<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Query7 &#187; nginx</title>
	<atom:link href="http://query7.com/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://query7.com</link>
	<description>PHP, Javascript, Python and Web Development</description>
	<lastBuildDate>Sat, 25 Jun 2011 21:29:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Light weight alternatives to Apache</title>
		<link>http://query7.com/light-weight-alternatives-to-apache</link>
		<comments>http://query7.com/light-weight-alternatives-to-apache#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:12:44 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[web-server]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=487</guid>
		<description><![CDATA[When it comes to choosing a Linux web server, Apache, as we all know, is almost a de facto standard. There is even a chance that your web host does not even offer (or worse, know of) an alternative web server. So, it's not a big surprise that many developers don't know too much about what other alternatives are available to them.]]></description>
			<content:encoded><![CDATA[<p>When it comes to choosing a Linux web  server, Apache, as we all know, is almost a de facto standard. There is even a chance  that your web host does not even offer (or worse, know of) an alternative web  server. So, it&#8217;s not a big surprise that many developers don&#8217;t know too much  about what other alternatives are available to them.</p>
<p>There is of course no denying that Apache  is indeed an old war horse, and an extremely robust and mature one at that. But,  even as stable as Apache is, it has one main drawback &#8211; it occupies a large  memory footprint due to its request-per-process model, and is therefore mediocre  at handling multiple concurrent requests when you have a limited RAM. This can  be a problem when you are starting out small, with a rented 256 MB VPS for your  application. Even if you are a big player, light weight Apache alternatives can  help increase the throughput of your servers. Youtube, for instance, was using  Lighttpd, a light-weight web server to serve millions of videos everyday (prior  to their acquisition by Google).</p>
<p>Ok enough digressing, let’s now take a look  at some of the open source alternatives to Apache.</p>
<p><strong>Lighttpd</strong></p>
<p><a href="http://www.lighttpd.net/">Lighttpd</a>, pronounced as Lighty, is a single  threaded web server optimized for a large number of keep-alive connections,  which is often a requirement for high traffic web applications. It was  originally developed by the German programmer Jan Kneschke to solve the  <a href="http://www.kegel.com/c10k.html">C10k problem</a> (handle 10,000 parallel  connections using a single server). Apart from Youtube as I have already  mentioned, Wikipedia, Meebo and Sourceforge all use Lighttpd. Lighttpd is rich  with features, and offers mod_rewrite (URL rewriting), FastCGI support, HTTP  compression, amongst many other features. I was able to install and configure  Lighttpd in a few minutes, and it is extremely light-weight (less than 1MB). I  was able to get PHP/MySQL running in a couple of minutes, using the FastCGI  interface.</p>
<p>One drawback, which I have seen repeatedly  mentioned in many forums and blogs on the web (I could not verify these claims  with my own tests), is that Lighttpd seems to suffer from memory leaks &#8211;  which often required scheduled server restarts.</p>
<p><strong>Nginx</strong></p>
<p><a href="http://nginx.net/">Nginx</a>, pronounced as Engine-X, is a web  server originating from Russia, and is written by <a href="http://sysoev.ru/en/">Igor  Sysoev</a>. Unlike Lighttpd, Nginx is not a single  threaded webserver (it instead uses a single master process which delegates  work to a small number of worker processes), but is another popular light  weight web server alternative. It is supported by more than 20% of Russian  virtual hosts, and is gaining lots of attention these days in other parts of  the world too.</p>
<p>Nginx is excellent at serving static files  and also supports reverse proxying. Like Lighttpd, I was able to get Nginx up  and running in a few minutes. However, it does not come up with default FastCGI  support &#8211; so getting PHP/MySQL working was a little tricky. It involves  spawning a FastCGI process manually. I found <a href="http://bc-dev.net/2008/05/07/mysql-nginx-and-php-on-ubuntu-804/">this tutorial helpful</a>.</p>
<p><strong>Erlang based alternatives</strong></p>
<p>Erlang is a concurrent programming language  designed by Ericsson to support distributed, soft real time applications, which  has been opensourced since 1998. I definitely want to write more about how  scalable Erlang is, but this is not the article for that. So, let’s just say  that Erlang is tailor-made for high demand applications which need to handle  multiple concurrent connections &#8211; like a web server.</p>
<p><a href="http://yaws.hyber.org/">YAWS</a> (Yet Another Web Server) and <a href="http://code.google.com/p/mochiweb/">Mochiweb</a> are two Erlang based  web servers which I found to be highly scalable and light-weight.</p>
<p>A load test conducted matching Yaws against  Apache found that Apache failed at 4,000 concurrent connections, while Yaws  continued functioning with over 80,000 concurrent connections (<a href="http://www.sics.se/~joe/apachevsyaws.html">source</a>). I did have some trouble installing  and configuring YAWS though. The documentation is scarce, to say the least.</p>
<p>Mochiweb is actually an Erlang library for  building your own light-weight HTTP server. Don&#8217;t be put off by that statement!  A simple server can be built with just a few lines of code. I installed and  tested Mochiweb too, and I found it pretty easy. If you are interested, here is  <a href="http://beebole.com/en/blog/erlang/how-to-quickly-set-up-ubuntu-804-loaded-with-erlang-mochiweb-and-nginx/">a tutorial which I found helpful</a>.</p>
<p><strong> So should you ditch Apache?</strong></p>
<p>This decision depends on a number of  factors. Like I have already stated, if you want to make the best out of the  limited resources you have, then a light-weight web server is definitely  advantageous. However, from my experience with playing with the above  alternatives, if you do decide to go with one of them, you should be prepared to  roughen it out. Poor documentation and support (the mailing lists and forums  are generally helpful, but you can never completely rely on them when you are  suddenly facing an issue in a production environment) could end up making  things difficult for you. Don&#8217;t get me wrong, I am not saying that these servers are not  production-ready yet (they <em>are</em> pretty  stable), but there is always an off-chance you might just hit upon some snag.  In that case, you probably have to roughen it out.</p>
<p>A reasonable choice would be to front  Apache with one of these light weight web servers. In effect, you can use them  for load balancing. Using reverse-proxying, you can handle the static files  (like CSS and images) using a light weight web server, and route the dynamic  requests to Apache.</p>
<p>So, in future, I hope you will consider an  Apache alternative, should your needs be better satisfied by a light-er web  server. If you have experience using any of the above alternatives, do share  your views in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://query7.com/light-weight-alternatives-to-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

