Which w3wp.exe process belongs to which App Pool in IIS6

Along with Windows Server 2003 and Internet Information Services 6.0 came a large number of benefits.  For us IIS admins, it was a great welcome set of changes. But, one apparent difficultly is matching up the w3wp.exe processes displayed in Task Manager to the Application Pools in IIS.

Review of IIS5

In IIS5.0 (Windows 2000 Server), each site that is set to Out Of Process will spin up a new instance of dllhost.exe.  Windows Task Manager lists them.  Now, the trick is to find out which dllhost.exe matches which site.  My favorite way is to use Component Services.  To do so, open Component Services from Administrative Tools, drill down to Computers -> My Computer and select COM+ Applications.  Now select View from the top menu and select Status.  Beside each site that currently has a dllhost.exe process spun up is the Process ID (PID).  Using Task Manager, you can tell the memory and CPU.

Note:  If the Process ID doesn't display for you in Task Manager, select View -> Select Columns and add it.

What about IIS6?

But, that doesn't work anymore with IIS6.0.  Now each site in IIS6 is placed in an Application Pool.  Each Application Pool is completely separated from other App Pools by running in its own process called w3wp.exe.  This make life SO much easier.  Now, the trick is to match up the process shown in Task Manager with the Application Pool set up in IIS.

If there is a different user for each application pool, Windows Task Manager is the easiest way to find out which application pool belongs to which site since Task Manager will display the user the process runs as.

But, what happens if you have multiple application pools running as the same user?  For example, if you keep to the default NETWORK SERVICE user but create multiple Application Pools, you may want to know which process belongs to which App Pool.  Component Services doesn't work for this anymore.

Enough already, tell me how to do it!

Have no worries, Microsoft has given us the exact tool for the situation.  IISApp.vbs lists all the applications, their PID and their App Pool name.

The script is already placed in systemroot\system32 on Windows Server 2003 so simply go to your Command Prompt and type in iisapp.vbs (the .vbs is optional) and you'll have an instant list of all the App Pool information you've always wanted to know.  You may need to type cscript iisapp.vbs instead if CScript isn't your default WSH script host.

Let's see an example of the output:

Here is an example of the output.

W3WP.exe PID: 1468   AppPoolId: AppPoolForSite1.com
W3WP.exe PID: 3056   AppPoolId: AppPooForSite2.com
W3WP.exe PID: 1316   AppPoolId: AppPooForSite3.com

Direct from the horse's mouth, Microsoft documents this:

http://www.microsoft.com/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/Default.asp?url=/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/cl_as_viewapps.asp

Summary

We've seen here that using iisapp.vbs, you can painlessly match up the PID to the friendly name of the Application Pool.

 

11 Comments

  • worked for me! Thanks!

    -now, how do I make my default app pool not use so much memory?

  • Scott - I'm trying to convert IISApp.vbs to run in a .asp page.
    The page of getting all PIDs for all Pools Works OK.

    My goal - when I get a "Catastrophic failure" in an .asp page, I want to cause the POOL to be recycled.

    My .asp page is dying on "oScriptHelper.WMIConnect" within the "Function RecycleAppPool"

    Do you know of a way to recycle a pool from within a .asp page?
    Thanks very much

  • Ferrell, from Classic ASP, I would use ADSI. Here's a good example: http://blog.crowe.co.nz/archive/2006/07/11/669.aspx. Use the bottom example "Starting an Application Pool" but replace .Start() with .Recycle(). Make sure that the user account that your app pool runs under is an administrator account.

  • hi,

    I am seeing a problem with this w3wp.exe process.
    I use Crystal Report viewer to allow users to view crystal reports on aspx page. Now the issue is for each crystal report it starts a new w3wp.exe process and then it stays there.

    I thought w3wp.exe only starts for an app pool. WHy does it start for each crystal report accessed?

    any help is very much appreciated.
    Regards

  • Hi Utsavi,

    The only ways that I can think of that IIS would do this is are:
    - The Web Garden setting for the app pool is set greater than 1. It should be set to 1 which means that there will only be one w3wp worker process. Or,
    - There are failures and the previous worker process is failing when the new request comes in. You'll be able to tell if you watch it for a bit afterward and see if the previous worker process died.

  • Hi Scott,

    I really appreciate time you took out to look at my problem and respond.

    The Web Garden Setting for app pool is set to 1 only.

    I have been monitoring the w3wp.exe processes the whole day yesterday. Actually the problem seems to be related to the back end system that we use. We use InterSystems CACHE 2008.2 as back end. So the crystal reports make an ODBC connection to that database.

    When I run my User Reports Web App, I only see one w3wp.exe process in task manager but its the System Management Portal of out CACHE database where I see other w3wp.exe processes being added.

    As soon as I access the Web App I see one w3wp.exe process in both task manager and in System Management Portal of CACHE then when I run any crystal report I still see only one w3wp.exe in task manager but now in System Management Portal I see two w3wp.exe processes. So I assume it adds new process in our database SMP for crystal report (ODBC connection). I would assume it would try to use same process everytime but it creates new process everytime I access a crystal report.

    I tried to set Idle time out of worker process to 2 mins. So after two minutes all worker processes gets recycled. Which helps but not much.

    Not sure if you will be able to help with CACHE thing or not.

    Thanks for your help once again.

    Regards,
    Utsavi

  • Hi Utsavi,

    I would trust Task Manager over the CACHE System Management Portal. Also, if you have the web gardens set to 1, it's very unlikely that IIS will spin up new worker processors per requests. My guess is that the CACHE System Management Portal gives a view into something else. Possibly it's showing AppDomains rather than worker processes, or possibly it's mistaken. Can you have it show the PID? If so, that will confirm if they are all the same process.

    Is it hurting anything to have the extra worker processes shown?

  • Hi Scott,
    I have simple question in reference to w3wp.exe process. I have 10-25 application pools defined but yet only 3 w3wp.exe are running in task manager. I thought there would be a w3wp.exe process for each application pool. Am I missing something here?

    Any feedback will be appreciated.

    Thanks
    Jitesh

  • Hi Jitesh,

    You're right in that it's a one to one mapping of app pools to worker processes "if all sites are receiving traffic" (unless web gardens are more than one, in which case it's a one to many mapping.)

    However, a worker process starts on demand only when it needs to. So after an iisreset or reboot, you shouldn't have any IIS worker processes. Then as you get the first visit for each app pool you'll start to see w3wp.exe processes created.

    If you have the Idle Time-out setting set (20 by default) then after X minutes it will stop unused worker processes. So that will also causes you to have a small list of worker processes compared to actual app pools.

    Check out this quick video in my Web Pro series. It shows this in action: http://weblogs.asp.net/owscott/archive/2011/04/17/iis-s-overlapping-app-pools-week-16.aspx

  • Hi Scott,
    Thanks for the great feedback. BTW what does term web garden mean...do you mean load balanced farm with more than 1 web server.

    Thanks
    Jitesh

  • Hi Jetesh. A Web Garden is an IIS feature since IIS6. It's a setting on the app pool that allows more than one worker process per app pool. It's *rarely* useful. I'll save you the pain: just leave it at 1. I was trying to be complete in my answer that there isn't always a 1-to-1 mapping because of web gardens.

Comments have been disabled for this content.