1

Topic: lighttpd vs apache

I started to hear about lighttpd recently, mostly from the rubyonrails people who suggest it for production webservers running rails. Some of the talk is here, here and here, but you can google for more.

I had a quick look at the lighttpd site, and they have a quite impressive benchmark page. I noticed, however, that they used apache 1.x on the tests, so I wondered how apache 2 would perform, especially when using the "worker" MPM model (i.e., threads instead of forking processes).

So I decided to do a small benchmark myself. I installed both servers and the "flood" program from the apache foundation. I set up a pretty basic config file for flood, telling it to do GET and HEAD requests on an HTML page with server-side includes for 60 seconds. Both webservers were configured with support for SSI (obviously) and compression enabled.

Here are my results:

Apache 2:

   Average times (sec)
connect write   read    close   hits    URL
0.0004  0.0005  0.0069  0.0069  37639   http://10.7.1.229/
Requests: 37639 Time: 52.24 Req/Sec: 676.28

lighttpd

   Average times (sec)
connect write   read    close   hits    URL
0.0011  0.0022  0.0026  0.0033  59825   http://10.7.1.229/
Requests: 59825 Time: 39.58 Req/Sec: 1512.86

So lighttpd handled almost 1,6 more requests than apache, and more than twice the requests/second rate.

The machine is a Celeron 2.4Ghz with 256MB of RAM.

Does anyone have real-world experience with lighttpd? I'd be interested in doing more complex benchmarks, and testing other configuration options on the webservers (for example, benchmarking dynamic content).

Re: lighttpd vs apache

WOW!!!! Impressive!

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: lighttpd vs apache

I've seen sth like this before with cherokee. What about some real pages like perl or php and not plaim html?

Guru for a day, newbie for a lifetime

4

Re: lighttpd vs apache

Well I don't know what makes HTML pages "unreal", but as I said I'm indeed planning to test dynamic content. Do you have any perl or php script that would be an interesting target for the benchmark? I will probably test my rails application. It is currently running on apache2 (pre-forking MPM) with ruby via fastcgi.

I'm not sure how apache2's worker MPM would work with dynamic content. IIRC it simply doesn't work because mod_perl (or was it mod_php? Both?) is not thread-safe. Since the idea was to test the worker MPM (as I expected it to be faster), I only tested static content.

Edit: BTW, there are benchmarks of apache 1.3 and lighttpd with dynamic content on the lighttpd page.

Last edited by andre (2005-04-21 19:54:04)

Re: lighttpd vs apache

I think there is a mod_perl2 that is is thread safe, but don't quote me on that.

http://www.0x743.com/vee (the program formerly known as vii)

Re: lighttpd vs apache

I recently used lighthttpd: it left zombies runnning. One I'm currently looking at is shttpd <url:http://shttpd.sf.net/>.

7

Re: lighttpd vs apache

Repeated the tests with my rails application. Both apache and lighttpd use fastcgi to run the ruby scripts. Apache is running with the pre-forking MPM.

Apache2

   Average times (sec)
connect write   read    close   hits    URL
0,0282  0,0330  8,5403  8,5404  29      http://10.7.1.229/
Requests: 29 Time: 49,53 Req/Sec: 0,74

lighttpd

   Average times (sec)
connect write   read    close   hits    URL
0,0003  0,0029  4,8832  4,8832  66      http://10.7.1.229/
Requests: 66 Time: 64,46 Req/Sec: 1,02

8

Re: lighttpd vs apache

Well, I test installed lighttpd yesterday for use as a server in my home lan and I must say that I like it very much, it's very fast and does the job...also very easy to set up.

Re: lighttpd vs apache

i installed lighttpd yesterday it seems to be ok but i can't set up the mysql_vhost mod

mysql-vhost.db             = "lighttpd"
mysql-vhost.user           = "lighttpd"
mysql-vhost.pass           = "secret"
mysql-vhost.sock           = "/var/mysql.lighttpd.sock"
mysql-vhost.sql            = "SELECT docroot FROM domains WHERE domain='?'"
                                                                                                                             ^
                                                                                                                             |
                                                                                                                   is this right ?

i tryed to replace the " ? " with $HTTP["host"] but it isn't seems to be right ...

is there anyone that tryed to setup mysql virtual hosts ?

Re: lighttpd vs apache

Port 443, is the default SSL port, you either need to change the line in the config file to that or you need to have you DNS provider point to 433 instead of 443 or, if there is a firewall you control in front of this server, have it route ssl traffice to that port.

"An educator never says what he himself thinks, but only that which he thinks it is good for those whom he is educating to hear."
-Nietzsche

Re: lighttpd vs apache

Repeated the tests with my rails application. Both apache and lighttpd use fastcgi to run the ruby scripts.