SYMPTOMS – IIS is using up a lot of memory – resulting in a slowing down of request processing. Both – single request processing  – as well as throughput (number of requests processed /sec) are subsequently slowed down.

CAUSE  – If your request contains a ‘long-running’ task – and you end up sending multiple such requests to IIS, pretty soon all available threads in IIS are TIED UP processing these requests.

POSSIBLE SOLUTIONS :

Web Gardens

You can assign more than one IIS worker process for a given application pool (this is called a Web Garden). What this does is effectively provide you with more threads to use. You can accomplish the same thing by increasing the maxThreadsPerCPU (set to 0 for max), however, this is probably set as 0 anyway. So your next step is to create multiple worker processes – each of which uses up all the threads it can. Note that this workaround works only if your ‘long running task’ is not CPU intensive. If it is chewing up CPU resources, creating a web garden (more processes that chew up the CPU) will only make the problem worse. For tasks that simply chew up threads – and are not CPU intensive (e.g. Database UPDATES), the WEB GARDEN workaround is an acceptable one.

IIS 8.0 Onwards

The first question to ask is – what is your ASP.NET code doing that is causing this slow down? Whatever this long-running request (task) is (in your asp.net code), you can consider moving it to an IIS background worker process.  This is a new feature available in IIS 8.0.

IIS 7.X

There are certain configuration parameters that you can utilize to control the number of threads used per IIS worker process . These include the following parameters:

<system.web>
   <applicationPool maxConcurrentRequestsPerCPU="12" maxConcurrentThreadsPerCPU="0" requestQueueLimit="5000"/>
</system.web>

What are some long-running tasks that chew up threads (but not CPU)?

  • Applications that make long running database requests
  • Applications that have  long-running, synchronous requests (transactions)
  • Applications that have  long-running , network intensive transactions

Overview of Application Pools and Worker Processes

  1. One IIS server may have multiple application pools.
  2. One web application binds to one application pool.
  3. One application pool may have more than one worker process (when Web Garden is enable).
  4. One worker process can have multiple app domains (an asp.net only concept). One app domain lives only in one worker process.
  5. One app domain may have multiple threads. One thread can be shared by different app domains in different time.

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.