Should I consider lighttpd?

On the Rail’s mailing list, our esteemed Koz asks:

I’ve seen lots of mention of lighttpd in the rails community, but I’m a little confused. Can anyone point me to a resource explaining the benefits? I’ve never had many complaints with apache, except that it has hundreds of features I don’t use.

I’m (slowly) building a rails application at present which may warrant a dedicated server, should I consider lighttpd?

There’s been mention because lighttpd.net itself purports to use Rails, and lighttpd happens to be one of the more feature rich “light” web servers. I think the best analogy for lighttpd to Those Who Rail Against the Machine would “Webrick that does FastCGI”: a single lighttpd instance is easy to compile, configure and get running for a single Rails App (it took me less than 10 minutes to have Manuals running under lighttpd).

There’s nothing wrong with Apache, but historically there has always been higher-throughput, “lighter” servers (some of which support FCGI well): tux, thttpd, premium thttpd, boa, nginx and even cherokee . These servers range from poor/basic/focused in their features, can be somewhat inflexible, and didn’t/don’t have Apache’s developmental momentum. There are commercial web servers that support FCGI (the way to currently run rails best) and these include Litespeed and Zeus even though I’ve not seen Ruby-FCGI under either and I haven’t tried it yet (in a way mod_perl and mod_php have pushed perl-fcgi and php-fcgi out to the fringes).

I’ve been happily enjoying PHP under lighttpd for a good year now, and originally found it as a light-weight webserver that did PHP-FastCGI right (meaning just like how I like to do it).

To me, lighttpd feels like a lean Apache and has a set of stable features that are not present in other lean-and-mean-only-rapidly-serve-up-images-kinda webservers:

  • FastCGI is built in: it has it’s own mod_fastcgi which is a plus because it often feels that Apache2 needs its FastCGI updated and the only one around is mod_fcgid . The only comparable servers that support FastCGI are Zeus and Premium thttpd.
  • It’s approach to PHP is pretty much the same as mine under Apache and looks a lot like Zeus’s.
  • I know some Apache guys but if you want something in there, then … who do you contact (that’s right, you write a module)? But at the same time, I bet if you’re interested, you could get something built into lighttpd (and the developer, Jan Kneschke is employed at MySQL—- a good sign).
  • At least for me on comox.textdrive, lighttpd is consuming about 1/5th the memory of Apache but with a slightly greater throughput for dynamically called FastCGI (both PHP and Ruby).
  • And my god, Virtual Hosting in MySQL? Sure, there’s a recent Apache module for this but I haven’t gotten it to compile on FreeBSD (granted I spent 5 minutes on it).
  • It does digest authentication, even with an LDAP backend. Oh man.
  • Ah … traffic shaping, that’s missing in Apache2.
  • It uses kqueue
  • I can increase the number of file descriptors without recompiling. Even recompiling Apache2 (like how one would do Apache1) with a larger FD_SETSIZE doesn’t help with mod_fastcgi (but mod_fcgid is fine …).

All said I am and would use lighttpd for a dedicated application on it’s own IP or server, or at least stress test the application under lighttpd first.

For example, we’re using lighttpd for our upcoming Manuals , and I could see it being a real contender for deploying single applications like Basecamp, 43Things, Ta-Da Lists or Pingomatic on dedicated (and load-balanced) servers.

What I would like to see in lighttpd in the near term (meaning essentially what it would take for me to deploy lighttpd instead of Apache):

  • Something like htaccess support
  • Support for a flexible MySQL backend for authentication
  • Access logging into MySQL ala mod_log_sql2
  • A demonstration of Python CGI and FastCGI support
  • An equivalent to mod_security
  • Basic support for DAV that would enable simple iCal and bookmark publishing
  • An equivalent to suexec

And dare I wish for:

  • A rich virtual hosting configuration available via MySQL
  • Virtualhost-by-virtualhost setuid and setgid (like the dead “perchild MPM” in Apache).
  • SVN support? (but running a dedicated svn.domain.com service under Apache2 would be fine).

All said, I’ve tried just about every web server that has existed, and have been using Apache since v0.6. Lighttpd is likely the first non-Apache server that I’ve kept around for more than a day, and definitely the first one that I’ve considered (and am) using in place of Apache, and where it really begins to shine is with a higher concurrency (I’ve taken manuals up to a c=1000 and load stayed less than 4).

·:· Posted 8 February 2005, 00:39 by Jason Hoffman to Lighttpd  |  

  1. You list ‘it uses select()’ as though it was a feature.

    More importantly, it use kqueue(). Which performs much, much better than select()/poll() under load.

    See:

    http://people.freebsd.org/~jlemon/papers/kqueue.pdf

    Dick Davies    8 February 2005, 15:01    #
  2. Absolutely and thank you for the comment, we run it on FreeBSD and that’s exactly what it uses.

    Jason Hoffman    8 February 2005, 17:09    #
  3. Am I the only one dreaming up a hosting controlpanel that doesn’t suck together with lighttpd?

    Anyway, lighttpd was/is a good surprise for me, the speed, the simpleness of it all and the fact that it can run on my p133 without it swapping out like mad such as apache did is really nice.
    Can’t wait to play around with it some more!

    johan    9 February 2005, 00:30    #
  4. Yes, I think even right now, lighttpd would be a good choice for an “admin” web server that’s part of hosting control panel.

    Jason Hoffman    9 February 2005, 01:54    #
  5. Is lighttpd available on text drive? Will it be?

    rick    9 February 2005, 02:20    #
  6. Isn’t it?

    Will people have the option of running under it? I would like that very much.

    Jason Hoffman    9 February 2005, 06:01    #
  7. I can see that lighttpd can do round-robin load balancing. What would one use for session-based load balancing?

    Rhub    9 February 2005, 22:45    #
  8. For session-based load balancing you would use Zeus’s Load Balancer.

    Jason Hoffman    10 February 2005, 03:56    #
  9. I also can highly recommend it, I’m using it on my productive servers with php fastcgi.

    Also have a look at http://article.gmane.org/gmane.comp.web.lighttpd/1188

    andreas    17 February 2005, 17:52    #