1

I am encountering an issue with my asp.net c# web application where the server is hitting very high cpu useage eg. 80%+ on w3wp process.

This has only happened recently after I made numerous changes to my application. I am fairly sure that it may be one of the changes that I have made is causing this issue with high cpu useage on the iis 7 web server.

Is it possible to analyze the process and find what exactly is causing this high useage? Or what is the mechanism for debugging such an issue.

amateur
  • 43,371
  • 65
  • 192
  • 320

2 Answers2

0

ASP.NET Case Study: High CPU in GC - Large objects and high allocation rates:

A high CPU issue is generally one of 3 things

  • An infinite loop
  • Too much load (i.e. too many requests doing lots of small things, so no one single thing is a culprit)
  • Too much churning in the Garbage Collector.

Try monitoring the % Time in GC counter and the .NET CLR Memory / # Gen 0 Collections, # Gen 1 Collections and # Gen 2 Collections.

Are you calling GC.Collect() anywhere in your code?

The problem you are describing also sounds symptomatic of High CPU in .NET app using a static Generic.Dictionary, caused by multiple threads hitting the dictionary. If that's the problem:

To resolve this timing issue you should take special care to synchronize (lock) around access to the dictionary if there is a possibility that you may have multiple writers working at the same time or if there is a possibility that you write while someone else is reading/enumerating through the same dictionary.

Related: ASP.NET Performance Monitoring, and When to Alert Administrators

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
0

The quickest way is to enable Page Tracing. This will tell you exactly how long the page took to generate, and in which methods the server spent most of it's time. This should highlight any particularly slow-running methods, allowing you to focus your troubleshooting on the problematic sections.

Simply add the following to any pages you suspect of being troublesome:

<%@ Page Trace="true" %>

Now, when you navigate to that page in your browser, you will get a detailed trace at the bottom of it.

RB.
  • 36,301
  • 12
  • 91
  • 131