PHP-FPM Process Management and sub-process number allocation principles detailed

Source: Internet
Author: User


PHP-FPM Process Management PM is an important parameter to control the number of child processes.

There are three ways to manage PM processes:


Static


Indicates that the Pm.max_chindren child process is fork directly when the PHP-FPM runs


Dynamic


Indicates that the runtime fork out pm.start_servers process, with the load situation, dynamic adjustment, up to no more than pm.max_children process. At the same time, to ensure that the number of idle processes is not less than the number of pm.min_spare_servers, otherwise the new process will be created, of course, is not unlimited creation, the most idle process does not exceed the number of pm.max_spare_servers, more than some idle process is cleaned up.


OnDemand


When a request is made, the process is created, the startup is not created, the maximum number of pm.max_chindren processes is not exceeded, and when the process is idle, it is released in time after pm.process_idle_timeout seconds.


If you choose to configure PM parameters?


Dynamic for small memory machine, flexible allocation process, save memory. Static applies to large memory machines, and the dynamic creation of the recycle process is also a drain on server resources. General large traffic applications do not choose OnDemand because fork a large amount of process overhead.


How should the number of PHP-FPM child processes be set?


The normal production environment will choose the static method


With respect to Max_children, [the amount of memory can be exploited/(* 1.2 of a single process memory *)]; Alternatively, it can be set to a larger [amount of memory/single process memory], and then observe (PHP-FPM's running state), through Max Active Processes parameters to properly configure.

There is a suggested formula for Start_servers, Min_spare_servers and max_spare_servers officials:

Start_servers = Min_spare_servers + (max_spare_servers-min_spare_servers)/2


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.