Wordpress benchmarks running on Nginx, Php, Apache and Fastcgi
This weekend we had a chance to test out high-bandwidth Wordpress blog set-up configurations and performance. We had a customer that landed multiple Digg front page stories and we had to tune the server to deal with the high peak time traffic.
For best performance we usually deploy Nginx and tie it together with Apache as a back-end for PHP processing, memcached, super cache and do a lot of rewriting rules and other optimizations.
The server is powered by one CPU Quad Core 5430 series processor, with 2GB RAM and SATA drives, runs on a SuperMicro server board. It’s a powerful box that can handle traffic well if correctly tuned and optimized.
We were running the latest Wordpress blog software with some custom rewrites done on the front end Nginx daemon (front end proxy). All static content was served by Nginx and all PHP queries were forwarded to Apache 2 version compiled from source as well as latest PHP 5.2.6 loaded as a module.
Nginx front end, Apache + PHP, Super Cache, some custom rewrite rules:
Requests done: 1000, concurrency 30 threads
Server Software: nginx/0.7.11
Server Hostname: www.*****.COM
Server Port: 80Document Path: /
Document Length: 340611 bytesConcurrency Level: 30
Time taken for tests: 16.652752 seconds
Complete requests: 1000
Failed requests: 883
(Connect: 0, Length: 883, Exceptions: 0)
Write errors: 0
Non-2xx responses: 883
Total transferred: 190501217 bytes
HTML transferred: 190245813 bytes
Requests per second: 60.05 [#/sec] (mean)
Time per request: 499.583 [ms] (mean)
Time per request: 16.653 [ms] (mean, across all concurrent requests)
Transfer rate: 11171.49 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 38 189.7 27 3032
Processing: 131 452 464.8 283 3876
Waiting: 3 70 339.9 33 3042
Total: 156 490 500.0 311 3932Percentage of the requests served within a certain time (ms)
50% 311
66% 418
75% 559
80% 632
90% 899
95% 1150
98% 1608
99% 3677
100% 3932 (longest request)
Nginx + FastCGI, running spawn-fcgi from Lightspeed distribution with 30 child threads, all static content served by Nginx and PHP served by PHP 5.2.6 php-cgi version (custom compiled from the source of course).
Server Software: nginx/0.7.11
Server Hostname: www.*****.com
Server Port: 80Document Path: /
Document Length: 170281 bytesConcurrency Level: 30
Time taken for tests: 103.429538 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 900
Total transferred: 170518100 bytes
HTML transferred: 170281000 bytes
Requests per second: 9.67 [#/sec] (mean)
Time per request: 3102.886 [ms] (mean)
Time per request: 103.430 [ms] (mean, across all concurrent requests)
Transfer rate: 1609.99 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 1748 3076 492.0 3035 4844
Waiting: 768 1673 370.9 1659 2948
Total: 1748 3076 492.0 3035 4844Percentage of the requests served within a certain time (ms)
50% 3035
66% 3248
75% 3405
80% 3496
90% 3732
95% 3943
98% 4192
99% 4398
100% 4844 (longest request)
As you can see Nginx + Apache, PHP, Super Cache was the clear winner - no questions asked. I have no idea were did error requests pop up (I just noticed it while pasting the benchmark output in this thread) for the first case.
Conclusion: we will stick with Nginx as a front-end proxy serving all static content while PHP processing forwarded to Apache web server running on the same server (using worker), running Super Cache and doing as much rewrites and file checking using Nginx for best performance. Apache is a big resource hog, however, our tests show it still outperforms running PHP scripts via FastCGI.
I would like to note that running PHP as a FastCGI required slightly lower memory usage, however the CPU load shoot up and I was not sure if we could handle Digg traffic that easily. Enjoy!