title: How do I configure IIS-10 and FastCGI for high concurrency?
body: <p>Scenario: we have a php 7 web application using IIS10 via FastCGI. We did performance testing on our application and noticed a slowdown. We ruled out the database tier. We looked at the IIS server and, even under heavy load, when the app slows down dramatically, the resources are not strained... no CPU spikes no RAM spikes. Digging further we came to the conclusion that all the requests coming in are simply being queued.  When some of requests take longer (for some very large reports that take 1-3 minutes) then every other request is being queued up waiting for the first ones to go through.</p>
  <p>So, the question is: where do we look to increase the number of concurrent requests IIS can handle at one time?</p>
  <p>I have found these settings, under FastCGI, but VERY little documentation. Can someone explain what these four settings do?</p>
  <ul>
  <li>Instance MaxRequests</li>
  <li>Max Instances</li>
  <li>Queue Length</li>
  <li>Rapid Fails PerMinute</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/w6Ouh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w6Ouh.png" alt="enter image description here" /></a></p>
  <p>Are there any other settings  we should be looking at under DefaultAppPool?</p>
  <ul>
  <li>Queue Length</li>
  <li>Maximum Worker Processes</li>
  <li>Recycling</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/6grNI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6grNI.png" alt="enter image description here" /></a></p>
  <p>UPDATE:
  A few things should be clarified for other who might search this:</p>
  <ul>
  <li>a request in this context means one call from the browser to the IIS server</li>
  <li>we used jmeter <a href="https://jmeter.apache.org/" rel="nofollow noreferrer">https://jmeter.apache.org/</a> to do some basic load testing</li>
  <li>a request (for the sake of this context) from browser to IIS server will be processed like this: browser &gt; DefaultAppPool worker process (this is defaulted to 1 in IIS look into web gardens if you want to increase this) &gt; FastCGI instance (think of this as process threads, language is tricky and people on the web use threads/processes/instances interchangeably which can be confusing). FastCGI is defaulted to 4. So this means when 5 concurrent requests come through, they all get funneled through the 1 DefaultAppPool worker process and 4 of the 5 will be worked on concurrently by FastCGI and the 5th will be queued. We tested this: after an IIS restart there will be no w3wp.exe or php-cgi.exe processes running. When the 5 concurrent requests come in: w3wp.exe will get started and it will spawn 4 php-cgi.exe processes (check task manager)</li>
  <li>to increase concurrency we set FastCGI &quot;Max Instances&quot; to 0 which allows IIS to decide how much it wants to handle based on resources available but you can also set it to a specific higher number. We tested this and I believe it to be accurate. You can see the w2wp.exe process and php-cgi.exe processes increasing in number as requests are coming in.</li>
  <li>you should also be able to increase the DefaultAppPool worker processes, if you were to set this to 4 and leave the FastCGI instances to 4 as well that should mean, in theory, that each worker process would spawn its own 4 FastCGI instances for a total of 4x4=16 concurrent requests. I have not tested sufficiently to be sure 100% that that's how this actually plays out.</li>
  </ul>