php-fpm.conf two key parameters

Source: Internet
Author: User

This specifies the connection, sending, and reading of the php-cgiTime, 300 seconds is enough, so myServer rarely appears 504Gateway time-out this error. The key thing is,php-Fpm.Conf'sSettings, this will directly lead to 502 bad Gateway and 504 Gateway time-out.
Let's take a closer look at some important php-fpm.conf parameters:
php-fpm.conf has two key parameters, one is "Max_children" and the other is "Request_terminate_timeout"
The value of my two settings one is "40″, one is" 900″, but this value is not universal, but it needs to be calculated by itself.
    is calculated in the following way:
      If your server performance is good enough and your broadband resources are sufficient, PHP If the script does not have loops or bugs, you can set the "request_terminate_timeout" directly to 0s. The meaning of 0s is to let php-cgi go on without time limit. And if you can't do this, that means your php-cgi may have a bug, or your broadband is not enough or other causes your php-cgi to be able to feign death then it is recommended that you assign a value to "Request_terminate_timeout". This value can be set based on the performance of your server. Generally, the better the performance, the higher you can set, 20 minutes-30 minutes. Because my server PHP script needs to run for a long time, some may be more than 10 minutes so I set 900 seconds, so that does not cause php-cgi dead and 502 bad gateway this error.

And how is the value of "Max_children" calculated? This value is in principle the bigger the better, php-cgi's process is much faster, and the queue requests are very small. Setting "Max_children" also needs to be based on the performance of the server, in general, a server normally consumes about 20M of memory per php-cgi, so my "Max_children" I set to 40, 20m*40= 800M means that at peak time all php-cgi are within 800M, below my valid memory 1Gb. And if my "Max_children" set the smaller, such as 5-10, then php-cgi will be "very tired", processing speed is also very slow, waiting for a longer time. If the request has not been processed for a long time, the 504 Gateway time-out this error, while the very tired of the php-cgi are dealing with the problem will appear 502 Bad Gateway this error.

Php-fpm.conf two critical parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.