How can I investigate 99% CPU usage by w3wp.exe?

7

1

w3wp.exe is showing 99% CPU usage. What are the best ways to investigate the cause of this high CPU usage?

Ravi

Posted 2009-04-28T09:56:53.853

Reputation:

Answers

6

Attach WinDbg + sos and run !runaway. That will show you which thread is taking the most CPU time. Do a !clrstack on the thread to find out what it is doing.

Brian Rasmussen

Posted 2009-04-28T09:56:53.853

Reputation: 236

4Can you link to or fill-in some instructions for attaching a process? I've been using Windows since 3.11, programming for a decade and have no idea how to do that. – Rob Allen – 2009-04-28T10:02:53.387

3

Both WinDbg and Visual Studio (and many other debuggers) can attach to a process in order to debug it. The reason I mention WinDbg is that the sos extensions make it relatively easy to find CPU hugs. For more information on WinDbg please see http://www.microsoft.com/whdc/devtools/debugging/default.mspx

– Brian Rasmussen – 2009-04-28T10:08:25.137

if issue in on LIVE server but I don't have access to it, do you have any suggestions. – None – 2009-04-28T13:10:40.767

Without access it is going to be a lot harder to find out. Try going through the source code then. Look for potential live locks, huge memory consumption (the problem may be that too much time is spend doing GC) and so forth. Without additional details it is hard to give specific advice. – Brian Rasmussen – 2009-04-28T13:31:32.263

3

Other suggestion of tools is DebugDiag, see more here
[UPDATE] Use ProcDump, see more at Using ProcDump.exe to monitor w3wp.exe for CPU spikes.

lsalamon

Posted 2009-04-28T09:56:53.853

Reputation: 131

Especially nice if none-developers have to provide the crashdumps etc. – None – 2009-09-02T20:18:48.247

2

w3wp.exe is the ASP.NET worker process, so if it is using a high percentage of the server's CPU, it is the ASP.NET application that is causing the problem. However, this does not necessarily indicate that there is a problem with the ASP.NET application. It may be serving too many requests with limited resources. The only real measure is to check the CPU usage against the amount of traffic being handled by the application.

If you are suspecting that a certain request takes too long, you could can use the Logparser command line utility to analyze your logfiles and find which page has a long execution time.

c:\>logparser "select top 10 cs-uri-stem, time-taken from INSERT_YOUR_IIS_LOG_FILE_NAME.log group by cs-uri-stem order by time-taken desc" -q:on

You could also use a tool to show which pages are currently executing, like IISPeek (not free).

If you want to go deeper, try to understand hwo to use WinDbg. Here is a good tutorial: Windows Debuggers: Part 1: A WinDbg Tutorial

splattne

Posted 2009-04-28T09:56:53.853

Reputation: 14 208

You need to have "time-taken" in the group by clause too, otherwise the script throws an error. – kafka – 2016-03-07T11:28:41.647

0

I've had this problem intermittently before. It seems to spike to 99% after the first request and never comes down. If I kill the process the new worker process usually behaves correctly. I've never figured out why this happens.

Greg

Posted 2009-04-28T09:56:53.853

Reputation: 207

0

We're having the same issue Greg notes above. We're just killing those processes. Didn't observe this on IIS6/windows server 2003, only on IIS7/windows server 2008.

Larry Dallas

Posted 2009-04-28T09:56:53.853

Reputation: