Benchmark Comparison on Serving Simple PHP: LiteSpeed vs Apache vs Nginx

To perform a fair benchmark requiring a lot of preparation, as you need to know the detail of each product and set appropriate configuration. Recently, we got chance to do some internal testing. It’s experimental, however the result is good enough to make some points and may be useful to our users, so we would like to share it in a series of blog posts first. Feel free to provide any feedback, so we can improve in our formal benchmark test later on.

This time we will compare web server performance on serving simple hello.php. Comparing simple php files is standard practice for benchmark, as this can reveal web server performance instead of php engine being the bottleneck. We will compare LiteSpeed, Apache and Nginx with different configurations.

Software version:  LiteSpeed 4.1RC2, LSAPI 5.0b2, PHP 5.3.0, Apache 2.2.14, Nginx 0.7.61.

Test results:

Configuration Non-Keep-Alive Keep-Alive
Server Mode Average of 4 tests Rating Average of 4 tests Rating
LiteSpeed LSAPI 1 CPU 4741.78 305 6488.52 326
Apache mod_php worker 1554.69 100 1992.34 100
event 1736.26 112 2217.04 111
prefork 1844.85 119 2501.67 126
Nginx 1 worker 1213.67 78 1226.19 62
Apache mod_fcgid worker 1012.43 65 990.87 50
event 970.53 62 973.11 49
prefork 939.67 60 942.61 47
Apache mod_fastcgi worker 832.76 54 825.22 41
event 792.64 51 779.92 39
prefork 795.51 51 793.18 40
Apache suPHP worker 89.63 6 90.09 5
Conclusion
LiteSpeed + LSAPI apparently have big advantage over other configurations. LiteSpeed performs more than 2 times faster than Apache mod_php, which is best configuration for Apache setup. There is little performance impact for LiteSpeed to run in suEXEC mode; therefore it can achieve security benefit of suPHP without losing performance while CGI-based suPHP is the biggest loser in this test.There are almost no differences between keep-alive and non-keep-alive for Nginx, mod_fcgid, mod_fastcgi and suphp.

Apache mod_php is second to LiteSpeed: about 52% (non-keep-alive) / 103% (keep-alive) faster than Nginx, about 83% (non-keep-alive) / 152% (keep-alive) faster than mod_fcgid, about 120% (non-keep-alive) / 207% (keep-alive) faster than mod_fastcgi, 18 (non-keep-alive) / 22 (keep-alive) times faster than suPHP.

Apache prefork performs mod_php better than worker and event modes; Apache worker performs mod_fcgid and mod_fastcgi just a little better than event and prefork modes.

Apache mod_fcgid is about 20% faster than mod_fastcgi; either mod_fcgid or mod_fastcgi lose keep-alive ability that mod_php has.


Details

Server Software apache/2.2.14 (mpm prefork, worker, event), default setting + disable access log
nginx/0.7.61 (1 worker) default setting + disable access log
litespeed/4.1RC2 (1cpu license), default setting + disable access log
Server Hardware Dual Athlon MP 2000+/266FSB/256KB L2 Cache
Memory: 1GB PC2100
Motherboard: MSI K7D
Hard Drive: 36GB 1000RPM SCSI drive
Server OS Linux CentOS 5.4
Client Software ApacheBench (ab) 2.3
Client Host Hardware 2 XEON E5410 2.33GHz with 8GB memory
Motherboard: ASUS DSEB-DG with 4Gpbs LAN ports
Hard Drive: 4 SCSI 10Krpm RAID0
Network Switch Dell PowerConnect 2624 24-Port Gigabit Ethernet Switch
Client VM Linux 2.6.24-ovz-1.9-default #1 SMP
openvz VM with 1GB memory, bridged Network connection over 1Gbps NIC

Build apache with different model:

$ ./configure –prefix=/usr/local/apache-event –enable-mods-shared=all –with-mpm=event
$ ./configure –prefix=/usr/local/apache-event –enable-mods-shared=all –with-mpm=worker
$ ./configure –prefix=/usr/local/apache-event –enable-mods-shared=all –with-mpm=prefork

Simple hello.php:

#cat hello.php

echo "hello world!";

?>

PHP Parameters:

PHP_LSAPI_MAX_REQUESTS=1000
PHP_LSAPI_CHILDREN=15
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
zp8497586rq

Tags: , , , , ,

5 Responses to “Benchmark Comparison on Serving Simple PHP: LiteSpeed vs Apache vs Nginx”

  1. Haw Loeung says:

    I’m curious as to how PHP-CGI is setup. Do you have it listening on a TCP or UNIX sockets?

  2. Where exactly did u actually end up getting the suggestions to create ““Benchmark Comparison on Serving Simple PHP: LiteSpeed vs Apache vs Nginx

  3. webmaster says:

    I’m curious as to how PHP-CGI is setup.

  4. [...] Litespeed- This is known to be the best webserver (http://blog.litespeedtech.com/2010/01/06/benchmark-comparison-on-serving-simple-php-litespeed-vs-apa…). It is a paid webserver which is why most hosting companies stick with open [...]

  5. [...] googling, I found some interesting data Benchmark Comparison on Serving Simple PHP: LiteSpeed vs Apache vs Nginx so I choose only mod_php, mod_fastcgi, mod_fcgid and suPHP to compare and analysis in this [...]