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.
|Server||Mode||Average of 4 tests||Rating||Average of 4 tests||Rating|
|LiteSpeed LSAPI||1 CPU||4741.78||305||6488.52||326|
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.
|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