9

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
3
  • If you are running fpm, check the .conf files in /etc/php/7.0/fpm/pool.d/ – Orphans Nov 7 '16 at 8:12
  • ps is a Linux system command, not PHP. Search for the pm.max_children setting in your PHP configuration files and increase it. 5 is really low for any website. Something like 50 or more is better. – Tero Kilkanen Nov 7 '16 at 20:19
  • I only have 2GB Ram and running 1 wordpress site - would 50 be too much or is that acceptable ? – JoaMika Nov 7 '16 at 20:37
14

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

1
  • 1
    This worked for me for php7.4 – bhattraideb Dec 15 '20 at 14:32
4

This command is supported by Php-Fpm 7. Use this ps -ylC php-fpm7.0 --sort:rss

3

For php 7.3 use this command:

ps -ylC php-fpm7.3 --sort:rss
1
  • 1
    Or, in my case, ps -ylC php-fpm7.2 --sort:rss – Jason Jul 11 '19 at 15:15
0

I had a bit different case but thought it to be worth mentioning here. In my case the reason behind the server reached pm.max_children setting error was invalid redirection configuration. That put my WordPress process into an infinite redirection loop that took all the PHP processes of the machine. From the client perspective the browser threw 504 Gateway timed out error.

In my Nginx configuration I had a redirection from a naked domain to www:

server_name akselipalen.com;
return 301 http://www.akselipalen.com;

I had to add $request_uri to the url like this:

server_name akselipalen.com;
return 301 http://www.akselipalen.com$request_uri;

The actual reason is a bit unknown but it seems that WordPress often wants to redirect to another URL. In my case, I had also just moved the WordPress instance from blog.akselipalen.com to www.akselipalen.com from the dashboard settings and ensured the correct new siteurl and home values via mysql console. The correct settings did not help the problem until I made the update to the Nginx redirection config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.