In my previous test, the max number of php-cgi process is 10 when there are a lot of concurrent requests. For example, there are 25 concurrent requests. IIS will start 10 processes first. 10 requests will get response. Then start 10 prcesses again to give response another 10 requests. At last, start 5 requests to handle last 5 requests. 10 processes is the number that IIS automatically select the optimal number of FastCGI processes for the current execution environment. It depends on the setting of Max Instance, set it for larger process number.
Make sure that FastCGI always recycles the php-cgi.exe processes before the native PHP recycling kicks in. The FastCGI process recycling behavior is controlled by the configuration property instanceMaxRequests. This property specifies how many requests the FastCGI process will process before recycling. PHP also has a similar process recycling functionality that is controlled by an environment variable PHP_FCGI_MAX_REQUESTS. By setting instanceMaxRequests to be smaller or equal to PHP_FCGI_MAX_REQUESTS, you can ensure that the native PHP process recycling logic will never kick in.
In the Edit FastCGI Application dialog box, set InstanceMaxRequest to 10000, and then click on the browse button next to the EnvironmentVariables setting. Add the PHP_FCGI_MAX_REQUESTS environment variable and set its value to 10000.
So, only when client closes the browser to disconnect, process will be closed(not close immediately). However, if there's a new request, IIS won't start a new process but let previous free process handle it.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Bruce Zhang