logos

With Andrii Grytsenko


Technical Diary - With Andrii Grytsenko

Apache vs Nginx vs Lighttpd and static content

Here I would like to show you http servers benchmark.

I take 3 more popular unix http server and make some little statistic for them. First I will create 4 files(test,test2,test3,test4) with appropriate size 2GB,700MB,100Mb and 2MB.

dd if=/dev/zero of=test count=1024 bs=2000000
dd if=/dev/zero of=test2 count=1024 bs=700000
dd if=/dev/zero of=test3 count=1024 bs=100000
dd if=/dev/zero of=test4 count=1024 bs=2000

here they are:

andrii@agrytsenko:~/tmp/test/web$ ls -lh
total 2.7G
-rw-r--r-- 1 andrii vboxusers 2.0G May 13 11:15 test
-rw-r--r-- 1 andrii vboxusers 684M May 13 12:14 test2
-rw-r--r-- 1 andrii vboxusers  98M May 13 12:15 test3
-rw-r--r-- 1 andrii vboxusers 2.0M May 13 12:15 test4

Next step downloading and compilation of servers. If will show only configuration flags and skip all the rest of it.
APACHE

./configure --prefix=~/tmp/test/http --disable-include --disable-filter \
--disable-charset-lite --disable-log-config --disable-env --disable-version \
--disable-mime --disable-status --disable-autoindex --disable-asis --disable-cgid \
--disable-cgi --disable-negotiation --disable-dir --disable-actions --disable-userdir \
--disable-alias --without-pcre --without-ssl

NGINX

./configure --prefix=~/tmp/test/http2 --without-http_ssi_module \
--without-http_access_module --without-http_userid_module --without-http_geo_module \
--without-http_map_module --without-http_rewrite_module \
--without-http_proxy_module --without-http_fastcgi_module \
--without-http_limit_zone_module --without-http_browser_module \
--without-pcre --without-http-cache

LIGHTTPD

./configure --prefix=/home/sheva/tmp/test/http3 --disable-silent-rules\
  --disable-dependency-tracking  --disable-libtool-lock --disable-ipv6 \
--without-pcre --without-bzip2 --without-mysql --without-ldap  \
--without-openssl --without-zlib --without-kerberos5

All of them uses port 1234 to listen. It will prevent all servers work simultaneously and it by turn prevent from distorted results.

I used default configuration so result can be far away from reality. I’ve made 2 tests make result more realistic and fetch files with wget through local TCP/IP stack.

This is result of first one:

Apache
2.2.15
Nginx
0.8.8
Lighttpd
1.4.26
2GB 9.53 MB/s 9.10 MB/s 9.69 MB/s
700MB 22.7 MB/s 37.0 MB/s 33.1 MB/s
100MB 153 MB/s 161 MB/s 133 MB/s
2MB 61.0 MB/s 81.0 MB/s 81.4 MB/s

Second attempt with next results:

Apache
2.2.15
Nginx
0.8.8
Lighttpd
1.4.26
2GB 9.51 MB/s 8.81 MB/s 10.3 MB/s
700MB 35.5 MB/s 35.7 MB/s 34.0 MB/s
100MB 157.0 MB/s 163.0 MB/s 170.0 MB/s
2MB 55.9 MB/s 164.0 MB/s 54.6 MB/s

This is final average results table:

Apache
2.2.15
Nginx
0.8.8
Lighttpd
1.4.26
2GB 9.52 MB/s 8,955 MB/s 9,99 MB/s
700MB 29,1 MB/s 36,35 MB/s 33,55 MB/s
100MB 155.0 MB/s 162.0 MB/s 151,5 MB/s
2MB 58,45 MB/s 122,5 MB/s 68.0 MB/s