Website is working slowly on PHP-FPM: server reached max_children setting or Bad file descriptor (9)

Follow

Comments

8 comments

  • Avatar
    Markus Wernecke

    Great help and tutorial ! Thanks a lot

  • 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

  • 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.

  • Avatar
    Sharul Hafiz

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

  • 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. 

  • 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
  • Avatar
    Marco Marsala

    May you insert 

    pm.max_children = 40

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

  • 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. 

Please sign in to leave a comment.

Have more questions? Submit a request