Tag Archives: Apache

Tuned Apache vs Nginx

WordPress is great when used as a general CMS/Blog platform it can scale quite easily using some basic caching methods, but when you start using it as an app with a fairly large number of users logged in like in a live classroom backchannel/response system scenario some performance issues start to pop up.

We are going through all the components and trying to see how we can improve performance. One is moving away from Apache and switching to Nginx. I did a very quick test comparing a tuned Apache with PHP and APC enabled vs a Nginx PHP-FPM APC install results are below. Should note I did not do any tuning with Nginx (will be the next test) but as you can see Nginx performs much better under high load.

using: ab -n 600 -c 100

Results:

Apache

Concurrency Level: 100
Time taken for tests: 54.546 seconds
Complete requests: 600
Failed requests: 0
Write errors: 0
Total transferred: 9122400 bytes
HTML transferred: 8999400 bytes
Requests per second: 11.00 [#/sec] (mean)
Time per request: 9090.968 [ms] (mean)
Time per request: 90.910 [ms] (mean, across all concurrent requests)
Transfer rate: 163.32 [Kbytes/sec] received

Nginx

Concurrency Level: 100
Time taken for tests: 35.677 seconds
Complete requests: 600
Failed requests: 0
Write errors: 0
Total transferred: 9125400 bytes
HTML transferred: 8999400 bytes
Requests per second: 16.82 [#/sec] (mean)
Time per request: 5946.115 [ms] (mean)
Time per request: 59.461 [ms] (mean, across all concurrent requests)
Transfer rate: 249.79 [Kbytes/sec] received

Apache Default config vs Tuned

Most people go with the default Apache config and hope for the best. Generally this can be ok if the traffic is light but once you start having more concurrent connections this may not work out for you. I am not going to go into details on tuning (there are a ton of posts on it) but this is a graph of a before and after of apache under load after merely removing excess apache modules and tweaking the KeepAlive settings.

using: ab -n 600 -100

Expire Headers! An easy way to speed up your website.

This is a another little tweak that can make your web pages faster and servers happier. Make sure you are using expires headers. I actually overlooked this one on our WordPress web servers, the tweak is a quick add if you have mod_expires installed you can make things faster in seconds.

From the YSlow documentation:

Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash.

Tested with LEAP and with these 6 lines in your .htaccess (WP was having issues with the code reason why this is screened)

The site went from a

to a honor roll A score in YSlow.