6 ms·
Well, server optimization has been my primary hobby for the past month, and I'd like to make some clarifications about a few things the article says. Saying th
by willarson 19y ago
Well, server optimization has been my primary hobby for the past month, and I'd like to make some clarifications about a few things the article says.
Saying that Lighttpd supports "CGI scripts, Ruby on Rails, Pylons, TurboGears, Django, Quixote, webpy, Mongrel, Catalyst, Mason, Joomla, AWStats, and so much more" is kind of misleading. Lighttpd can do a few things: it does fast cgi (fcgi support explains about 75% of the examples in that list), it can serve static files, and it can proxy requests to other servers. Lighttpd doesn't "support Mongrel", because Mongrel is another server. What Lighttpd does is use something akin to mod_proxy to send certain requests somewhere else, that somewhere else might be a Mongrel cluster that is running on port 8080 (hence it "supports" Mongrel).
That proxying service is where the majority of Lighttpd usage has been. A typical efficient setup these days (YouTube does along these lines) is to have lighttpd accept incoming requests and if the request is for a static file then it serves the request (because it is very lightweight (i.e. minimal) it is more efficient than Apache at serving static media), and if it is for dynamic content the request is passed to Apache, which then passes it back to Lighttpd, which passes it back to the requester (this means that "heavy" Apache threads will be dedicated to a request for a shorter period of time since it only has to communicate/wait for Lighttpd instead of the actual requester).
Lighttpd on its own isn't necessarily the best solution (an example from my experience is that mod_python and Apache become more efficient at serving dynamic content than fcgi and Lighttpd as the numbers of requester per second get very high). Usually a combination of a light frontend server and Apache in the backend can provide the best performance (again this is at high numbers, at lower numbers lighttpd is probablly equally or more efficient).
As a final note, I'd really recommend Nginx over Lighttpd if you are looking for a light http server to serve static content, support fcgi, and/or proxy to other servers. The biggest reason? Lighttpd leaks memory and has to be restarted occasionally because every couple of days (under heavy usage) it dies. Not a great feature in a production server.