| Lighttpd, The Fast Apache... |
| Written by ircmaxell | |||
| Friday, 20 April 2007 | |||
|
I've been testing a new webserver on this and a few other sites for the past few months. I got tired of Apache's HUGE memory usage and lack of ability to support a load. While looking for ways to speed Apache up, I came across an interesting solution. Lighttpd (Pronounced Lite - e) was that solution. Not only is it a full featured web server like Apache, it also has an almost zero memory footprint. My server has 2 gigs of RAM, and this new server can support more than 100 times the request before even coming close to the memory limit. I'm going to talk about how I set it up on my server, and how it's helped me exceed what I ever thought possible.
My ServerI'm presently running a Virtual Private Server from Spry, which has been a dream. When I chose this VPS, I needed a basic server with root level access for a project of mine. Now, I've got three live websites running, and between them that have really started to put a strain on the little server. I see about 5,000 visitors a day on average across the three sites, which on its own is not much. However one site, bagsofcrap.com, sparatically uses all of my server resources (to the point of failure even). Durring one of those events, I have seen over 10 million hits per day! With Apache as my front end server, I was crashing with just around 1 million hits per day. That is what prompted me to look for an alternative.
A Server that Serves Just 1% Dynamic Content is SlowerI've always read that and thought to myself that it's an inherant flaw to the way servers operate. But then the idea came. Lighttpd is EXTREMELY good at handling static content (such as images, xml and html files). It also has a VERY good proxy mechanism (in fact, it's capable of load balancing multiple servers this way). So then I got the idea that still powers my site today. I use Lighttpd as a front end to Apache. Lighttpd runs on port 80, and intercepts all incoming request. It then proxies any html (for SEF URLS), or php file back to Apache to process. Apache is happy, because it is processing all dynamic requests, and Lighttpd is happy, because it doesn't need to worry about how to process a dynamic request... It just passes it along. Now, what kind of speed gains did I get from this? The GainsWhen I first started the both servers, I really didn't see much of a speed gain between them (as far as static content). Lighttpd seemed to be about 1% faster with static content, but that's not a significant gain. I maxed out my DSL line with bandwidth before either flinched, so I could not test the difference. I just knew that Apache alone could manage about 1 million hits per day before taking the server down. Then, in March my true test came. It was another of those high request events. This time, they worked flawlessly for the first 9 hours (spitting out almost 2.5 million hits durring that time). But then, I noticed 503 error messages sparatically. A quick look into the log files revealed the problem. My VPS has the number of TCP sockets limited in an attempt to control bandwidth. Due to the proxy, every dynamic request consumed three sockets (user->lighttpd->Apache->MySQL). I called the host, and they said that was the config. The next day, I called back, and they doubled my sockets. Then came the amazing difference. With Apache alone, I saw a maximum of about 25 requests per second before the server started straining. Now with the combo, I was seeing over 280 request per second. Now THATs a difference! The MoralApache is very good at what it does. It is a full fledged, full featured web server. Just what you need to serve dynamic content. But why do you need all those modules, features, and memory to serve basic images? You don't. Period. Let a smaller and more efficient server handle the simple request, and pass off all the complex ones to Apache. Lighttpd has made my VPS outlast me. I had planned on buying a dedicated server by now. But with the same traffic, I'm now seeing about 10% of the load (My page caching component helps there too). I am planning on detailing my experience with getting Cpanel to work with Apache and Lighttpd (it's not been fun). The combination is absolutely worth it, and I recommend anyone running ANY server to consider the change. Trackback(0)
Comments (5)
![]() written by pguy, June 24, 2007 How?
written by linuxpenguin, April 22, 2007
Anyone know of any good guides out there to set up lighttpd? I'm still a little bit new when it comes to the whole webserver thing.
I'm using Ubuntu Server - I know how to install the program, but I'm not sure how I should set the config files. written by Anthony, April 20, 2007
I have it running where Lighttpd serves all non-php files. So basically images, css, and xml files (and audio and video, zip, etc). If an .html (for SEF urls) or .php files are requested, it fowards the request back to Apache. I am planning a tutorial in a week or two describing how I set it up.
written by macchese, April 20, 2007
Hi,
very interesting article, just a question: How can I divide static and dynamic content from a CMS (i.e. Joomla) in order to have a lighttpd as a reverse proxy and an apache as a target web? Write comment
|
|||
| Last Updated ( Friday, 20 April 2007 ) | |||
| < Prev | Next > |
|---|











cheers