Websites on PHP-FPM are unavailable or loading slowly: "server reached max_children setting" OR "pool seems busy"

Follow

Comments

12 comments

  • Avatar
    Markus Wernecke

    Great help and tutorial ! Thanks a lot

    0
    Comment actions Permalink
  • Avatar
    Sharul Hafiz

    Possible to apply this setting to all domains with single file editing? I have lots of domains to be configured 1 by 1

    0
    Comment actions Permalink
  • Avatar
    Nikolay Zhmuk

    @Sharul Hafiz You can check the article mentioned in Additional Information section - https://support.plesk.com/hc/en-us/articles/115001201949
    Keep in mind that increasing of pm.max_children parameter for all domains can affect the server performance significantly. It is better to filter only affected domains in /var/log/plesk-phpXX-fpm/error.log file
    ===
    grep "server reached max_children setting" /var/log/plesk-phpXX-fpm/error.log
    ===
    and adjust max_children just for them.

    0
    Comment actions Permalink
  • Avatar
    Sharul Hafiz

    @Nikolay What is the limit of pm.max_children? let say if I have 10GB free ram.

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov

    @Sharul

    The setting is purely depends on amount of traffic for the website. Try to double the default value (from 5 to 10) and monitor the site for several days. 

    If the same error appears again, analyze the time period between reaching MaxChildren. In case the time like several minutes, double the value again (from 10 to 20), in case the error appears once a day, just add one more child to the configured value (20 to 21). 

    Typically, 20 is more than enough for medium-loaded websites. 

    0
    Comment actions Permalink
  • Avatar
    Marco Marsala

    This line

    # grep "server reached max_children setting" /var/log/php-fpm/error.log | awk '{print $5}' | sort -n | uniq -c

     is wrong, as it should be

    # grep "server reached max_children setting" /var/log/plesk-phpXX-fpm/error.log | awk '{print $5}' | sort -n | uniq -c
    0
    Comment actions Permalink
  • Avatar
    Marco Marsala

    May you insert 

    pm.max_children = 40

    in Additional PHP directives field of PHP Settings page for domain?

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov (Edited )

    Hello Marco, 

    Both files (/var/log/php-fpm/error.log and /var/log/plesk-phpXX-fpm/error.log) exist on the filesystem. The first is used to store errors from system php-fpm, and the second is used when we are speaking about php-fpm which is provided bu Plesk. 

    Meanwhile, I have edited the article in this way: 

    # grep "server reached max_children setting" /var/log/*php*-fpm/error.log | awk '{print $5}' | sort -n | uniq -c

    As for the second question, Additional PHP directives field is used to insert configuration directives in /var/www/vhosts/system/example.com/conf/php.ini file (configuration file for php itself), however pm.max_children directive should be added to the configuration file of php-fpm pool (/var/www/vhosts/system/example.com/conf/php.ini). 
    So, this is two different files. And now Plesk could manage only php settings, but not php fpm pool settings. 
    If you would like Plesk to manage php fpm pool settings, vote for this feature on Plesk Uservoice portal. 

    0
    Comment actions Permalink
  • Avatar
    Lars Doe

    @Konstantin

    You provided the same path for both php.ini files and said these were two different files. 

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Lars,

    Thank you for noticing. Indeed, additional directives are stored in/var/www/vhosts/system/example.com/conf/php.ini and PHP-FPM settings are stored in /opt/plesk/php/X.X/etc/php-fpm.d/example.com.conf.

    As it is stated in the article, now it is possible to change PHP-FPM settings in Pleks GUI.

    0
    Comment actions Permalink
  • Avatar
    Bob B

    I'd like to create a weekly scheduled task (cron job) to check for "server reached max_children setting" in the plesk-php*-fpm error.log, on CentOS 7.  It looks like that log is rotated weekly. 

    Could someone make a suggestion for a good way to schedule a weekly task, which will e-mail the server administrator, weekly, with a list of domains that have reached "max_children"?  I suppose I could create something in "/etc/cron.weekly", but how do I make sure the script runs before the weekly log rotation?

    0
    Comment actions Permalink
  • Avatar
    Taras Ermoshin

    Hello @Bob B!

    You are right, the log files from the directories /var/log/plesk-phpXX-fpm/ are rotated weekly - in the logrotate configuration files /etc/logrotate.d/plesk-phpXX, options daily, weekly, monthly, or yearly are not specified, and in the main configuration file /etc/logrotate.conf, the option weekly is set.

    For the weekly task you would like to create, you can write a corresponding script and put it into the option prerotate/endscript in the logrotate configuration files /etc/logrotate.d/plesk-phpXX. For more details on logrotate configuration options, see the link https://linux.die.net/man/8/logrotate. Please note that the script should be made on your own.

    1
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request