1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Resolved PHP-fpm max children

Discussion in 'Plesk 12.x for Linux' started by Janko1000, Feb 9, 2016.

  1. Janko1000

    Janko1000 Regular Pleskian

    22
    40%
    Joined:
    Oct 4, 2012
    Messages:
    204
    Likes Received:
    12
    Location:
    Germany
    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?!

     
  2. IgorG

    IgorG Forums Analyst Staff Member

    49
    24%
    Joined:
    Oct 27, 2009
    Messages:
    24,385
    Likes Received:
    1,213
    Location:
    Novosibirsk, Russia
    Affiliate:
    https://plesk.com/?a_aid=59ae552b0731c
    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.
     
  3. brainforge

    brainforge Basic Pleskian

    20
    40%
    Joined:
    Feb 7, 2011
    Messages:
    55
    Likes Received:
    5
    Location:
    England
    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!
     
  4. Michael Huber

    Michael Huber New Pleskian

    9
    20%
    Joined:
    Sep 13, 2014
    Messages:
    22
    Likes Received:
    0
    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
     
  5. Enverex

    Enverex New Pleskian

    22
    23%
    Joined:
    Jun 3, 2010
    Messages:
    23
    Likes Received:
    2
    Location:
    UK
    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.
     
  6. UFHH01

    UFHH01 Plesk addicted!

    44
    64%
    Joined:
    Jun 11, 2013
    Messages:
    6,762
    Likes Received:
    1,709
    Location:
    Hamburg / Germany
    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

    ...​
     
  7. Enverex

    Enverex New Pleskian

    22
    23%
    Joined:
    Jun 3, 2010
    Messages:
    23
    Likes Received:
    2
    Location:
    UK
    /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.
     
  8. UFHH01

    UFHH01 Plesk addicted!

    44
    64%
    Joined:
    Jun 11, 2013
    Messages:
    6,762
    Likes Received:
    1,709
    Location:
    Hamburg / Germany
    Hi Enverex,

    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.

    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.

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


    Actually, this standart setting is inherited from all PHP-version vendors and Plesk meets this standart with the configuration. ;)
     
  9. Enverex

    Enverex New Pleskian

    22
    23%
    Joined:
    Jun 3, 2010
    Messages:
    23
    Likes Received:
    2
    Location:
    UK
    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...

    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?
     
  10. UFHH01

    UFHH01 Plesk addicted!

    44
    64%
    Joined:
    Jun 11, 2013
    Messages:
    6,762
    Likes Received:
    1,709
    Location:
    Hamburg / Germany
    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.

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



    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. :)
     
  11. Enverex

    Enverex New Pleskian

    22
    23%
    Joined:
    Jun 3, 2010
    Messages:
    23
    Likes Received:
    2
    Location:
    UK
    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.
     
  12. UFHH01

    UFHH01 Plesk addicted!

    44
    64%
    Joined:
    Jun 11, 2013
    Messages:
    6,762
    Likes Received:
    1,709
    Location:
    Hamburg / Germany
    Hi Enverex,

    No, sorry.
     
  13. solucionesuno

    solucionesuno Regular Pleskian

    15
    85%
    Joined:
    Dec 30, 2013
    Messages:
    108
    Likes Received:
    1
    Location:
    Spain
  14. gennolo

    gennolo Basic Pleskian

    10
    85%
    Joined:
    Nov 21, 2015
    Messages:
    51
    Likes Received:
    3
  15. IgorG

    IgorG Forums Analyst Staff Member

    49
    24%
    Joined:
    Oct 27, 2009
    Messages:
    24,385
    Likes Received:
    1,213
    Location:
    Novosibirsk, Russia
    Affiliate:
    https://plesk.com/?a_aid=59ae552b0731c
    I think it's unproductive to write "+1" here.
    It would be much more effective to vote for this feature on the Plesk uservoice.
     
    Dukemaster and UFHH01 like this.
  16. jefrancomix

    jefrancomix New Pleskian

    3
     
    Joined:
    Jun 28, 2017
    Messages:
    2
    Likes Received:
    0
    Location:
    Mexico City
    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.
     
  17. Peter Debik

    Peter Debik Golden Pleskian Plesk Guru

    37
    80%
    Joined:
    Oct 15, 2015
    Messages:
    1,904
    Likes Received:
    391
    Location:
    Berlin, Germany
    Dukemaster likes this.
  18. mr-wolf

    mr-wolf Regular Pleskian Plesk Guru

    24
    73%
    Joined:
    Oct 26, 2016
    Messages:
    499
    Likes Received:
    97
    Location:
    Netherlands
    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: Jun 29, 2017
  19. Mohd Sharul HafizR

    Mohd Sharul HafizR Basic Pleskian

    14
    35%
    Joined:
    Apr 5, 2014
    Messages:
    33
    Likes Received:
    0
    Hi, i tried this, however after some time, it back to default 5, how can we make this permanent?
     
  20. mr-wolf

    mr-wolf Regular Pleskian Plesk Guru

    24
    73%
    Joined:
    Oct 26, 2016
    Messages:
    499
    Likes Received:
    97
    Location:
    Netherlands
    Best Answer
    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: Oct 9, 2017
Loading...