Websites hosted in Plesk and served by PHP-FPM are unavailable or load slowly: "server reached max_children setting" or "Bad file descriptor (9)"

Applicable to:

Plesk for Linux

Symptoms

Websites that have PHP handler set as FPM application served by Apache or FPM application served by nginx at Domains > example.com > PHP Settings load slowly or are not accessible (permanently or periodically) with a 50x error in a web-browser:

- A subscription is not synced with this service plan (Marked with a blue lock in the Subscriptions menu). - If the permission Hosting performance settings management is granted in service plan settings at Service Plans > plan_name > Permissions tab.

Click on the picture to enlarge

Plesk 12.5 and previous releases

Increasing pm.max_children for one domain

Create the php.ini file in domain's system directory /var/www/vhosts/system/example.com/conf/:

# touch /var/www/vhosts/system/example.com/conf/php.ini

Open the php.ini file in any text editor (for example, vi editor) and add the following records:

@Sharul Hafiz You can check the article mentioned in Additional Information section - https://support.plesk.com/hc/en-us/articles/115001201949Keep 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.

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

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.

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.