Benchmark Nginx and Varnish for a WordPress Site

This is a post about benchmarking nginx and varnish in my little series of getting the most performance for your buck, running nginx with varnish, apc and memcache for a WordPress website on a small VPS with 128MB RAM.

If you don’t have it installed already, then get apache2-utils to run the benchmark tool:

apt-get install apache2-utils

To test nginx+fpm only, we need to send requests to port 8080:

ab -kc 10 -n 1000 http://localhost:8080/

To test varnish we need port 80:

ab -kc 10 -n 1000 http://localhost:80/

Comparison of the two give us (in my case anyway) the following results. Please note this is all run locally and I have SSD drives.

Description Nginx Varnish
Server Port 8080 80
Time taken 5.753 seconds 0.054 seconds
Total transferred 255000 bytes 6351000 bytes
Requests per second 173.83 18589.09
Transfer rate 43.29 Kbytes/sec 115292.28 Kbytes/sec
50% of requests served in 57ms 0ms
100% of requests served in 121ms (longest request) 3ms

Yes, we are cheating here. Varnish is delivering static content back and it’s all requested locally not from another machine outside the network. Anyway, the whole point of this set-up is to make our dynamic website be as static as possible whilst remaining dynamic (er- you what?).

APC, memcached and the use of W3 Cache all help to reduce the amount of hard work our system has to do to deliver the same bit of content to the visitor. We are not talking about web-apps but a run of the mill WordPress powered site here. Varnish helps to reduce the work load even further and the above table is proof that a reverse proxying cache is the single piece of software that makes or breaks your performance.

Put Cloudflare in front of that and see how little bandwidth your website suddenly requires and how blazingly fast it is all of a sudden! Notice how little resources you can do without. Save your pennies for running a VPS host server instead.

Look out for another post with more benchmark information and more exhaustive tests. For example, I will test Cloudflare vs direct (varnish & nginx) from remote.

Related posts in this (little) series:

What are you doing for a living? How are you using this little tutorial? Let me know and leave me your comments below or drop me a tweet.

If you like this page, please share it