title: What is the relationship between Application Pools and worker process threads?
body: <p>I'm troubleshooting restarts in an ASP.NET application. The application is restarting about 20 times a day. We strongly suspect one part of the application because the restarts began when this particular feature when into production. I've added some logging to those pages using the log4net library, but I'm having trouble interpreting the logs.</p>
  
  <p>When an ASP.NET application is running in an Application Pool, does only a single instance of that application run, or will multiple instances of that application run? I know several worker process threads will be spawned. What is the relationship of the worker process threads to the application(s) running in the App Pool?</p>
  
  <p>I am thinking that I may not be interpreting the results correctly if there are multiple applications logging to the same log. If one is restarted but the other is not, the logs aren't really telling me much about what was happening when the restart occurred.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>Looking at <a href="http://www.iis.net/configreference/system.applicationhost/applicationpools">this page</a>, I find the following information:</p>
  
  <blockquote>
    <p>An application pool defines a group of one or more worker processes, configured with common settings that serve requests to one or more applications that are assigned to that application pool. Because application pools allow a set of Web applications to share one or more similarly configured worker processes, they provide a convenient way to isolate a set of Web applications from other Web applications on the server computer. Process boundaries separate each worker process; therefore, application problems in one application pool do not affect Web sites or applications in other application pools.</p>
  </blockquote>
  
  <p>But I am still confused. I know from experience that I can assign two entirely different applications to use the same App Pool. Does that mean that exactly two worker processes will be spawned? Or can there be multiple worker processes spawned for the first app, and multiple worker processes spawned for the second app? If a problem happens in one worker process, can it take down every application running in that App Pool?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>From <a href="http://msdn.microsoft.com/en-us/library/Ee817662%28pandp.10%29.aspx">this page about using WinDbg</a>, I found this information (emphasis mine):</p>
  
  <blockquote>
    <p>In IIS 5.x, there is only one Aspnet_wp.exe worker process and one debugger thread. Consequently, only one debugger can be attached to the Aspnet_wp.exe process at a time. This can pose a problem if you're dealing with multiple Web applications on the same machine. In IIS 6.0, you can coerce an AppDomain to run in a separate application pool. (For more information, see "IIS 5.x Process Model" and "IIS 6.0 Process Model" in Chapter 1.) <strong>Separate application pools provide multiple W3wp.exe processes.</strong> Multiple debugger threads are created in these processes (one in each), allowing you to debug more efficiently.</p>
  </blockquote>
  
  <p>This sounds to me like each App Pool gets one <code>w3wp.exe</code> process. Am I interpreting that right? And if so, does that still apply in IIS 7.5?</p>