Update : A naive implementation of using Lua 5.1 to generate a dynamic response has been added. This loads Lua, loads a Lua script and executes it. Retrieves the string response and returns it to the browser. Take a look below for a new additional download link.
Cheers
There are many well written , fast web servers around with full features for CGI , FastCGI , proxying and dynamic language support such as Ruby, PHP and Python. So what is Lighttz ? It’s a small HTTP server written in C , benchmarked against the big guns. It is by no means a replacement for the big four, and is mainly a testing showcase. For the sake of brevity, the comparison of the first benchmarks will compare the following web servers:
- Apache/2.2.8-mpm-prefork
- lighttpd/1.4.19
- nginx/0.5.33
- userver-0.6.0 – compiled and run with epoll support
- lighttz/0.1 – libev epoll event model
Short summary and the configuration as tested is below. Please note that other event models such as select and poll are available under each server , but these were picked for the performance or wide use ( in case of Apache ) .
Apache – http://httpd.apache.org/
The usual pre-forking server most, widely used to power many websites.
Lighttpd – http://www.lighttpd.net/
Also a very popular server. Instead of a forking model, it utilizes a fast a very well performing epoll mechanism.
Nginx – http://sysoev.ru/en/
A little younger but equally fast server , which also utilizes epoll event model.
Userver – http://userver.uwaterloo.ca/index.php
A small, microwebserver that’s mostly used for tests and benchmarks. Project is maintained at University of Waterloo.
Lighttz –
A short C program that simulates an HTTP server and handles the requests using Libev and epoll.
Test platform
Ubuntu 8.04 , Kernel 2.6.24-16 SMP , 2GB RAM, Core2Duo 2.4GHz
Benchmarking Client Program
ApacheBench . Command used:
ab -c1000 -n1000000 <host:port> . The test document index.html is a 357 byte static file. Lighttz did not use the static file, it sent out the exact same contents as index.html contained in a char array.
The above simulated 1000 concurrent clients making 1000000 requests .
Results
Each result is an average of three runs with one pre-warming run to let each server utilize the cache.
Requests per second. Listed in order of fastest to slowest.
- Lighttz – 14,719 ( Cpu usage: 40-50% , Memory: 188 KB , 1 process )
- Lighttpd – 14,701 ( Cpu usage: 65-85%, Memory: 6.6 MB , 1 process )
- Nginx – 14,378 (Cpu usage: 65-80%, Memory: 2.1 MB , 2 processes )
- Userver – 13,221 ( Cpu usage: 75-90%, Memory: 1.2 MB, 1 process )
- Apache – 9,512 ( Cpu Usage: 60-80%, Memory: 3.5 MB x 147 processes , 514 MB total )
Hardware used, other running servers and operating systems will reflect different results. The tests were not run to define maximum performance for all solutions. Each application will apply a different level of stress on the server.
Source code for Lighttz : http://zenebo.com/lighttz.c.tar.gz
Lua version: http://zenebo.com/lighttz_lua.tar.gz
Libev : http://software.schmorp.de/pkg/libev.html
Index.html file was taken from SuperJared.com article located here: http://superjared.com/entry/benching-lighttpd-vs-nginx-static-files/