Howdy, Stranger!

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

Advertise on LowEndTalk.com

PHP5-FPM: slower and slower
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

PHP5-FPM: slower and slower

edited December 2013 in Help

I have a Wheezy VPS with several webs running with Nginx + PHP-FPM + XCache. The FPM is configured with 2 pools:

The first one is used by several WP blogs and it's going very fast under load (perfect with 50.000 visits/day)

The other one is running a Prestashop web. This page has almost no traffic (w/o bots), and the load time is acceptable. The problem: the shop becomes slower and slower as more time passes.

PHP-FPM tasks go 100% CPU with a simple request, MySQL and Nginx look OK (almost innactive)

Pool config:
pm = dynamic;
pm.start_servers = 2;
pm.max_children = 10;
pm.min_spare_servers = 2;
pm.max_spare_servers = 2;
pm.max_requests = 1000;

I set a hourly cron reloading fpm, and a daily restart. The server goes better

Any ideas would be appreciated

Comments

  • Are there any long-running MySQL queries to the Prestashop database?

    DevOp based out of Chicago Somewhat knowledgeable about php.
  • @sergiodelatorre said:
    I have a Wheezy VPS with several webs running with Nginx + PHP-FPM + XCache. The FPM is configured with 2 pools:

    The first one is used by several WP blogs and it's going very fast under load (perfect with 50.000 visits/day)

    The other one is running a Prestashop web. This page has almost no traffic (w/o bots), and the load time is acceptable. The problem: the shop becomes slower and slower as more time passes.

    PHP-FPM tasks go 100% CPU with a simple request, MySQL and Nginx look OK (almost innactive)

    Pool config:
    pm = dynamic;
    pm.start_servers = 2;
    pm.max_children = 10;
    pm.min_spare_servers = 2;
    pm.max_spare_servers = 2;
    pm.max_requests = 1000;

    I set a hourly cron reloading fpm, and a daily restart. The server goes better

    Any ideas would be appreciated

    Have you tried using a cacher like varnish? Alternatively are there any cache plugins for prestashop like there are for wp?

  • MunMun Member without signature

    It is an issue with PHP5-FPM, it happens on pretty much any heavy loaded PHP site. Frankly nginx + php5-fpm =! apache, nor is it better then apache.

    I suggest you change the pm.max_children to something greater then 10, maybe 20. I also suggest you check your logs out in /var/log/php5-fpm.log which should state what is happening.

    If you are running debian, it might also be a good idea to move to dotdeb which has a better built repo of php-fpm and nginx.

    http://dotdeb.org/

    Mun

  • I set a hourly cron reloading fpm, and a daily restart. The server goes better

    Run the cron more frequently. On my busiest sites I have crons reloading FPM every 10-15 minutes. It helps.

    I'd also install memcache if you haven't already, and set Prestashop to use it in the admin

    I suggest you change the pm.max_children to something greater then 10, maybe 20

    I'd go much higher 50 or 100.

  • @DomainBop said:
    On my busiest sites I have crons reloading FPM every 10-15 minutes.

    pm.max_requests does not help with this problem? I guess I don't run heavy enough sites to have run into this.

  • I run a very popular website for a large company that gets over a million of hits per day. It is running off of Apache 2.2 and PHP-FPM, and it handles it like a champ.

    Without knowing much about your setup, try the following:
    pm.max_children=30
    pm.max_spare_servers=20

    Also try running it as a Unix socket. That should help a bit.

  • FPM actually sucks ass at memory / child management (Re-attested by #hashphp at freenode), and this is supposed to be its core function.

    For hugely popular sites, I'd look at LSAPI, or plain old fcgi through php_cgi -- but you'll need to write something for worker process control for this to work.

    -- BOFH

  • If you are running debian, it might also be a good idea to move to dotdeb
    which has a better built repo of php-fpm and nginx.

    What's better in the dotdeb php-fpm?

    Repositories: Debian: EU US - Ubuntu: Hiawatha & Others PPA ~ Opensource projects: GitHub

    Support my repositories or my projects: Bitcoin 1SteRu8WRPUqUmE1YXZPZ2cQki8CSGK1r

  • MunMun Member without signature

    @Steve81 said:
    What's better in the dotdeb php-fpm?

    The default debian repo has an older php5-fpm version, the newer versions are a little faster, and have fixes for some of the issues that cause php5-fpm to be crap.

    Mun

    Thanked by 1Steve81
  • MunMun Member without signature

    @amhoab said:
    I run a very popular website for a large company that gets over a million of hits per day. It is running off of Apache 2.2 and PHP-FPM, and it handles it like a champ.

    Without knowing much about your setup, try the following:
    pm.max_children=30
    pm.max_spare_servers=20

    Also try running it as a Unix socket. That should help a bit.

    Unix sockets can be a blessing or a curse. I'd suggest you actually not do it if you are having issues. Stay with the 127.0.0.1:9000 address.

    Mun

  • First off all, thank you for the help

    As said WP socket is under load, but the Prestashop socket is mainly unused. My biggest question is: Could the config setup has a performance incidence with a website with barely no traffic (mainly bots)? I have problems with no traffic so i can't imagine with heavy load. Why the server becomes slower?

    @Adduc: No, the database is working very fast

    @sc754: Prestashop has its own cache system config (Files/XCache/Memcache). I've never tried Varnish, but people report worse performance with Prestashop.

    @Mun: I'm using dotdeb sources.

    @DomainBop: Do you have a lot of error 500 with resets?

    @amhoab @Mun: I'm using a unix socket, the other one is also unix:

    I will try the proposed changes :)

  • edited December 2013

    After some time-to-1stBit and ab tests I can conclude: Prestashop goes about 60% faster with no cache (Smarty & XCache) I dont understand why.

    I will disable crontabs and I will test if the slowering problem has relation to this.

  • I am also using nginx and php-fpm but it all working fine here , its always fast . And I personally dont think this is because of fpm so It could be the php cacher . I suggest u to try the zend opcache instead of xcache ...

    [REF] Get $10 for Free - DigitalOcean - Click Here - 2 Months Credit

  • MunMun Member without signature

    @duyan13 said:
    I am also using nginx and php-fpm but it all working fine here , its always fast . And I personally dont think this is because of fpm so It could be the php cacher . I suggest u to try the zend opcache instead of xcache ...

    It isn't, it is fully php5-fpm.

    Mun

  • Without resets php-fpm still becomes slower :-/

  • I think its a dirty method to restart the fpm every 10-15 min . We / You could probably report this to the php team .

    [REF] Get $10 for Free - DigitalOcean - Click Here - 2 Months Credit

  • The spiderbots are load. It's not PHP-FPM but you have back pressure on it from all the processing it has to do. Try disabling dynamic categories and other fun stuff in prestashop to see if that let's it clear the pipe. You might also looking into controlling the crawl delay - either through robots.txt or their respective control panels.

    Resetting fpm only drops all queued jobs, that's why it looks faster.

Sign In or Register to comment.