Goodness of dynamic maxInstances in FastCGI

One of the major pain points in FastCGI 1.0 was that users were required to set maxInstances to a number which works best for their application. Many users didn’t tune this value and were running FastCGI with default value of maxInstances which didn’t give them optimal performance. We recommended users to set maxInstances to (10 * number of processors) if they don’t want to go through the pain of finding the ideal maxInstances for them which worked much better than default value but still didn’t give optimal performance. Even when users fine-tuned maxInstances to ideal value, they didn’t always get best possible performance at all times due to variations in traffic, server/application configuration changes and code changes.
In IIS 7.5 we fixed this pain point by making FastCGI module capable of monitoring system state and adjust this number dynamically to give best possible performance. This feature is referred to as dynamic maxInstances or auto maxInstances and can be enabled by setting maxInstances value to 0. As we intend to maintain a consistent platform for PHP developers on WinXP and above, we have added this feature to FastCGI ISAPI 1.5 and made it available on IIS 7.0 as well (read more here). Last week I spent some time comparing dynamic maxInstances results with suggested maxInstances value (10 * processor count) results and below is what I got.
Hardware: Quad core machine with 4 GB RAM
Application: Joomla


MaxInstances = 40
MaxInstances = 0
%age difference
Path Length (less is good)
Response Time (less is good)
844 ms
783 ms
Context switches/sec (less is good)
Requests/Sec (more is good)
As you can see, all performance parameters improved considerably just by changing maxInstances to 0. Our testing showed similar improvements in performance of other PHP applications as well. So we changed the default value of maxInstances to 0 in FastCGI ISAPI 1.5 and Win7. Note that if a value is explicitly set in fcgiext.ini or applicationHost.config, that value will override default value. Due to restrictions of QFE release process, we couldn’t change the default of maxInstances in IIS 7.0. So you are required to enable dynamic maxInstances after install this update on IIS 7.0.
We typically run many applications on our performance bench machines and were required to choose one maxInstances number for all applications. Choosing a different maxInstances number for each application was a better way to do performance testing but that was painful. Now with dynamic maxInstances, we get optimal performance for each application without any pain. Our performance testing is loving this feature and I hope you love it too.

7 thoughts on “Goodness of dynamic maxInstances in FastCGI

  1. Pingback: Testing File Change Notification support on WinCache 1.1 Beta2 : Don Raman's Blog : The Official Microsoft IIS Site

  2. Pingback: Tweets that mention Goodness of dynamic maxInstances in FastCGI « Kanwaljeet Singla --

  3. Thanks changed our MaxInstances from MaxInstances=8 to MaxInstances=0

  4. Does the same for Fastcgi with wincache installed?
    I found max instances of between 2 and 4 to be fastest for us.
    A setting of 0 seems to simply set between 1 and 4 instances (for our setup.traffic) depending on load but also causes wincahce to not to perform as well because of the php-cgi.exe constant changes in # of instances.
    We do about 1.4 pages vies per month.

  5. We run a Windows Server 2008 Enterprise 32bit setup with 4Gb ram and a 6core AMD processor. Wil setting the instances to 0 work or is this only for 64bit servers?

  6. Hi,

    Setting instances to 0 will help 32-bit systems as well. This setting pretty much saves you from finding the idea number which works for your server. Also this number will change dynamically to make FastCGI work in most optimal configuration at any given time. Static number might not work if some parameters like traffic/server configuration changes.


Leave a Reply

Your email address will not be published. Required fields are marked *