Nginx – Php-Fpm 7 server reached pm.max_children

nginxphp-fpm

I am receiving this error message when I run an intensive job in WordPress:

[pool www] server reached pm.max_children setting (5), consider raising it

Using Php-fpm 7 + Nginx on 2GB RAM Server.

When I run:

ps aux | grep fpm

root      1508  0.0  1.5 367260 31380 ?        Ss   Nov05   0:11 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
www-data 10231  0.0  2.7 453420 55540 ?        S    15:10   0:03 php-fpm: pool www
www-data 13266  0.0  2.4 449892 50900 ?        S    22:13   0:00 php-fpm: pool www
www-data 13572  0.0  1.8 372468 37740 ?        S    23:14   0:00 php-fpm: pool www
user+ 13721  0.0  0.0  14512   980 pts/0    R+   23:30   0:00 grep --color=auto fpm

Tried to follow this tutorial to determine correct settings that I need. http://bit.ly/2edUbir

I can't run this command because it's not supported by Php-fpm 7 apparently.

ps -ylC php-fpm --sort:rss

Best Answer

To adjust the settings, you’ll need to find your php-fpm.conf or www.conf depending on what version of PHP-FPM you have installed. In my case, I had to edit /etc/php/7.0/fpm/pool.d/www.conf. You’ll want to look for the following settings and make adjustments based on your server specs:

[php-fpm-pool-settings]
pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500

To get an idea of what to use for the pm.max_children, you can use this calculation: pm.max_children = Total RAM dedicated to the web server / Max child process size. Remember to leave some RAM for extra services you have running on your system.

Depending on the name of your service, you can try on of the following:

sudo systemctl restart php-fpm

sudo systemctl restart php7.0-fpm

the following command will help us to determine the memory used by each (PHP-FPM) child process:

ps -ylC php-fpm --sort:rss

You can check an average memory usage by single PHP-FPM process with this handy command:

ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

For More detail Read Bellow Links Read More 1 Read More 2