PHP-FPM Reached Max Children


Recently my PHP scripts became unresponsive, and the browser just kept on trying to load the page. This was odd since the script works on my local machine, but not the development server. There was no apparent reason for this issue.

I then discovered that the PHP-FPM log showed the following message:  “WARNING: [pool www] server reached pm.max_children setting (5), consider raising it”. This log is located under /var/log/php7.2-fpm.log. Note that you may be running a different version PHP.

This issue seems to occur when there are many parallel executions of PHP scripts. Simply restarting Apache did not resolve this issue for me.

To fix it – change the pm.max_children setting in the www.conf configuration under /etc/php/7.2/fpm/pool.d :

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5

My default was set to 5, but this number can be increased.  Don’t set this number too high either, since this can cause other issues. Read this for more info.

Remember to restart PHP-FPM after the change using:

sudo service php7.2-fpm restart 

You should not see the following message in the PHP-FPM log: “ready to handle connections” If your site is still not starting, then check your other Apache logs.

Hi, my name is Anto! I am a cloud computing hobbyist! Give me anything to do with the cloud, and I am interested. I work for a Cloud computing company by day and as a Cloud computing hobbyist by night! My projects use PHP, NodeJs, Ubuntu, MySQL and of course Amazon Web Services. Hopefully, my blog aids your cloud journey! Feel free to post a comment and share your thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.