Learn about Centmin Mod LEMP Stack today
Become a Member

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

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

  1. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    @eva2000, what's wrong with using default fastcgi for the request body?
    I'm probably missing something, I don't see anywhere into Nginx documentation that you need to add those settings in order to enable PHP-FPM accelerated upload. A while ago, I have setup a very large site with 14 web nodes, they upload attachments at various sizes from 1-10MB without any issues. You know which site, I hired you to optimize the MySQL database.

    If those settings are indeed needed, it will definitelly be posted on Nginx/PHP site. That thread on XenForo, is definitely related to the fact that he is not using a proper configuration file. I bet he is using fastcgi_params, instead of fastcgi.conf. No wonder his uploads will never work...

     
    Last edited: Aug 10, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    It's probably the fact you had 14 web nodes (assuming you mean headless PHP-FPM cluster of servers), that you didn't have issues as they would of shared and distributed the load (PHP request service time in this case) across all 14 web nodes and would of contributed a greater number of actual cpu threads available to service those PHP requests :) Which is the goal of having load balanced web nodes :)

    As opposed to folks running a single PHP-FPM pool on a single server constrained by the resources of that single server (limited cpu threads available which would in turn limit the number of PHP-FPM max children you can use comfortably).

    Anyway, as I said just trying those accelerated upload settings for myself to see what they do - again always learning :D

    edit: actually thinking about it, maybe better way to test effectiveness of accelerated uploads would be on a server constrained to lower number cpu threads and lower number of PHP-FPM pm.max_children value ?

    edit: lol we're both re-editing our posts - yeah I was thinking it was that site that I optimised their MySQL server for :)

    edit: Good thing about working on Centmin Mod is the original goal of working with <512MB memory based VPS servers that you learn how to make do with what you are limited to - Centmin Mod has been tested on 128-256MB VPS with single cpu core :)
     
    Last edited: Aug 10, 2014
  3. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    @eva2000, the number of servers has nothing to do with the directives highlighted above. There is nothing to try, IMO accelerated upload is enabled by default. What you do with those directives is:
    Instead of increasing the PHP memory usage, which you already have it set to 256MB (128MB more then you need), you push the file through Nginx and increase there the memory. Please perform a test, I'm sure the upload time will be identical on both cases.

    @Matt was uploading 32MB files to one of his servers, maybe he can let us know if he had those directives in place?
     
    Last edited: Aug 10, 2014
  4. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah that's why I going to test this stuff out and get hands on to find out for myself what it does :)

    oh i mean number of web nodes in related to the pm.max_children warning and service time of PHP requests not the accelerated upload. Likelihood of hitting pm.max_children is much lower when you have PHP requests distributed and shared over 14 web servers :)

    I believe Matt's forums are NOT as busy in terms of concurrent users as RoldanLT's so PHP concurrent request activity probably isn't as high. That's why in this thread, I suggested RoldanLT check his PHP stats etc
     
    Last edited: Aug 10, 2014
  5. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    Well, having the number of children and max requests low is much better for the overall performance, regardless the number of servers.
     
    Last edited: Aug 10, 2014
  6. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    well depends on the server and PHP concurrency load I guess. If you have 4 cpu threads, pm.max_children value of 4 would perform better than a value of 1 if you're pushing a constant 50 concurrent PHP requests though PHP-FPM server
     
  7. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    I forgot to add this: prepare yourself for a HUGE I/O when you do your tests, as you are writing everything to disk. In theory, the options will slow down your file transfer when processed through Nginx, if network is not a bottleneck. There is a reason why Nginx has it set to Off by default. Yes, you could address this issue by having proper client buffers... but you realize the headaches you go through? :)
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    but how much of an I/O load increase ? and whether that I/O cost is more advantageous compared to total time for PHP-FPM delayed process due to processing large file uploads when hitting a pm.max_children limit ?

    edit: okay guess the I/O increase can be measured if you are monitoring disk I/O before and after implementing this
     
    Last edited: Aug 10, 2014
  9. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  10. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    @eva2000, I'm simply trying to use logic. If accelerated file upload is disabled by default, the Internet will scream all over the places to turn it on, starting with PHP and Nginx sites. IMO, whatever you find related to those settings is again people who do not understand what the settings do and they copy it blindly. I'm looking forward to your tests.
     
  11. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    not sure Siege supports multipart POST JoeBlog Siege Frequently Asked Questions ?

    My train of thought is given say 4 cpu thread limited server with 4 pm.max_children and say 50% of users are trying to concurrency upload via PHP a 15MB sized attachment thereby delaying PHP request service time and driving up the listening queue and hitting pm.max_children limit, would accelerated file upload offload some of that delayed PHP request service time to ease the pressure on pm.max_children limit ?

    Would accelerated upload have same effect as caching PHP requests via fastcgi_cache, varnish or frontend cache to ease the load on PHP-FPM workers where the cost of caching PHP is increased memory usage (i.e. cost of accelerated upload is increased disk I/O usage) ?
     
  12. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    @eva2000, IMO the accelerated support has nothing to do with cache. It is basically a method to upload files in PHP (accelerated). There is no advantage doing it through Nginx, although it can be done. You probably know a lot more then myself on Varnish etc., but I doubt there is anything cached during the upload process mainly because is done thought POST which by default neither proxy_cache or fastcgi_cache process it. No idea for Varnish.

    Still waiting on your tests, you did not do them yet? :D
    Just upload a huge file and see the time it takes to complete in milliseconds, for both scenarios. My bet is your time will be identical.
     
  13. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    no the PHP cache is an analogy only in terms of offloading PHP processing time to Nginx for accelerated uploads. To put the theory or question another way, would PHP performance be better if there were less PHP processing delays incurred from large PHP base file uploads blocking and consuming up the listening queue for PHP ?

    no the tests are under the scenario of high concurrency PHP processing/requests on a constrained system with limited number of pm.max_children and limited number of cpu threads to process them. Haven't found an easy way to simulate that (the high concurrency part)
     
  14. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    You are basically worried that PHP-FPM upload will slow the system down as you add overhead through it for uploads. Don't be, there are plenty of pm settings available for any type of site, they scale very well. :)

    This is the perfect example:
    Code:
    # grep ^pm /etc/php-fpm.d/www.conf
    pm = dynamic
    pm.max_children = 8
    pm.start_servers = 6
    pm.min_spare_servers = 4
    pm.max_spare_servers = 8
    pm.max_requests = 100
    With those settings on my tiny I5 server with 8GB of RAM, I was able to scale a 2,000 users Siege bombardment without issues (fastcgi_cache disabled).
     
    Last edited: Aug 10, 2014
  15. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  16. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    add a 10 second delay to your PHP file and watch it hit pm.max_children limits - did a quick test for normal PHP file and PHP file with 10 seconds sleep and that was with only siege concurrency at 50 not 2000 PHP-FPM - WARNING: [pool www] server reached max_children setting (50), consider raising it | Centmin Mod Community
     
  17. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    I understand perfectly what you mean, you ask if running less processes in PMP-FPM and more in Nginx might be a better approach. IMO, no. It should not make a difference performance wise, if your configuration is optimal. Remember that at origin Andrei Nigmatulin designed the PHP-FPM patch for Nginx. Later on, it made it into PHP core code.
     
  18. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    An easier and much more accurate test is to upload a large attachment in XenForo. What you did is crazy, heh. There is no PHP file in this world that will take 10 seconds in execution. But I want to try it. Post your test script, I will test it on my live server.
     
  19. eva2000

    eva2000 Administrator Staff Member

    54,353
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    4:57 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah that's what I have floating around in my head right now.. either way, always good to test out theories whether they're correct or not.. hands on is only way :D

    not test script for php uploads that's the road block for me for the simple file it was just 2 files

    howdy.php
    PHP:
    <html>
    <head>
      <title>PHP test script</title>
    </head>
    <body>
    <?php echo '<p>Howdy Folks</p>';?>
    </body>
    </html>
    howdy_sleep.php
    PHP:
    <html>
    <head>
      <title>PHP test script</title>
    </head>
    <body>
    <?php echo '<p>Howdy Folks</p>'sleep(10); exit;?>
    </body>
    </html>
    yes hello world was too boring :D
     
    Last edited: Aug 10, 2014
  20. Floren

    Floren Active Member

    148
    77
    28
    Jun 6, 2014
    Ratings:
    +77
    Local Time:
    1:57 PM
    @eva2000, post the howdy_sleep.php contents I will upload it on my server and see if I get the max_children warning.

    Edit: I will test this as code:
    Code:
    <?php
    
    var_dump(time());
    sleep(10);
    var_dump(time());
    Is that OK with you? :)
     
    Last edited: Aug 10, 2014