- Plesk for Linux
Websites that have PHP handler set as FPM application served by Apache or FPM application served by nginx at Domains > example.com > PHP Settings load slowly or are not accessible (permanently or periodically) with a 50x error in a web-browser:
PLESK_INFO: 500 Internal Server Error
PLESK_INFO: 502 Bad Gateway
PLESK_INFO: 503 Service Temporarily Unavailable
PLESK_INFO: 504 Gateway Time-out
The following message appears in the PHP-FPM error logfiles:
CONFIG_TEXT: WARNING: [pool example.com] server reached max_children setting (*), consider raising it
The number in the output indicates how many times this message have appeared:
# grep -r "server reached max_children setting" /var/log/*php*-fpm* | wc -l
The message above is usually accompanied with this error:
# grep -r "unable to read what child say: Bad file descriptor (9)" /var/log/*php*-fpm* | wc -l
Server performance may decrease due to php-fpm processes that use up to 100% of CPU.
If nginx is enabled on the server, one of the following error messages may appear in domain's error logfile
CONFIG_TEXT: [error] 11456#0: *118348 connect() to unix:///var/www/vhosts/system/example.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 203.0.113.2, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/example.com/php-fpm.sock:", host: "example.com"
CONFIG_TEXT: [error] 20058#0: *4725139 upstream prematurely closed connection while reading response header from upstream, client: 203.0.113.2, server: example.com, request: "POST /path/to/some/file HTTP/2.0", upstream:
New child processes of PHP-FPM master process cannot be spawned due to reached the
pm.max_children limit. This may happen due to:
- high website traffic
- unoptimized application code, which may cause long living PHP-FPM processes hitting limit overuse. Website connections are not closed properly and remain hanged, until
pm.max_childrenfor a domain is reached.
pm.max_children limit for affected domains:
Connect to the Plesk server via SSH.
Find affected domains using the commands below:
Note: The number on the left indicates how many times the the
pm.max_childrenlimit has been reached by the website.
# grep -r "server reached max_children setting" /var/log/*php*-fpm* | cut -d' ' -f5 | tr -d ']' | sort | uniq -c | sort -nr
pm.max_childrenlimit for the listed above domains.
Note that the server performance can be affected if
pm.max_childrenis too big. In this example, we are setting
Plesk Onyx 17.5 and newer releases
Plesk Onyx 17.0 and previous releases
If raising the
pm.max_children parameter considerably does not help, consider to review website code to understand the reason of hanging connections.
Note: PHP profilers such as xdebug may help to find out the bottleneck at expense of lower performance during the profiling.