0

I'm using a LEMP stack, with separate php5-fpm pools for two wp pages. Both nginx and php5-fpm pool config files are identical except for site and the socket names. I do static pools with 2 workers each.

The observed phenomena are the following:

  • If I have only one site active, it is super quick to load <<1s response.
  • If I have two sites active, the first site response goes to 1s and the second >10s - often hitting 504 timeout.
  • If I don't use different pools for the different sites then both slow down to 2-10s waiting time for response.
  • The slowdown only happens on the php requests, the static file requests are unaffected.
  • Similar phenomenon happened when I tried LAMP stack.

What is going wrong here? Where could be the problem? How could I track this one down? I could not figure out what logging/debug/stats options I have... :(

Edit:

This is development phase, very low traffic website, so the issue cannot be that I'm running out of workers. I have a single request coming in.

Barney Szabolcs
  • 171
  • 1
  • 7
  • sounds like not enough ram maybe. Check ram use while loading many sites. wordpress is a serious resource hog, though if you use wordpress page caching you can improve performance a lot. – Lizardx Aug 29 '16 at 02:26
  • oh yes it is a resource hog... I'm battling with optimising ram. But why would only one site slow down hellishly and the other be unaffected - even the admin page? – Barney Szabolcs Aug 29 '16 at 02:28
  • That's a good question. the only thing I can think of is some SESSION issues, if those are being written as well to a database. There may also be a multiple wordpress instance configuration error, I've never run > 1 wp instance though so I can't say. I'd check the ram use, mysql use, etc, just to see where they are at during two page/two site loads. It's funny to see 1 second be considered fast, lol, times sure have changed, in the not so distant past, that would have been considered a significant problem in itself, but standards have dropped a lot. – Lizardx Aug 29 '16 at 02:37
  • wordpress caching plugins significantly improve performance, but at the cost of not being able to install certain dynamic plugins, like spam handlers, bad behavior, etc, but the performance gain is massive, at least 10x better. – Lizardx Aug 29 '16 at 02:39
  • I have a feeling it is somewhere with connection hang-ups towards the db and not php. -- session issues could be a good idea I'll look into that too. – Barney Szabolcs Aug 29 '16 at 02:43
  • 1
    What do your logs say? Also note that if your users are anonymous you can get 10 - 100 times performance increase using Nginx page caching. Reference here: https://www.photographerstechsupport.com/tutorials/hosting-wordpress-on-aws-tutorial-part-4-wordpress-website-optimization/ – Tim Aug 29 '16 at 02:54
  • Tim, thanks that looks like a valuable article! I'm not sure how to set up the logs. Especially not the socket logs, which would be the most telling I think. – Barney Szabolcs Aug 29 '16 at 11:06
  • Tim, nginx microcaching sounds like a good performance boost, I'll set that up too! However, I think my root problem is in the realm of bugs/hang ups/deadlocking... I'm not sure how to set up logs for this. Especially not the socket logs, which would be the most telling I think. – Barney Szabolcs Aug 29 '16 at 11:14

1 Answers1

1

If you have static pools with two workers each, you basically run out of workers for the PHP scripts all the time.

If two requests arrive at the same time, one has to wait until a request is finished until a further request can be served. If there are tens of requests coming in at the same time (for example, index.php and any scripts serving AJAX content), a single page load would need several concurrent workers to finish loading. If workers are limited to two, one request has to finish loading until the next one can be served.

So, my recommendation is to use dynamic pools with a minimum of ten workers and maximum 20 to start with. Monitor your php5-fpm.log for messages that recommend adding more workers, and increase maximum workers according to that.

If your server cannot handle larger amount of workers, you need to get more resources.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Thanks for having a look at my problem, Tero! I thought so too for the first time. But I only have a single request coming in. This is development phase, low traffic website. – Barney Szabolcs Aug 29 '16 at 13:16
  • Any ajax requests? That has the same effect. – jedifans Aug 29 '16 at 14:04
  • 1
    I would make it static. Worker upscaling and downscaling can give unforeseen slowness. My philosophy is that if the server can momentarily handle a high amount of workers in dynamic mode, it can also handle a high amount of workers in static mode, forever. – Halfgaar Aug 29 '16 at 14:20
  • Good point. I use dynamic, because there are multiple sites running on the server and resource usage is different between them. – Tero Kilkanen Aug 29 '16 at 16:22