Saturday 25 April 2015

Performance Monitor (perfmon): Correlating w3wp# to App pool process


The Windows Performance Monitor (perfmon) is a useful tool to capture run-time performance metrics such as CPU utilisation, .NET  GC runs etc.

Problem

The IIS web applications execute on multiple"w3wp" processes and it can be difficult to profile a single web application using perfmon. Perfmon simply name each process as "w3wp#1", "w3wp#2", which is not helpful at all!.
Multiple w3wp processes in perfmon


The goal of this post is to help identify the relevant "w3wp" process and map it back to the application pool.

Step 1 : Find the Process Id of the application pool process

Navigate to C:\Windows\System32\inetsvr folder and issue the command in the following screen capture. (appcmd list wp).
Finding out Process Id per application pool

The appcmd command returns the names of each application pool together with their process Ids. At this point we know the process Id and application pool that we are interested in.

Step 2: Add the requisite performance metric to perfmon

Simply add the metric to perfmon. I have added the CPU utilisation and most importantly the process Id. The process Id can be found under "Process" category.
Adding CPU utilisation with process Id

Step 3: Monitor the metric added in Step 2 

The sample metric looks like below:

Captured metric in perfmon
The most interesting piece of information is highlighted in the capture. We can see that the process id "4780" is in fact the "Stub" service as per Step 1.

Concerns

What if there are dozens of web application in IIS? The steps discussed here are for a simple case and does not scale well unfortunately. However I have seen some answers in StackOverflow that suggest to modify few registry keys that can provide a more meaningful name.

I do see that perfmon is not the best tool for performance monitoring. But I do think it is not too bad once you get use to it. (I do prefer dotTrace!).

1 comment:

  1. Casino Site Review + Bonus Code - LuckyClub
    Find the luckyclub.live best Casino Site Review ✔️ Grab a deposit bonus worth up to ₹100 ✔️ Deposit ₹500 Bonus ✔️ Deposit today ✔️ Live chat.

    ReplyDelete