views:

933

answers:

4

I'm seeing consistently high CPU usage for my ASP.NET web application (on the live production box only, naturally....!) and I'm trying to narrow down the cause - it's basically maxing out a quad core Xeon box and there's no way it should be able to do that!

The CPU usage of the web process is generally higher than that of the DB process - which rings alarm bells to me on its own (?).

However, using the standard profiling tools (dotTrace, Red Gate etc) only show you the time spent in individual methods (rather than actual CPU usage) - and ultimately still highlight methods that are DB-bound. While this might indicate opportunities for caching or better indexes, I don't see how that in itself would result in high CPU usage of the web application process?

Any suggestions or tips as to how I can narrow this down?

Thanks!

A: 

Can you set up some unit tests to call various methods and see what their impact is on processor usage? Visual Studio has some testing tools built in if you're using Team System, but even if you're not, you could write a multithreaded tester to call particular functions hundreds of times.

If you'd like some pointers on how to do this, I can help you build some basic unit testing.

rwmnau
+1  A: 

Some suggestions to try at the first place.

1.Deploy with Release Build Check whether the deployed product is in release mode. By running in debug mode, lot of time is wasted loading the pdbs along with the assemblies.

2.Disable ViewState Disable viewstate if its not required. ViewState is nothing but data stored in hidden fields to be persisted between requests. it increases the total payload of the page both when served and when requested. There is also an additional overhead incurred when serializing or deserializing view state data that is posted back to the server. Lastly, view state increases the memory allocations on the server.

3.Disable Session State:

If you are not going to use it disable Session State. By default it’s on. You can actually turn this off for specific pages or for the whole application.

There are some basic ASP.NET application performance monitoring, check these two MSDN articles "Monitoring ASP.NET Application Performance" and Performance Counters for ASP.NET

Pradeepneo
A: 

are you recording/reporting unhandled exception? If not do so and check if any of them correspond with your high CPD spikes you may have a stack overflow causing the spikes.

http://msdn.microsoft.com/en-us/library/ms998306.aspx

You could also look into recoding the time of each request by using a HttpModule and checking which requests are taking up the most time which may indicate the pages that are causing the issue.

Damien McGivern
A: 

As Pradeepno notes, the place to start with is really performance counters--they can give you a very good idea of what is consuming what part of the CPU.

The web app usage being higher than DB usage isn't entirely suprising. If you have decent db design, most web apps are barely going to cause a decently powered DB server to break a sweat.

Wyatt Barnett