Archive for August, 2008

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: 80

Document Path: /
Document Length: 340611 bytes

Concurrency 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] received

Connection 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 3932

Percentage 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: 80

Document Path: /
Document Length: 170281 bytes

Concurrency 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] received

Connection 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 4844

Percentage 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!

Comments (5)

Why LAMP (Linux Apache MySQL PHP) is the best

With more and more complicated sites coming to the internet, you can create functional and attractive websites. When you receive proposals from your developer, you can choose LAMP which is the best technology available today. Today internet has large number of opportunities for creation and management of a website. Now you can build a website absolutely free and open source with Linux Apache MySQL PHP, popularly known and abbreviated as LAMP, a powerful and common bundle of technology components.

The combined components of LAMP viz., Linux is a very popular operating system; Apache is a web server, MySQL is a database and PHP is a scripting language. Choosing LAMP is the best way for you to gain complete control and power over your web site. You can get started with the free scripts, examples etc., which are available on the web site, by taking help of tools and free editors. A web hosting company can make a good profit margin with less cost involved in it since LAMP is absolutely open sourced. Now you have got a big choice before you to choose from a large number of web hosting providers.

As there are good improvements in the installers for LAMP components, you can install them without difficulty. When you are able to debug, you can use PHP debuggers to write perfect code. LAMP is very strong in its performance, security and reliability and is considered to be the best architecture to serve the web pages. LAMP will function as an excellent platform for your web development needs. You will benefit from the major advantages of LAMP which are open source, ‘geeky’ community supported and also of low cost compared to other technologies. PHP has a simple web integration and Apache is known for its security features. With LAMP you can run a dynamic server as well as website. With this combined LAMP technology you can establish a good software distribution package. You can acquire the components at a very low acquisition cost. LAMP allows you to use the web browser to execute program and receive static and dynamic content.

By using the scripting languages, you have got the benefit of efficient and easy manipulation of various text streams. You can use the bundle software LAMP as a best alternative solution to a commercial package. The popularity of LAMP is on the increase as it is available as free software.

Comments (2)