why is php-fpm spawning and destroying hundreds of children per second with no server load?
Neither misconfiguration nor buggy version. In fact, there is nothing to be worried about.
The reason your processes are exiting and respawning that fast is that you are using the default value for pm.max_requests
in your php-fpm pool configuration file as it's commented via a semi-colon ;
symbol. To understand what pm.max_requests
parameter stands for you can read the following description taken from the default configuration:
pm.max_requests = int
The number of requests each child process should execute before respawning. This can be useful to work around memory leaks in 3rd party libraries. For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. Default value: 0.
And yours is 0 since it's commented. You can set it to something like 100-500 (depending on your needs) so as to have your php-fpm recycling the process after processing that amount of requests.
By the way, you should note that these messages in your log file is only informational and there is nothing wrong, so don't you worry. These log entries can be avoided by using the value of warning
instead of notice
for the log_level
parameter in php-fpm.conf
. It is almost showing everything - a bit less than debug
level - since the default value is set to notice
.
Taken from the default configuration:
log_level = string
Error log level. Possible values: alert, error, warning, notice, debug. Default value: notice.
Good Luck