R – Profiling CPU usage of ASP.NET web app – but not the database!

asp.netcpucpu-usageperformanceprofiling

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!

Best Answer

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

Related Topic