views:

1175

answers:

5
+8  Q: 

Apache or lighttpd

For development, I use a local LAMP stack, for production I'm using MediaTemple's Django Container (which I'm loving BTW). MT's container uses lighthttpd. Honestly I've never had any other experience with it. I've always used Apache. I've been doing some reading:

Here's are questions:

  • What strengths does one have over the other?
  • Would it benefit me to use lighthttpd on my dev setup?
  • What's up with using both? The Linux.com article talks about using lighttpd with Apache.
+3  A: 

The benefit of both: Apache is more powerful and extensible (useless if you don't need that power, but anyway...) and lighttpd is faster at static content. The idea is of splitting your site into static content (css, js, images, etc) and dynamic code that flows through Apache.

I'm not saying you can't do a lot with lighttpd on its own. You can and people do.

If you're using lighttpd exclusively on your production server, I would seriously consider mirroring that on your development and staging servers so you know exactly what to expect before you deploy.

Oli
Good point, I took for granted that there may be differences in the "output".
jobscry
A: 

Use a standard web server. Apache is used by 50% of web sites (Netcraft), therefore, if you use Apache, peoples' web browsers, spiders, proxies etc, are pretty much guaranteed to work with your site (its web server anyway).

Lighthttpd is used by 1.5% of web sites (Netcraft), so it's far less likely that people will test their apps with it.

Any performance difference is likely not to matter in production; an Apache server can probably serve static requests at a much higher bandwidth than you have, on the slowest hardware you're likely to deploy in production.

MarkR
Yes, but that 1.5% of web sites includes YouTube, so I think Lighttpd is fairly reliable.
Justin Voss
This is quite a pointless comparison. All web servers serve pages in the same manner, and their inner workings are transparent to the end-user. No server-browser tweaks are necessary when the server complies with standards (and both of these do).
Hugo
A: 

The answer depends on your projects goals. If it's going to be a large scale site where uptime is critical and load is hight go with lighttpd; it scales amazingly. The only downside is that you have to be more hands on initially. Most hosts won't support this and it really pays to know what you're doing with lighttpd.

If it's a site for your mother that'll get a few thousand visitors a month apache'll work better. She'll be able to move to a new host a lot easier and support is easier to find.

Eric Lamb
+2  A: 

The way you interface between the web server and Django might have even a greater impact on performance than the choice of web server software. For instance, mod_python is known to be heavy on RAM.

This question and its answers discuss other web server options as well.

I wouldn't be concerned on compatibility issues with client software (see MarkR's comment). I've had no such problems when serving Django using lighttpd and FastCGI. I'd like to see a diverse ecosystem of both server and client software. Having a good standard is better than a de facto product from a single vendor.

akaihola
+2  A: 

For purely static web pages (.gif, .css, etc.) with n http requests from distinct ip addresses: 1. Apache: Runs n processes (with mod_perl, mod_php in memory) 2. lighttpd: Runs 1 process and 1 threads (You can assign m threads before launching it)

For purely dynamic web pages (.php, .pl) with n http requests from distinct ip addresses: 1. Apache: Runs n processes (with mod_perl, mod_php in memory) 2. lighttpd: Runs 1 lighttpd process thanks to async I/O, and runs m fast-cgi processes for each script language.

Lighttpd consumes much less memory. YouTube used to be a big user of lighttpd until it was acquired by Google. Go to its homepage for more info.

P.S. At my previous company, we used both with a load balancer to distribute the http traffic according to its url suffixes. Why not fully lighttpd? For legacy reasons.

yogman