Welcome to Centmin Mod Community
Register Now

PHP-FPM WARNING: [pool www] server reached max_children setting (50), consider raising it

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by RoldanLT, Jul 10, 2014.

  1. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    I got this on my php-fpm log:
    WARNING: [pool www] server reached max_children setting (50), consider raising it

    And my php-fpm.conf:
    Code:
    pid = /var/run/php-fpm/php-fpm.pid
    error_log = /var/log/php-fpm/www-error.log
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m
    process_control_timeout = 10s
    ;include=/usr/local/nginx/conf/phpfpmd/*.conf
    
    [www]
    user = nginx
    group = nginx
    
    listen = 127.0.0.1:9000
    listen.allowed_clients = 127.0.0.1
    ;listen.backlog = -1
    
    ;listen = /tmp/php5-fpm.sock
    ;listen.owner = nobody
    ;listen.group = nobody
    ;listen.mode = 0666
    
    pm = ondemand
    pm.max_children = 50
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 20
    pm.min_spare_servers = 5
    pm.max_spare_servers = 35
    pm.max_requests = 5000
    
    ; PHP 5.3.9 setting
    ; The number of seconds after which an idle process will be killed.
    ; Note: Used only when pm is set to 'ondemand'
    ; Default Value: 10s
    pm.process_idle_timeout = 10s;
    
    rlimit_files = 65536
    rlimit_core = 0
    
    ; The timeout for serving a single request after which the worker process will
    ; be killed. This option should be used when the 'max_execution_time' ini option
    ; does not stop script execution for some reason. A value of '0' means 'off'.
    ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
    ; Default Value: 0
    ;request_terminate_timeout = 0
    ; Default Value: 0
    ;request_slowlog_timeout = 0
    slowlog = /var/log/php-fpm/www-slow.log
    
    pm.status_path = /phpstatus
    ping.path = /phpping
    ping.response = pong
    
    ; Limits the extensions of the main script FPM will allow to parse. This can
    ; prevent configuration mistakes on the web server side. You should only limit
    ; FPM to .php extensions to prevent malicious users to use other extensions to
    ; exectute php code.
    ; Note: set an empty value to allow all extensions.
    ; Default Value: .php
    security.limit_extensions = .php .php3 .php4 .php5
    
    ; catch_workers_output = yes
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    Again, I need your expert advice about this @eva2000 :(
    Thanks!
     
  2. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    Running this command:
    Got 55M.
     
  3. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    well tuning is up to you :)

    keep raising it until you don't get the error or to the point you can live with the memory usage and php response times (which get slower as you get further with pm.max_children > number of cpu threads/cores available).
     
  4. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    Having mine set to:
    This could be the reason?
     
  5. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    try disabling and see :)
     
  6. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    • Like Like x 1
  7. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    ooh nice tweak there.. yes the 3 lines should go into php include file you listed

    Code:
    fastcgi_pass_request_body off;
    client_body_in_file_only clean;
    fastcgi_param  REQUEST_BODY_FILE  $request_body_file; 
    let me know how that fairs for you :)

     
    • Like Like x 1
  8. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    I pasted it at the very bottom of the file, Thanks!
    Looks fine, but I'm still encountering this problem (WARNING: [pool www] server reached max_children setting) once per 2 hours.
     
  9. dorobo

    dorobo Active Member

    420
    104
    43
    Jun 6, 2014
    Ratings:
    +161
    Local Time:
    10:37 AM
    latest
    latest
    will it be included in latest beta?
     
  10. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    yeah that tweak wouldn't help fully with that error unless it's related to slow or time consuming uploads via php-fpm for your usage case. Tweak and tune = trial and error testing ;)

    let's see how it fairs for @RoldanLT first heh.
     
  11. Matt

    Matt Moderator Staff Member

    680
    314
    63
    May 25, 2014
    Sheffield, UK
    Ratings:
    +433
    Local Time:
    3:37 AM
    1.7.1
    MariaDB 10
    I've had that error a couple of times:

    Code:
    [16-Jun-2014 14:36:16] WARNING: [pool www] server reached max_children setting (50), consider raising it
    [30-Jun-2014 09:58:39] WARNING: [pool www] server reached max_children setting (50), consider raising it
    I've just increased it to 70 and will increase again if needed. It's only happened a few times in the last 5 months, so can't see 50 being a big issue, but 70 should be plenty for me
    Code:
    [root@host php-fpm]# grep " max_children setting" www-error.log  | wc -l
    21
     
  12. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    I'd be wary of raising max children too high - but it's all relative to how many cpu cores and cpu threads you have to work with. I mentioned that in 3rd post above https://community.centminmod.com/th...setting-50-consider-raising-it.791/#post-3607.

    curious @RoldanLT which pages you get hits mostly from ? You can use ngxtop to find out like Brent did at https://community.centminmod.com/threads/ngxtop-real-time-metrics-for-nginx.285/

    Code:
    ngxtop -l /home/nginx/domains/yourdomain.com/log/access.log --no-follow
     
  13. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    But I have access log off on my domain.
     
  14. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    you're concerned with .php files or php files served via friendly urls which should by default still get logged to access log as you can see from Brent's stats :)

    if you have specifically and completely disabled access_logs yourself, you can just re-enable them for 48hrs to see where that php load is coming from
     
    • Like Like x 1
  15. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    so did you end up trying that tweak for the below 3 additional lines ?
    Code:
    fastcgi_pass_request_body off;
    client_body_in_file_only clean;
    fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
     
  16. RoldanLT

    RoldanLT Well-Known Member

    3,829
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    10:37 AM
    1.11
    10.2
    Yes, up until now.
    Why?
     
  17. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    curious to try it on this forum too :D
     
    • Like Like x 1
  18. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    @RoldanLT just to elaborate on statement I made regarding usefulness of Siege for PHP tuning at Php-fpm configuration: encountered and error | Page 6 | XenForo Community


    To simulate hogged PHP processes for forum attachment uploads etc (yeah not scientific), a simple example of hello world php script where one has an sleep 10 second delay to simulate PHP processing delays

    with siege -c50 -d30 -t1M

    ###############################
    dynamic


    Code:
    ;pm = ondemand
    pm = dynamic
    pm.max_children = 8
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 6
    pm.min_spare_servers = 4
    pm.max_spare_servers = 8
    pm.max_requests = 100
    
    no simulated 10s sleep delay

    Code:
    pool:                 www
    process manager:      dynamic
    start time:           08/Aug/2014:20:52:57 -0700
    start since:          75
    accepted conn:        179
    listen queue:         0
    max listen queue:     0
    listen queue len:     65535
    idle processes:       5
    active processes:     1
    total processes:      6
    max active processes: 3
    max children reached: 0
    slow requests:        0
    
    Code:
    Transactions:                    177 hits
    Availability:                 100.00 %
    Elapsed time:                  59.83 secs
    Data transferred:               0.02 MB
    Response time:                  0.00 secs
    Transaction rate:               2.96 trans/sec
    Throughput:                     0.00 MB/sec
    Concurrency:                    0.00
    Successful transactions:         177
    Failed transactions:               0
    Longest transaction:            0.01
    Shortest transaction:           0.00
    
    with simulated 10s sleep delay during siege

    Code:
    pool:                 www
    process manager:      dynamic
    start time:           08/Aug/2014:20:54:44 -0700
    start since:          78
    accepted conn:        69
    listen queue:         19
    max listen queue:     37
    listen queue len:     65535
    idle processes:       0
    active processes:     8
    total processes:      8
    max active processes: 8
    max children reached: 1
    slow requests:        0
    
    with simulated 10s sleep delay after siege

    Code:
    pool:                 www
    process manager:      dynamic
    start time:           08/Aug/2014:20:54:44 -0700
    start since:          121
    accepted conn:        88
    listen queue:         0
    max listen queue:     37
    listen queue len:     65535
    idle processes:       7
    active processes:     1
    total processes:      8
    max active processes: 8
    max children reached: 1
    slow requests:        0
    
    Code:
    Transactions:                     39 hits
    Availability:                  68.42 %
    Elapsed time:                  59.32 secs
    Data transferred:               0.00 MB
    Response time:                 17.95 secs
    Transaction rate:               0.66 trans/sec
    Throughput:                     0.00 MB/sec
    Concurrency:                   11.80
    Successful transactions:          39
    Failed transactions:              18
    Longest transaction:           30.00
    Shortest transaction:           0.00
    
    Pay attention to the above max children reached, listen queue and max listen queue values during siege with simulated 10s sleep.

    Siege has it's place in load and stress testing but it isn't 100% reflective of real world for PHP performance especially for forum type PHP loads which are non-cached PHP based and are not straight forward (php based attachment uploads).
     
    • Like Like x 2
  19. Floren

    Floren Active Member

    148
    76
    28
    Jun 6, 2014
    Ratings:
    +76
    Local Time:
    10:37 PM
    Why would you want to use this configuration? What is the purpose of using those directives? Please explain.
     
  20. eva2000

    eva2000 Administrator Staff Member

    29,016
    6,585
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,775
    Local Time:
    12:37 PM
    Nginx 1.13.x
    MariaDB 5.5
    @RoldanLT linked to Image upload (resize) not working on nginx/php-fpm | XenForo Community

    Code:
    With this nginx will handle the uploads, then pass the completed upload to PHP-FPM. Works great here 
    I want to see via testing if that is really the case :)

    Floren have you tried something like this ?

    okay google-fu at work and officially it's called Accelerated upload support

    Permissions for using "Accelerated upload support"?

     
    Last edited: Aug 10, 2014