Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


CPU Load 100%
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

CPU Load 100%

mujmuj Member

When I stress the my server for 10s the php-fpm goes to 100% and stays even when I stop. To recover I have to restart php-fpm then it goes normal.

Any ideas on how to fix this high load after stress?

«1

Comments

  • perennateperennate Member, Host Rep

    How long does it say? Even after PHP script timeout?

  • mujmuj Member

    Dunno, I quickly restart. But it would stay long if I leave it.

  • Please check your codes at first I think

  • mujmuj Member

    Which code?

    I run Nginx.

  • mujmuj Member

    Should I reinstall PHP-FPM?

  • udkudk Member

    try again with a really simple php script, just an echo or something

    that way you can tell if it's your code that's the problem

  • mujmuj Member

    @udk said:
    try again with a really simple php script, just an echo or something

    that way you can tell if it's your code that's the problem

    But I have all my files WordPress, this hasn't happened before, just when I reinstalled the server.

  • tchentchen Member
    edited August 2013

    You're exhausting your child processes (pm.max_children) during the stress test and are queuing up the requests. Increase it if you've got memory to spare, otherwise you just have to be patient and let it drain the pipe.

    Thanked by 2Abdussamad muj
  • mujmuj Member

    @tchen said:
    You're exhausting your child processes (pm.max_children) during the stress test and are queuing up the requests. Increase it if you've got memory to spare, otherwise you just have to be patient and let it drain the pipe.

    Ok, but the CPU just stays around 100% and I can't access the website.

  • smansman Member

    switch to apache :p

  • What Linux distribution do you use?

  • mujmuj Member

    @budingyun said:
    What Linux distribution do you use?

    Debian 6 32bit

  • mujmuj Member

    @sman said:
    switch to apache :p

    Should I?, I'm sure it needs more resources and there are security issues?

  • budingyunbudingyun Member
    edited August 2013

    @muj said:
    Debian 6 32bit

    Please share your php5-fpm configuration.

    nano /etc/php5/fpm/pool.d/www.conf

    This is my low end configuration btw:

    [www] user = www-data group = www-data listen = 127.0.0.1:9000; pm = dynamic pm.max_children = 1 pm.start_servers = 1 pm.min_spare_servers = 1 pm.max_spare_servers = 1 pm.max_requests = 128

  • mujmuj Member

    @budingyun said:
    pm.max_requests = 128`

    [www]
    user = www-data
    group = www-data
    listen = /var/run/php5-fpm.sock
    pm = ondemand
    pm.max_children = 5
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 1
    pm.process_idle_timeout = 3s;
    pm.max_requests = 500
    chdir = /var/www/
    env[HOSTNAME] = $HOSTNAME
    php_admin_value[upload_max_filesize] = 32M
    
  • Try changing it to dynamic.

    pm = ondemand -> pm = dynamic

    or increase pm.process_idle_timeout value maybe to 10 seconds.

  • mujmuj Member

    @budingyun said:
    Try changing it to dynamic.

    pm = ondemand -> pm = dynamic

    or increase pm.process_idle_timeout value maybe to 10 seconds.

    Added ondemand and dynamic and restarted php-fpm.
    I stress it goes to 100% and stays even though I stop the stress.

  • budingyunbudingyun Member
    edited August 2013

    Something like this?

    [www]
    user = www-data
    group = www-data
    listen = /var/run/php5-fpm.sock
    pm = dynamic
    pm.max_children = 4
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 1
    pm.max_requests = 500
    chdir = /var/www/
    env[HOSTNAME] = $HOSTNAME
    php_admin_value[upload_max_filesize] = 32M
  • mujmuj Member
    edited August 2013

    @budingyun said:
    Something like this?

    Yep I did that.

    [www]
    user = www-data
    group = www-data
    listen = /var/run/php5-fpm.sock
    pm = dynamic
    pm.max_children = 5
    pm.start_servers = 1
    pm.min_spare_servers = 1
    pm.max_spare_servers = 1
    pm.process_idle_timeout = 10s;
    pm.max_requests = 500
    chdir = /var/www/
    env[HOSTNAME] = $HOSTNAME
    php_admin_value[upload_max_filesize] = 32M
    
  • tchentchen Member
    edited August 2013

    What do you use for stress testing? ab? How many requests/sec are you simulating? Be reasonable.

    Anyways, it comes down to the fact that your wordpress pages are slow enough that they're causing back pressure on php-fpm. With only 5 child processes, a standard ab test will saturate the pipeline. Even if you stop ab, those requests are in the queue on the server and will have to be worked through hence why you keep seeing 100% cpu even when you 'stop' the test.

    To figure out what a good php-fpm setting, you'll have to revisit how much load you expect first. Once you figure that out, then you can raise max_children so that it can satisfy those requests while not running out of memory.

    Useful link:
    http://myshell.co.uk/index.php/adjusting-child-processes-for-php-fpm-nginx/

  • mujmuj Member

    @tchen said:
    What do you use for stress testing? ab? How many requests/sec are you simulating? Be reasonable.

    Anyways, it comes down to the fact that your wordpress pages are slow enough that they're causing back pressure on php-fpm. With only 5 child processes, a standard ab test will saturate the pipeline. Even if you stop ab, those requests are in the queue on the server and will have to be worked through hence why you keep seeing 100% cpu even when you 'stop' the test.

    To figure out what a good php-fpm setting, you'll have to revisit how much load you expect first. Once you figure that out, then you can raise max_children so that it can satisfy those requests while not running out of memory.

    Useful link:
    http://myshell.co.uk/index.php/adjusting-child-processes-for-php-fpm-nginx/

    LOIC, 20 threads. Even when I do it for 3 seconds it goes 100% :\

  • BrianHarrisonBrianHarrison Member, Patron Provider

    Why not drop PHP-FPM? There are plenty other more actively developed and better maintained solutions and mediation strategies for high-traffic websites than PHP-FPM.

  • @BrianHarrison said:
    Why not drop PHP-FPM? There are plenty other more actively developed and better maintained solutions and mediation strategies for high-traffic websites than PHP-FPM.

    You mean you're suggesting something be used other than what's in PHP core?

  • mujmuj Member

    @BrianHarrison said:
    Why not drop PHP-FPM? There are plenty other more actively developed and better maintained solutions and mediation strategies for high-traffic websites than PHP-FPM.

    Could you name some please?

  • @muj said:
    Could you name some please?

    Try adding the ReallyStatic plugin to your blog. There's no way in fuck you're going to squeeze performance out of wordpress.

    Thanked by 1muj
  • mujmuj Member

    @Rallias said:
    Try adding the ReallyStatic plugin to your blog. There's no way in fuck you're going to squeeze performance out of wordpress.

    Do you think I should reinstall PHP-FPM?

  • @muj said:
    Do you think I should reinstall PHP-FPM?

    Keep PHP-FPM for now. There's NOTHING BETTER for executing PHP.

    And yes, I'm aware that is a very low standard.

  • @muj said:
    Do you think I should reinstall PHP-FPM?

    How about your nginx configuration?

Sign In or Register to comment.