Php-fpm.conf important parameters max_children and request_terminate_timeout

Source: Internet
Author: User
Php-fpm.conf important parameters max_children and request_terminate_timeoutphp-fpm.conf have two crucial parameters: one is max_children and the other is request_terminate_timeout. one of my two sets is 40 & amp; Prime ;, one is 900 & amp; Pr php-fpm.conf important parameters max_children and request_terminate_timeout php-fpm.conf have two crucial parameters: one is "max_children ", the other is "request_terminate_timeout". one of the two values is "40" and the other is "900". However, this value is not common and needs to be calculated by yourself. The calculation method of www.2cto.com is as follows: if your server has good performance and sufficient bandwidth resources, and the PHP script does not have loops or bugs, you can directly set "request_terminate_timeout" to 0 s. 0 s means to keep the PHP-CGI running without a time limit. And if you can't do that, that is, your PHP-CGI may have a BUG, or if your bandwidth is insufficient or your PHP-CGI may be suspended for other reasons, we recommend that you assign a value to "request_terminate_timeout", which can be set based on the performance of your server. In general, the better the performance, the higher you can set, 20 minutes-30 minutes can be done. Since my server PHP script takes a long time to run, some may take more than 10 minutes, so I set 900 seconds, this will not cause the PHP-CGI to die and the 502 Bad gateway error occurs. How is the value of "max_children" calculated? In principle, the larger the value is, the better. if the php-cgi process is too large, it will process very quickly and there will be very few requests in the queue. "Max_children" also needs to be set based on the server performance. generally, a server normally consumes about 20 MB of memory per php-cgi, so my "max_children" I set to 40, 20 M * 40 = 800M that is to say that at the peak of all PHP-CGI consumption exists within M, less than my effective memory 1 Gb. If my "max_children" settings are small, such as 5-10, php-cgi will be "very tired", the processing speed will be slow, and the waiting time will be long. If a request is not processed for a long Time, the error 504 Gateway Time-out occurs, if the php-cgi that is working very well encounters a problem, the 502 Bad gateway error will occur. Www.2cto.com max_requests means that if each process exceeds this number (it has little to do with the php process), it will automatically kill .. I should set 512 here, but I'm too lazy to test it. it's a large one, but I don't want to set it too large. it's a struct. it's not tested. it's close to 8 K to 9 K. setting 100 kB on the Internet is a waste of memory. the waste size of a process is close to 1 MB. according to the 128 processes commonly configured on the Internet, the waste is about MB. okay, I admit that m is the cabbage price, but don't waste it .. = max_children is basically the number of processes. the process with nginx is not as big as you think, because FPM will manage the processes on its own (to be verified, at least I simply browsed the source code, I think it means this ). too large parameters should not be set, which occupies a lot of memory, so you don't need to talk about the consumption of processes. max_children is better set according to req/s. If the program is 100 req/s, the processing capability is .. if the maximum concurrency is 10 kb, it is better to set 100, which is dynamically adjusted. however, if you use php 5.3, you can also set the style to apache-like. set start_servers, min_spare_servers, and max_spare_servers to automatically adjust the three parameters. for details, refer to the configuration file, after such settings, high load and complex php programs will save you a little trouble. after all, testing req/s is a terrible physical activity.
 

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.