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:

ConfigurationNon-Keep-AliveKeep-Alive
ServerModeAverage of 4 testsRatingAverage of 4 testsRating
LiteSpeed LSAPI1 CPU4741.783056488.52326
Apache mod_phpworker1554.691001992.34100
event1736.261122217.04111
prefork1844.851192501.67126
Nginx1 worker1213.67781226.1962
Apache mod_fcgidworker1012.4365990.8750
event970.5362973.1149
prefork939.6760942.6147
Apache mod_fastcgiworker832.7654825.2241
event792.6451779.9239
prefork795.5151793.1840
Apache suPHPworker89.63690.095

 

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 Softwareapache/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 HardwareDual Athlon MP 2000+/266FSB/256KB L2 Cache
Memory: 1GB PC2100
Motherboard: MSI K7D
Hard Drive: 36GB 1000RPM SCSI drive
Server OSLinux CentOS 5.4
Client SoftwareApacheBench (ab) 2.3
Client Host Hardware2 XEON E5410 2.33GHz with 8GB memory
Motherboard: ASUS DSEB-DG with 4Gpbs LAN ports
Hard Drive: 4 SCSI 10Krpm RAID0
Network SwitchDell PowerConnect 2624 24-Port Gigabit Ethernet Switch
Client VMLinux 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<?php

echo “hello world!”;

?>

PHP Parameters:

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


Related Posts


Comments

%d bloggers like this: