This specifies the connection, send, and read of PHP-CGITime, 300 seconds is enough, so mineserver504s rarely appearGatewayTime-out error. The most important thing isphp-fpm.confofSet up, which will directly lead to 502 Bad Gateway and 504 Gateway Time-out.
Let's take a closer look at some important parts of php-fpm.confparameter:
php-fpm.conf has two crucial parameters, one is "max_children" and the other is "request_terminate_timeout"
I have two settings with values of "40" and "900", but this value is not universal, but needs to be calculated by myself.
Here's how it's calculated:
If yoursserviceinstrumentperformanceGood enough, and the broadband resources are sufficient, PHPScriptIf there are no loops or bugs, you can just set the "request_terminate_timeout" to 0s. 0s means that PHP-CGI runs all the time without a time limit. If you can't do this, that is, your PHP-CGI may have a certain bug, or your bandwidth is not enough or other reasons cause your PHP-CGI to fake death, then it is recommended that you assign a value to "request_terminate_timeout", which can be set according to the performance of your server. Generally speaking, the better the performance, the higher you can set it, 20 minutes -30 minutes is fine. Since my server PHP scripts take a long time to run, some can be more than 10 minutes, so I set it to 900 seconds so that it doesn't cause PHP-CGI to die and get the 502 Bad gateway error.
And how is the value of "max_children" calculated? In principle, the bigger the better, php-cgiprocessIf there are more, it will be processed quickly, and there will be few requests in the queue. max_children Generally speaking, under normal circumstances, a server consumes about 20M of memory per php-cgi, so I set my "max_children" to 40, 20M*40=800M, which means that all PHP-CGI consumed less than 800M at peak time, which is lower than my effective memory of 1Gb. And if my "max_children" is set smaller, such as 5-10, then php-cgi will be "very tiring", the processing speed is also very slow, and the waiting time is longer. If the request has not been processed for a long time, the 504 Gateway Time-out error will appear, and the php-cgi that is being processed will encounter a 502 Bad gateway error if it encounters problems.
|