Lighttpd和nginx是目前替代apache最有力的两个竞争者了,偶最近考虑把网站的apache替换为它们中的一个,因此找了下它们对比的资料,下面的文章是我感觉比较客观中肯的,希望对大家有帮助,呵呵。
Nginx vs. Lighttpd for a small VPSTagged in
序列号 | CPU | RAM | HDD | 带宽 | 售价(美元) | 免费试用 |
---|---|---|---|---|---|---|
香港服务器1 | E5-2620 | 32G | 1T HDD | 50M/无限流量 | $196.00 | 立即申请 |
香港服务器2 | E5-2650 | 32G | 1T HDD | 50M/无限流量 | $256.00 | 立即申请 |
香港服务器3 | E5-2680 | 32G | 1T HDD | 50M/无限流量 | $316.00 | 立即申请 |
香港服务器4 | E5-2690 | 32G | 1T HDD | 50M/无限流量 | $336.00 | 立即申请 |
香港服务器5 | E5-2697 | 32G | 1T HDD | 50M/无限流量 | $376.00 | 立即申请 |
香港服务器6 | E5-2620*2 | 32G | 1T HDD | 50M/无限流量 | $376.00 | 立即申请 |
香港服务器7 | E5-2650*2 | 32G | 1T HDD | 50M/无限流量 | $436.00 | 立即申请 |
香港服务器8 | E5-2680*2 | 32G | 1T HDD | 50M/无限流量 | $476.00 | 立即申请 |
香港服务器9 | E5-2690*2 | 32G | 1T HDD | 50M/无限流量 | $556.00 | 立即申请 |
香港服务器10 | E5-2697*2 | 32G | 1T HDD | 50M/无限流量 | $596.00 | 立即申请 |
香港服务器11 | E5-2680v4*2 | 32G | 1T HDD | 50M/无限流量 | $696.00 | 立即申请 |
香港服务器12 | E5-2698v4*2 | 32G | 1T HDD | 50M/无限流量 | $796.00 | 立即申请 |
* lighttpd* nginx* vps hosting* web server
Posted on January 10, 2007 2:41pm
I have been using Lighttpd for almost a year and Nginx for amonth on my servers. I know that they were created to be massivelyscalable, solving the C10k problem. However their asynchronised-IOmodel and small memory foot-print also make them suitable asalternative HTTP servers for memory-limited VPS. Alternative =Anything but the current defacto Apache.
I will be writing more about Lighttpd and Nginx later during theyear, but will try to use this post to draw some comparison betweenNginx, the new darling of these light-weight web servers, andLighttpd, many Web 2.0 developers’ all time favourite.Lighttpd
Lighttpd I have been running Lighttpd (pronounced “lighty”) onmy home servers and development boxes since the beginning of 2006.It is a great replacement for Apache if you have the whole box toyourself, i.e. you don’t need to worry about supporting .htaccessfiles that your users might use. Currently this website is hostedon lighttpd-1.4.13 on a Gentoo VPS.
Pros
* Light weight. Clean restart of 1.4.13 takes no more than 2MbRSS on this 64bit VPS. It binds the port, drops the privilege andthat’s it! A single process does all the tricks even when you havehundreds of concurrent connections. No more pre-fork MPM withmis-configured MaxClient that sends you to swap hell.* Speed. Very fast static file serving. Very fast FastCGI serving.Very fast proxy serving.* Modules, and lots of them. Good comprehensive documentation aswell. It even has SCGI for your Quixote apps.* Mod_magnet. Wanna a scripting engine right inside your webserver? Mod_magnet integrates Lua into lighttpd, so your World ofWarcraft scripting skillz can be put into better use.* Community. It has got a Blog, a Wiki/bug tracker and a forum. Itis easy to find help when you need one.
Cons
* Stability (or lack of according to the RoR folks). I had quitea lot of issues using Lighttpd as proxy+HTTPS front-end for ourPython stuff, but the same app runs fine with just lighttpd + proxywithout HTTPS.* Mod_rewrite (or again, lack of it). Built-in rewriting enginesucks, and porting Apache mod_rewrite rules over can be non-trivialsometimes. Update: Here’s an article I have written on Drupal cleanURL on Nginx and Lighttpd, which looks at the URL rewrite optionsof these two web servers.* Memory leak. The RSS of my lighty process grows by about 1.5Mbper day, but then I don’t have lots of traffic (less than 50krequests a day). At the end I just need to restart it once a week.Many people have far worse memory leaking issues I heard.
Nginx
Nginx I have been running Nginx (pronounced “engine X”) on mydevelopment box and two of my VPS’s since December 2006. It isRussian, fast and very configurable. I am currently using 0.5.5 formy sites, but don’t be deceived by its version number — it is verystable.
Pros
* Light weight. It is not as light weight as lighttpd when itclean-starts. At least two processes are needed — one masterprocess running as root that binds to the port, and one or moreworker processes that handle the actual requests. Around 7Mb RSStogether on my 64bit VPS (and only 4.5Mb on 32bit VPS). Still beatsApache hands down.* Fast. Some benchmarks have shown that Nginx has a slight edgeover Lighttpd, but so far I haven’t been able to notice any. Again,much faster than Apache over static file serving or proxying,especially when you turn up the value of keep alive (more than 1minute for example).* Modules. There are many modules available on Nginx. Some veryuseful, and some are just plain weird. While lighttpd has Luaembedded, you can now also embed the whole Perl interpretor insideNginx.* Better Rewrite Module. A much better rewrite module than Lighttpdthat supports complex conditions. Porting mod_rewrite rules fromApache is actually now feasible without touching the appsthemselves.* Stable and not leaking. Been running Nginx on a production sitedoing PHP-FastCGI, and have no issue what so ever.
Cons
* Lack of community. Where can I find help regarding Nginx?There’s only IRC as far as I know. And while the lead developerwrites beautiful code, all documentation were initially in Russianwhich was a big stumbling block before the English docs camealong.* No CGI support. Oh well, maybe I am the only one who still hackssmall CGI scripts. Apparently Nginx does not spawn CGI or FastCGIprocesses, which means you need to either (1) convert it intoexternal-spawn FastCGI, or (2) proxy to another web server thatdoes CGI.* No simple virtual host support. Lighttpd has mod_simple_vhost andmod_evhost to let you quickly deploy lots of name-based virtualhosts. You can somehow do the same with using $server_name in rootand a wild-card in server_name, but it’s still not as clean aslighttpd. At the end you will find Nginx configuration files muchmore verbose if you run lots of small sites off a single webserver.* No X-sendfile support. I found Lighttpd’s X-sendfile support veryuseful when my scripts need to send back large files, and wasdisappointed to find out that Nginx does not have it.X-Accel-Redirect is different as it requires extra configuration onweb server, which makes your web-app less portable.
Conclusion
I don’t think I am a suitable judge to say which one is better,as (1) I have only been running Nginx for a month, and (2) my levelof traffic does not really stress test these high-performing webservers. At the moment I think I like Nginx better purely becauseit does not leak, and its rewrite module that enables me to runmany off-the-shelf open source PHP apps with clean URL.
Again, I might change my mind in 3 months time when I find outmore warts about Nginx. We will see.