Linux Servers Useful

Solved! WARNING: [pool ***] server reached max_children, consider raising it

If you encounter such an error in the php logs, then it is time to modify max_children. The php logs are usually located in /var/log/,  and in my case they are in /var/log/php7.4-fpm.log

WARNING: [pool ********] server reached max_children setting (8), consider raising it

Search for the file where the max_children variable is located, in my case the file is www.conf and is located in the folder: /etc/php/7.4/fpm/pool.d/

Change the value pm.max_children = 8 to a larger one, 16 for example

@ sudo nano /etc/php/7.4/fpm/pool.d/www.conf

save the .conf file and restart the web server:

@sudo systemctl restart apache2

or only the php-fpm service as follows:

@ sudo systemctl restart php7.4-fpm.service

Eventually you can check these logs, who knows, you may not even know you have such a problem!

** As I noticed, for HestiaCP (VestaCP) users max_children can be found in both the /etc/php/7.4/fpm/pool.d/www.conf file and the file /usr/local/hestia/php/etc/php-fpm.conf

** Attention, you must also have enough memory for this, otherwise the results are not as expected!

Check the memory used by each php-fpm service-child with the following command:

@ ps -ef | grep '[f]'pm
root      618    1  0 Dec17 ?        00:00:27 php-fpm: master process (/usr/local/hestia/php/etc/php-fpm.conf)
root     1692    1  0 01:11 ?        00:00:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
matrix    3539 1692 14 01:30 ?        00:00:03 php-fpm: pool
matrix    3542 1692 10 01:30 ?        00:00:01 php-fpm: pool
matrix    3547 1692  0 01:30 ?        00:00:00 php-fpm: pool
matrix    3548 1692 15 01:30 ?        00:00:00 php-fpm: pool

Then, to see the memory required for these processes, we need to add the rss parameter which is “Resident Set Size” or the physical memory. Note: Modify php-fpm7.4 to suit your version of PHP:

ps -C php-fpm7.4 -o rss=

These numbers are in Kbytes , so we calculate an average of the displayed values and multiply by max_children, and we find approximately the memory needed only for php, but don’t forget, the server also needs memory for Apache, Nginx, mysql … maybe Varnish, HAproxy, Redish, etc. .. so, check these values carefully!

Leave a Reply

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