IIS with FAST CGI not closing the php-cgi process on task manager getting the server stock.

Manuel Alejandro Grande 1 Reputation point
2022-03-11T19:30:32.483+00:00

Currently a website is located under IIS server using php and the Fast CGI process, at the moment that users start using the Website, the task manager shows how the php-cgi process increase 1 by 1 and some times like 10 process at the time.

The problem is that the CGI process never closed and increase the numbers of process in my server getting everything down.

I will appreciate an insight about the configuration process that i have to do in order to resolved my issue.
The CGI config on the ISS is per default, nothing has change.

Windows development | Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,771 Reputation points
    2022-03-14T02:21:57.29+00:00

    Hi @Manuel Alejandro Grande ,

    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.
    182519-2.png

    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.
    182567-1.png

    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

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.