• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved PHP-fpm max children

Janko1000

Regular Pleskian
Hi,

we have 3 "high Traffic" Sites on a Plesk Server.
The Server has enough Power to handle it but we have Trouble with FPM.

Code:
[08-Feb-2016 03:15:08] WARNING: [pool domain.de] server reached max_children setting (5), consider raising it
[08-Feb-2016 03:15:59] WARNING: [pool domain.de] server reached max_children setting (5), consider raising it
[08-Feb-2016 03:16:37] WARNING: [pool domain.de] server reached max_children setting (5), consider raising it
[08-Feb-2016 03:17:45] WARNING: [pool domain.de] server reached max_children setting (5), consider raising it
[08-Feb-2016 03:38:38] WARNING: [pool domain.de] server reached max_children setting (5), consider raising it

All Sites are blank at this Time.
It look like the Value "5" is hardcoded?!
 
You can set the value "pm.max_children = 50" on the configuration file of php-fpm. The config file for php-fpm 5.6, for example, is residing in the directory /opt/plesk/php/5.6/etc/php-fpm.d
You can create or update the above-mentioned value in "www.conf" file under this directory to fix the warning.
After that restart webserver and php-fpm service.
 
The /opt/plesk/php/5.6/etc/php-fpm.d directory has a .conf file for each domain.
/opt/plesk/php/5.6/etc/php-fpm.d/domain1.com.conf
/opt/plesk/php/5.6/etc/php-fpm.d/domain2.com.conf
Etc.

Each of these files contains the warning:
; DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
; SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
; If you need to customize this file, ... override settings in /var/www/vhosts/system/domain1.com/conf/php.ini ...

Um, I think this needs a bit more thought and a clearer answer!
 
in my /opt/plesk/php/XX.XX/etc/php-fpm.d/ is no file with www.conf

there are round about 300 files for each domain. how can I change global this setting and update the domains?

thanx
 
So, is there a way to do this globally yet? 5 per domain by default is painfully low and having to manually create one of these files every time someone makes a domain is obviously unreasonable.
 
Hi Michael Huber,
hi Enverex,


there are round about 300 files for each domain. how can I change global this setting and update the domains?
and
So, is there a way to do this globally yet?

You might be interested in the "find" - command, in combination with "xargs" and "sed":

Example commands ( to change "pm.max_children = 5" to "pm.max_children = 50" in *.conf - files at several possible php - paths ):
Code:
find /etc/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /etc/php5/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /opt/plesk/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"


Check the "pm.max_children" - configuration:

Examples:
Code:
find /etc/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /etc/php5/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /opt/plesk/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

Note:

A restart of your corresponding PHP-FPM - service(s) is required so that the changes take effect:

Examples:

service php5-fpm restart
service plesk-php54-fpm restart
service plesk-php71-fpm restart

...​
 
/etc/php* isn't relevant here as those values aren't used on the "per domain PHP version" type setups.

The PHP config file /var/www/vhosts/system/(domain)/conf/php.ini is the one that need to be edited, but these don't exist until someone has created that domain.

In short, we know HOW to raise the value *for a specific domain* but this only allows you to change a single domain and only after it's been created. For people with no access to the filesystem, e.g. a customer, it's not an option.

Cronjobbing a find/xargs/sed is a dirty hack and far from ideal and having every single customer contact us every single time they add a new domain for us to perform this modification for them is obviously unreasonable.

My question is - why isn't this just something that can be set in the Plesk panel itself, or even within a domain's own settings? 5 is a very low value and will almost always need to be modified. Modifying this value seems overly difficult for something that you're almost guaranteed to need to modify.
 
Hi Enverex,

/etc/php* isn't relevant here as those values aren't used on the "per domain PHP version" type setups.
Sorry to correct you here, but if you use several additional PHP - versions on your server(s), including the ones from Plesk, it is very relevant - that's why I included these paths as well in my EXAMPLES.

The PHP config file /var/www/vhosts/system/(domain)/conf/php.ini
Again, I'm sorry to correct you: The depending "php.ini" has got nothing to do with the FPM - pool - settings and no modification at a php.ini will result in a change of your corresponding PHP-FPM - setting.

Cronjobbing a find/xargs/sed is a dirty hack and far from ideal and having every single customer contact us every single time they add a new domain for us to perform this modification for them is obviously unreasonable.
I suggested the examples to avoid possible manual changes on each existent PHP-FPM - *.conf - file and to save you some time. If you don't want to use the suggestion, pls. feel free to ignore my post. :)


5 is a very low value and will almost always need to be modified.
Actually, this standart setting is inherited from all PHP-version vendors and Plesk meets this standart with the configuration. ;)
 
Sorry, ignore my vhost comment, I was referencing the wrong document by accident (I meant the /opt/plesk/php folder, not the vhost PHP override). Anyway...

Sorry to correct you here, but if you use several additional PHP - versions on your server(s), including the ones from Plesk, it is very relevant - that's why I included these paths as well in my EXAMPLES.

Plesk uses /opt/plesk/php/(PHP Version)/etc/php-fpm.d/(Domain).com.conf for the php.ini overrides (nothing in /etc/php gets used unless you use the OS own versions of PHP which isn't relevant in this example).

Anyway, your response side-steps the actual issues here:

1. How can we set the default so that domains aren't limited to 5 by default (so that we don't have to retroactively apply the config for domains after they're created).
2. Why does Plesk not let you set this from within the interface?
 
Hi Enverex,

sorry again, but your answer is again misleading, because you seem to think, that the PHP-FPM - configurations have anything to do with a depending php.ini. This is NOT the case.

Plesk uses /opt/plesk/php/(PHP Version)/etc/php-fpm.d/(Domain).com.conf
... and Plesk will as well create a PHP-FPM - configuration to ( for example ) "/etc/php/5.6/fpm/pool.d/(sub)domain.conf", if you desire to choose a vendor PHP-handler ( or possible additional PHP - versions, installed manually on your server - Examples: Multi-PHP - versions from AtomicCorp, or Multi-PHP - versions from Ondřej Surý ) in your (sub)domain - specific PHP - settings. ;)



1. How can we set the default so that domains aren't limited to 5 by default (so that we don't have to retroactively apply the config for domains after they're created).
2. Why does Plesk not let you set this from within the interface?
To 1: You could consider to modify the corresponding Plesk python "phpinimng", but pls. be aware that you do this on your very own risk and without support from Plesk. In addition, pls. note that all possible changes here might be overwritten in case of updates/upgrades/patches from Plesk at any time.

To 2: I'm repeating myself here, but the setting here is set to "5", because Plesk meets international standarts for PHP - versions. If you desire an additional feature to overwrite such a standart over the Plesk Control Panel, pls. consider to add a feature request at: => https://plesk.uservoice.com , explain your wishes and don't forget to include your buisiness case in your feature request. :)
 
Ok, we may confusing a few things here. Ignore anything about php.ini, all we're discussing here is raising "pm.max_children" globally when using PHP-FPM with Plesk's own multi-PHP version setup, for all domains, be they existing domains or domains that may be added in future. Nothing more. Is there a way of doing that right now?

Fudging the phpinimng file is obviously not going to be an option as it could break any future updates to Plesk.

https://plesk.uservoice.com is basically a write-off as this is something we need now or soon, not in several years time (or potentially never). Nothing we've ever requested (or seen others request) that really mattered has ever been implemented, but that's not relevant right now.
 
Why is this thread marked as solved? Plesk allows editing php.ini, but that's not the point, but max_children in PHP FPM pools.

This is something we can "solve", but against Plesk, actually Plesk ditches the hard work of sysadmins rewriting the pools with their default settings. FWIW, default is not the same as standard or best practice, e.g. WordPress default user is admin, but is advised against keeping like this for security reasons.

And this is the case here, a non sensible default is imposed on us, against the best efforts we need to do in order to not lose our tweaks because Plesk hardcoded lame settings.
 
Example commands ( to change "pm.max_children = 5" to "pm.max_children = 50" in *.conf - files at several possible php - paths ):
Code:
find /etc/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /etc/php5/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /opt/plesk/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"


Check the "pm.max_children" - configuration:

Examples:
Code:
find /etc/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /etc/php5/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /opt/plesk/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

Note:

A restart of your corresponding PHP-FPM - service(s) is required so that the changes take effect:

Examples:

service php5-fpm restart
service plesk-php54-fpm restart
service plesk-php71-fpm restart

...​

I just happened to start reading this article and read UFHH01 's suggestion, which is a good one.
I often use sed and immediately noticed a flaw in its implementation.
Each time you execute it, the amount of pm.max_children will be multiplied by 10 (I tested this to make sure, but knew it beforehand).
The one replying even mentioned a cronjob which would soon give some very unexpected results....

This would be better:
Code:
find /etc/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g"
find /etc/php5/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g"
find /opt/plesk/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g"

Because I think the date of the file is important, I don't like changing the timestamp of a file if nothing is modified. I would therefore prefer to use this:

Code:
MODIFIED=
[ -d /etc/php ] && find /etc/php/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true
[ -d /etc/php5 ] && find /etc/php5/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true
find /opt/plesk/php/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true

if [ ${MODIFIED} ] ; then
  /etc/init.d/plesk-php71-fpm restart
  /etc/init.d/plesk-php70-fpm restart
  /etc/init.d/plesk-php56-fpm restart
fi
 
Last edited:
Hi Michael Huber,
hi Enverex,



and


You might be interested in the "find" - command, in combination with "xargs" and "sed":

Example commands ( to change "pm.max_children = 5" to "pm.max_children = 50" in *.conf - files at several possible php - paths ):
Code:
find /etc/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /etc/php5/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"

find /opt/plesk/php/ -type f -name *.conf | xargs sed -i "s/pm.max_children = 5/pm.max_children = 50/g"


Check the "pm.max_children" - configuration:

Examples:
Code:
find /etc/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /etc/php5/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

find /opt/plesk/php/ -type f -name "*.conf" -exec grep --color -Hni "pm.max_children ="  {} \;

Note:

A restart of your corresponding PHP-FPM - service(s) is required so that the changes take effect:

Examples:

service php5-fpm restart
service plesk-php54-fpm restart
service plesk-php71-fpm restart

...​
Hi, i tried this, however after some time, it back to default 5, how can we make this permanent?
 
Hi, i tried this, however after some time, it back to default 5, how can we make this permanent?
That's because you didn't follow my advice to make this a cronjob

ln -s /usr/local/sbin/mod_php_ini /etc/cron.hourly/
chmod +x /usr/local/sbin/mod_php_ini

cat /usr/local/sbin/mod_php_ini
Code:
#!/bin/bash
MODIFIED=
[ -d /etc/php  ] && find /etc/php/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true
[ -d /etc/php5 ] && find /etc/php5/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true
find /opt/plesk/php/ -type f -name "*.conf" -exec grep -il "pm.max_children = 5$"  {} \; | xargs sed -i "s/pm.max_children = 5$/pm.max_children = 50/g" 2>/dev/null && MODIFIED=true

if [ ${MODIFIED} ] ; then
  /etc/init.d/plesk-php71-fpm restart
  /etc/init.d/plesk-php70-fpm restart
  /etc/init.d/plesk-php56-fpm restart
fi
 
Last edited:
Back
Top