Matching IIS Worker Processes to Application Pools.

This technique can be used to determine which application pool holds the sites in which the w3wp process is pegging the CPU. Sites will need to be separated into individual app pools by process of elimination to determine exactly which site is spiking CPU usage.

Get task manager configured.
1.    First launch task manager by either right-clicking on the task bar or Start -> Run -> taskmgr
2.    Navigate to the processes tab.
3.    Select View -> Select columns -> PID
4.    Open a command prompt Start -> Run -> cmd

For IIS 6
1.    Run the command iisapp from a command prompt.
2.    If you get an error message about wscipt just hit yes and let it register with cscript.
3.    A list of application pools and their PID will be returned:
W3wp.exe PID: 2232 AppPoolID: DefaultAppPool
W3wp.exe PID: 2608 AppPoolID: MyAppPool

For IIS 7
Iisapp has been replaced by: %windir%\system32\inetsrv\appcmd.exe list wp. The output of the command is slightly different as well but contains the same info:

WP “6488″ (applicationPool:Classic .NET AppPool)