Finally got a bit of time (OK, I have forced myself to take some time) to get my VPS WordPress dream config sorted out and wrap it up in a handy bash script so that I can roll it out across my clients websites easily.
After following various tutorials and picking certain peoples brains, I think I finally have arrived at the bees knees as they say (or do they?)!
The configuration
The dream config breaks down as follows:
- 128MB VPS (Virtualbox for testing, KVM or XEN for production
- Debian 6 (Squeeze)
- PHP5 with FPM (via dotdeb)
- Nginx web server
- APC Optcode cache
- Varnish Caching Proxy
- WordPress with W3 Cache plug-in
- and for good measure Cloudflare CDN/Proxy
I will write up an easy to follow, cut-and-past tutorial soon – promise! And publish my script once it’s done and working. Until then, please check out the following comparison between Nginx+Varnish and Nginx without Varnish. The difference is clear!
This is with WP (latest) and W3 Cache active, running on APC with browser caching.
The test were run with Apache Bench (apt-get install apache2-utils).
Nginx (with APC & W3C)
ab -kc 10 -n 1000 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: nginx/1.0.2
Server Hostname: localhost
Server Port: 8080
Document Path: /
Document Length: 0 bytes
Concurrency Level: 10
Time taken for tests: 40.789 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Keep-Alive requests: 0
Total transferred: 263000 bytes
HTML transferred: 0 bytes
Requests per second: 24.52 [#/sec] (mean)
Time per request: 407.894 [ms] (mean)
Time per request: 40.789 [ms] (mean, across all concurrent requests)
Transfer rate: 6.30 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.2 0 37
Processing: 235 407 30.6 404 534
Waiting: 235 407 30.6 404 534
Total: 235 407 30.7 405 534
Percentage of the requests served within a certain time (ms - milliseconds)
50% 405
66% 417
75% 424
80% 428
90% 444
95% 459
98% 484
99% 496
100% 534 (longest request)
Nginx and Varnish (with APC & W3C)
ab -kc 10 -n 1000 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: nginx/1.0.2
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 6054 bytes
Concurrency Level: 10
Time taken for tests: 1.299 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 1000
Total transferred: 6419989 bytes
HTML transferred: 6054000 bytes
Requests per second: 769.98 [#/sec] (mean)
Time per request: 12.987 [ms] (mean)
Time per request: 1.299 [ms] (mean, across all concurrent requests)
Transfer rate: 4827.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 13 113.2 1 1139
Waiting: 0 13 113.2 1 1139
Total: 0 13 113.2 1 1139
Percentage of the requests served within a certain time (ms - milliseconds )
50% 1
66% 1
75% 2
80% 2
90% 2
95% 3
98% 19
99% 1137
100% 1139 (longest request)
Summary
On its own Nginx (with APC and W3C) takes 40s to run a test with 1000 requests. With Varnish in front of it is only takes 1.2s to serve the same number!
On its own Nginx will handle 24.52 requests per second, whereas with Varnish in front it will handle 769.98!
On its own Nginx will transfer 6.30 Kbytes/sec with Varnish it will push 4,827.39 Kbytes/sec!
The majority of requests (90%) were served within 444ms with just nginx but just 2ms with varnish. This is from localhost of course.
Now imagine the whole thing protected and CDN’d by Cloudflare and you got yourself a website that can truly fly.
Cushty! ;D
PS: Thanks to Daniel Miesler’s post for inspiration. There are more people to thank but I’ll save that until the next post.
Coming Soon
Related posts in this (little) series:
- How to: Testing Nginx with APC, Varnish, WordPress and W3 Cache on a 128MB VPS
- How to: Install Nginx with APC, Varnish, WordPress and W3 Cache on a 128MB VPS
- How to: Benchmark Nginx and Varnish for a WordPress Site
- How to: Make Money from Offering VPS Hosting


Pingback: Install Nginx with APC, Varnish, Wordpress and W3 Cache on a 128MB VPS | Axel Segebrecht's Blog
Pingback: Benchmark Nginx and Varnish for a Wordpress Site | Axel Segebrecht's Blog
Pingback: Make Money from Offering VPS Hosting | Axel Segebrecht's Blog