Related parameters:
PM = XXX: How to control child processes, options are static and dynamic, OnDemand (ondemand: No child processes are created when starting, and are created when new requests are made).
Pm.max_children = XXX:
The number of PHP-FPM child processes created when PM = static;
The maximum number of PHP-FPM child processes that are created when pm = Dynamic or OnDemand.
Pm.start_servers = xxx:dynamic mode, the system will start the "Pm.start_servers" php-fpm sub-process when PHP-FPM is running.
Pm.min_spare_servers = the number of minimum idle processes in xxx:dynamic mode. If the idle process is less than this value, the corresponding process is created.
pm.max_spare_servers = number of maximum idle processes in xxx:dynamic mode. If the idle process is larger than this value, the extra idle process is killed.
The system adjusts the number of PHP-FPM processes dynamically between "pm.min_spare_servers" and "pm.max_spare_servers" based on demand.
Values for the relevant parameters:
Use the PS command to view the memory size of each PHP-FPM process: After a period of running, each process consumes about 20m-30m.
# ps -ylc php-fpm --sort:rsss uid pid ppid c pri ni rss sz wchan tty time cmds 0 29355 1 0 80 0 4352 51301 ep_pol ? 00:15:03 php-fpms 2002 12865 29355 0 80 0 19296 54206 skb_re ? 00:58:51 php-fpms 2002 29365 29355 0 80 0 19780 54335 skb_re ? 05:44:56 php-fpmS 2002 29359 29355 0 80 0&Nbsp;21280 54650 skb_re ? 05:44:51 php-fpms 2002 29357 29355 0 80 0 21676 55289 skb_re ? 05:44:18 php-fpms 2002 29358 29355 0 80 0 22716 55033 skb_re ? 05:43:25 php-fpms 2002 29362 29355 0 80 0 26576 56073 skb_re ? 05:43:56 php-fpmS 2002 29360 29355 0 80 0 26864 56144 skb_re ? 05:44:18 php-fpmS 2002 29361 29355 0 80 0 26888 56165 skb_re ? 05:43:32 php-fpms 2002 29356 29355 0 80 0 26896 56109 skb_re ? 05:44:23 php-fpmS 2002 29370 29355 0 80 0 27196 56146 skb_re ? 05:43:10 php-fpmS 2002 29371 29355 0 80 0 27240 56160 skb_re ? 05:44:10 php-fpms 2002 29363 29355 0 80 0 27460 56227 skb_re ? 05:44:30 php-fpms 2002 29373 29355 0 80 0 27636 56742 skb_re ? 05:43:27 php-fpms 2002 29366 29355 0 80 0 28436 56427 skb_re ? 05:42:49 php-fpms 2002 29374 29355 0 80 0 28636 56494 skb_re ? 05:44:40 php-fpms 2002 29368 29355 0 80 0 28844 56999 skb_re ? 05:44:05 php-fpms 2002 29375 29355 0 80 0 29972 56842 skb_re ? 05:43:18 php-fpms 2002 29367 29355 0 80 0 30048 56800 skb_re ? 05:43:31 php-fpms 2002 29364 29355 0 80 0 35872 58251 skb_re ? 05:44:25 php-fpms 2002 29372 29355 0 80 0 42840 60428 skb_re ? 05:44:19 php-fpm
PM which to use, according to the server hardware configuration to decide it. Process generation and destruction will bring a certain amount of resource overhead, so considering the stability, the choice of static more appropriate. The use of dynamic can end redundant processes and free up memory.
Pm.max_children value of the set, generally take "memory/20m". The memory here is not included in the memory that other processes occupy.
Pm.start_servers value =min_spare_servers + (max_spare_servers-min_spare_servers)/2
For example, 512M VPS, if allocated to PHP-FPM maximum 250M, the recommended pm.max_spare_servers set to 250/30, about 8. As for Pm.min_spare_servers, it is recommended that you set the load on the server, for example, if the server is just deploying a PHP environment, the more appropriate values are between 2~5.
In addition: Pm.max_requests = 500, sets the number of requests for the service before each child process restarts. is useful for third-party modules that may have a memory leak. If set to ' 0 ', the request is always accepted.
PHP-FPM Sub-process count control