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