user1419367
user1419367

Reputation: 21

LEMP Nginx + php-fpm high load timeouts then fine

I'm pretty new to all of this but I'm OCD about optimization.

I'm trying to optimize my web server running a LEMP setup for wordpress.

I'm using WP hypercache instead of w3 total cache as it seems to perform phenomenaly in comparison with my setup

I'm using blitz.io to test and throw 450 users at the domain for 60 seconds starting with the full 450.

This is my results: Spike at 5 sec is errors and timeouts https://i.sstatic.net/7qDE3.png

htop during the spike: https://i.sstatic.net/EAnjR.png

It's a vps w/ 2 cpu at 2.5Ghz and 2.5GB memory, as you can see memory usage is low.

nginx: worker_processes 1; worker_connections 1024;

php-fpm: dynamic, pm.max_children = 10, pm.start_servers = 2, pm.max_spare_servers = 2, ;pm.max_requests = 500 default value = 0

I've increased the nginx worker_processes to 2 with no change, and I've messed with my php-fpm settings with no change. Any ideas what I should be looking at?

Upvotes: 0

Views: 1380

Answers (1)

kei1aeh5quahQu4U
kei1aeh5quahQu4U

Reputation: 153

This does not look too bad. ~40 timeouts out of 19k requests is normal. I got similar results.

As for tuning:

  • look into http://wiki.nginx.org/HttpFastcgiModule#fastcgi_cache - using this avoids touching php at all and nginx does all the caching. You can also look at batcache (http://evansolomon.me/notes/faster-wordpress-multisite-nginx-batcache/)

  • look into apc/memcached for object caching. this makes the non-cached requests faster and also the backend is more responsive. apc also reduces the memory footprint of php. For day to day use this makes more of a difference. This also helps if a lot of your requests are not cacheable (e.g. lot's of new comments).

  • consider using php5.4 it's a lot of faster and requires less memory

  • enable the mysql query cache. http://mysqltuner.com is a nice little script to configure your server.

Measuring peak transfers is not a good indicator for scalability most of the time. real users behave probably different.

edit: try blitz.io on a static nginx page. If there are still timeouts the problem is probably at blitz.io or somehwere else. Also activate gzip compression for your pages.

Upvotes: 1

Related Questions