First of all - the explanation:
I have a web app I have developed that "functions" properly, just not optimally. Whenever I activate a control that causes a postback, the CPU on the server spikes to about 30% (w3wp.exe) and retreats to nothing within a few seconds. This causes considerable performance issues in both the front-end and the server. Whether it's a drop-down box that causes a SQL query through it's "SelectedIndexChanged" event, or just postback that massages data already on the form without a SQL call.
In an attempt to provide useful information, here is what I have tried and the results so far:
-- Looked at this, but I can already see what is causing my spike
http://forums.asp.net/t/1181591.aspx/1?w3wp+processor+spikes
-- Tried this URL, but I couldn't find anything out of the norm. I may just not know what to look for:
http://blogs.msdn.com/b/webtopics/archive/2009/08/08/using-procdump-exe-to-monitor-w3wp-exe-for-cpu-spikes.aspx
-- Went through all of my code to remove the old-style string concatenation and did it with StringBuilder instead.
-- Set Compilation Debug to false (marginal front-end improvement, but no improvement on CPU)
-- Tried installing and enabling the DynamicCompressionModule (compdyn.dll). That improved the front-end performance noticably, but did not affect the CPU utilization.
-- There is currently no anti-virus on this machine because it is just a development server for now, but I did run a scanner on it with the latest definitions to make sure it was D&D free.
-- I don't have any additional httpmodules/handlers beyond the normal ones.
-- This is dealing with a data-bound page
1. On the original site, I had created a separate application pool (I have since moved it to the traditional ASP.NET 4.0 pool to no avail)
2. On this particular page, I am not accessing Active Directory, but I am on the Default page
3. This is a data-driven page and uses a few SqlDataSources in the ASPX code
Discoveries
1. Moving to a new application pool did nothing for me
2. Starting fresh proved not to drag-down the CPU. Starting fresh means I put a button and a textbox on the page and had the button populate the textbox with the date and time.
3. This is not limited to just data-bound pages.
I figure it will be easier if I make the code available to you. I have uploaded it -->to this ZIP file.
Contents of QuickEntry.ZIP
QuickEntry.aspx
QuickEntry.aspx.cs
AD.cs (Active Directory handler)
Site.Master
Site.Master.cs
Web.Config (with sensitive data replaced by xxxxxx)
Here are my server specs:
Intel Xeon 3.4GHz Quad-Core
4GB RAM
IIS 7.0
Windows Server 2008 R2 Enterprise 64-bit SP1
Microsoft SQL Server 2008 Standard SP2
ASP.NET 4.0
Can anyone point me in the right direction? If my CPU spikes at 30% with one user clicking on one item, surely it will crash if I release it to my users. Let me know if you need me to post anything else.
Suthish NairPosted May 13, 2011, 2:42 AM
Instead of storing huge records in session objects, refer different ways to pass values across web pages..
Different Ways to Pass Data between Web Forms
Manikavelu VelayuthamPosted May 13, 2011, 1:48 AM
From there you can fix the problem easily.
They are open source tools only.
You could get a clear cut idea on whats happening behind the screen.
It can be your database hit, page rendering or any javascript, network cost like that all information will be displayed over there.
Revert back to me once you fixed the issues using the above tools.
Shane KahkolaPosted May 12, 2011, 5:35 PM
Thank you. I did check to make sure I wasn't shoving massive amounts of data to the drop-downs, but the biggest one is 30 items.
Otherwise, I added the "UpdateMode='Conditional'" to the UpdatePanels and it did improve performance -- though only nominally.
Additionally, I removed the session variable I was creating that contained a large comma-delimited string containing all of the AD groups in which the user was a member. I thought maybe that was impeding the postbacks. Again, there was improvement in performance, but nominal.
So, apparently those were great suggestions, but they aren't fully eliminating my problem. I'll keep posting my troubleshooting steps.
Any additional ideas would much appreciated.
Suthish NairPosted May 12, 2011, 2:05 PM
Always use UpdateMode="Conditional" for update panel.