W3WP.exe spikes web server CPU up to 30% on each postback

May 12 2011 12:54 PM

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.

-- If I create a new application and load it up - I don't have that problem.  So, obviously it must be in my application, right?

-- I don't have any additional httpmodules/handlers beyond the normal ones.

-- This is dealing with a data-bound page

Information
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.


Attachment: quickentry.zip

Answers (4)