English 中文(简体)
high cpu useage on w3wp process
原标题:

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.

问题回答

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

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.





相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签