`

nginx vs lighttpd

阅读更多

I have been using Lighttpd for almost a year and Nginx for a month on my servers. I know that they were created to be massively scalable, solving the C10k problem. However their asynchronised-IO model and small memory foot-print also make them suitable as alternative HTTP servers for memory-limited VPS. Alternative = Anything but the current defacto Apache.

I will be writing more about Lighttpd and Nginx later during the year, but will try to use this post to draw some comparison between Nginx, the new darling of these light-weight web servers, and Lighttpd, many Web 2.0 developers’ all time favourite.

Lighttpd

Lighttpd I have been running Lighttpd (pronounced “lighty”) on my home servers and development boxes since the beginning of 2006. It is a great replacement for Apache if you have the whole box to yourself, i.e. you don’t need to worry about supporting .htaccess files that your users might use. Currently this website is hosted on lighttpd-1.4.13 on a Gentoo VPS.

Pros

  • Light weight. Clean restart of 1.4.13 takes no more than 2Mb RSS on this 64bit VPS. It binds the port, drops the privilege and that’s it! A single process does all the tricks even when you have hundreds of concurrent connections. No more pre-fork MPM with mis-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 as well. It even has SCGI for your Quixote apps.
  • Mod_magnet. Wanna a scripting engine right inside your web server? Mod_magnet integrates Lua into lighttpd, so your World of Warcraft scripting skillz can be put into better use.
  • Community. It has got a Blog, a Wiki/bug tracker and a forum. It is easy to find help when you need one.

Cons

  • Stability (or lack of according to the RoR folks). I had quite a lot of issues using Lighttpd as proxy+HTTPS front-end for our Python stuff, but the same app runs fine with just lighttpd + proxy without HTTPS.
  • Mod_rewrite (or again, lack of it). Built-in rewriting engine sucks, and porting Apache mod_rewrite rules over can be non-trivial sometimes. Update: Here’s an article I have written on Drupal clean URL on Nginx and Lighttpd, which looks at the URL rewrite options of these two web servers.
  • Memory leak. The RSS of my lighty process grows by about 1.5Mb per day, but then I don’t have lots of traffic (less than 50k requests 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 my development box and two of my VPS’s since December 2006. It is Russian, fast and very configurable. I am currently using 0.5.5 for my sites, but don’t be deceived by its version number — it is very stable.

Pros

  • Light weight. It is not as light weight as lighttpd when it clean-starts. At least two processes are needed — one master process running as root that binds to the port, and one or more worker processes that handle the actual requests. Around 7Mb RSS together on my 64bit VPS (and only 4.5Mb on 32bit VPS). Still beats Apache hands down.
  • Fast. Some benchmarks have shown that Nginx has a slight edge over 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 1 minute for example).
  • Modules. There are many modules available on Nginx. Some very useful, and some are just plain weird. While lighttpd has Lua embedded, you can now also embed the whole Perl interpretor inside Nginx.
  • Better Rewrite Module. A much better rewrite module than Lighttpd that supports complex conditions. Porting mod_rewrite rules from Apache is actually now feasible without touching the apps themselves.
  • Stable and not leaking. Been running Nginx on a production site doing 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 developer writes beautiful code, all documentation were initially in Russian which was a big stumbling block before the English docs came along.
  • No CGI support. Oh well, maybe I am the only one who still hacks small CGI scripts. Apparently Nginx does not spawn CGI or FastCGI processes, which means you need to either (1) convert it into external-spawn FastCGI, or (2) proxy to another web server that does CGI.
  • No simple virtual host support. Lighttpd has mod_simple_vhost and mod_evhost to let you quickly deploy lots of name-based virtual hosts. You can somehow do the same with using $server_name in root and a wild-card in server_name, but it’s still not as clean as lighttpd. At the end you will find Nginx configuration files much more verbose if you run lots of small sites off a single web server.
  • No X-sendfile support. I found Lighttpd’s X-sendfile support very useful when my scripts need to send back large files, and was disappointed to find out that Nginx does not have it. X-Accel-Redirect is different as it requires extra configuration on web 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 level of traffic does not really stress test these high-performing web servers. At the moment I think I like Nginx better purely because it does not leak, and its rewrite module that enables me to run many off-the-shelf open source PHP apps with clean URL.

Again, I might change my mind in 3 months time when I find out more warts about Nginx. We will see.

分享到:
评论

相关推荐

    套件php 集成最新的Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend Optimizer+Zend Loader

    首先,Apache、Nginx和LightTPD是三种流行的Web服务器软件。Apache是最广泛使用的开源HTTP服务器,具有丰富的模块和广泛的社区支持。Nginx以其高性能和低内存占用著称,尤其适合高并发场景。LightTPD则是一款轻量级...

    Web服务器选型(Apache+Nginx+Lighttpd)之性能对比测试报告.pdf

    这篇性能对比测试报告主要关注了三个主流的Web服务器——Apache、Nginx和Lighttpd在性能上的差异。测试的目的是为了评估这三款服务器在实际应用中的性能表现,为未来的项目选择提供依据。测试环境是在一台配置为8核...

    phpStudy 最新 Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend 稳定 强大

    1、全面适合 Win2000/XP/2003/win7/win8/win2008 操作系统 ,支持Apache、IIS、Nginx和LightTPD。 2、该程序包集成以下软件,括号内为phpstudy下对应的目录。 php 7.0.12 php 5.6.27 php 5.5.38 php 5.4.35...

    jquery-upload-progress, 上传进度栏使用 apache Nginx 和lighttpd上传进度模块.zip

    jquery-upload-progress, 上传进度栏使用 apache Nginx 和lighttpd上传进度模块 它可以与apache上传进度模块,Nginx 上传进度模块或者lighttpd一起使用,在这里阅读更多: ...

    lighttpd和nginx比较

    ### Lighttpd与Nginx的深度比较 随着互联网技术的发展与用户需求的增长,轻量级Web服务器在处理高并发连接、低资源消耗等方面展现出了显著的优势。在众多选择中,Lighttpd与Nginx成为了最为热门的两种替代方案。...

    nginx lighttpd apache 之间的区别.doc

    标题中的“nginx lighttpd apache 之间的区别”指的是在IT行业中选择Web服务器时常见的三个选项:Nginx、Lighttpd和Apache。这三种服务器在技术特性、性能、资源消耗和适用场景上都有各自的特点。 首先,让我们详细...

    三大WEB服务器对比分析(apache ,lighttpd,nginx)

    三大WEB服务器对比分析(apache ,lighttpd,nginx) 分析的还不错

    Nginx、Apache、Lighttpd禁止目录执行php配置示例

    本篇文章将详细介绍如何在Nginx、Apache和Lighttpd这三种流行的Web服务器上实现这一功能。 **Apache配置** 在Apache服务器上,我们可以使用`<Directory>`指令来限制指定目录内的PHP执行。以下是一个示例: ```...

    Nginx课件完整版.pdf

    Nginx课件完整版.pdf Nginx是一款功能强大的网络服务器软件,能够提供高性能的Web服务器、反向代理、负载均衡等功能。...Nginx的竞争对手有Apache、Lighttpd、Tomcat、Jetty、IIS等,各自有其特点和应用场景。

    nginx 源码 解析 资料大全

    收集的 nginx 源码 解析 ,非常全 architecture.png ...nginx与lighttpd+实现分析比较.pdf Nginx源代码分析.docx Nginx源代码分析与导读.ppt nginx源码分析.doc nginx源码剖析.pdf Ningx代码研究.docx

    lighttpd-1.4.45_lighttpd服务器_

    lighttpd,这个名字在Web服务器领域中或许不如Apache或Nginx那样耳熟能详,但其独特的轻量级特性和高效性能,使得它在特定场景下成为理想的解决方案。lighttpd-1.4.45是lighttpd服务器的一个重要版本,它以其小巧、...

    Apache、lighttpd、Nginx用哪个搭建高性能服务器

    Apache、lighttpd、Nginx用哪个搭建高性能服务器?对于Web高性能服务器上的选择,这个是很多人头痛的问题。其实Apache、lighttpd、Nginx都用他们优点,在什么情况下我们如何去选择适合自己的Web高性能服务器,  ...

    Linux服务器端Web服务三剑客(Apache Lighttpd Nginx).docx

    自1996年以来,Apache一直是互联网上最受欢迎的Web服务器,尽管市场份额近年来受到了如IIS、GWS、Lighttpd和Nginx等竞争对手的挑战,但其市场占有率仍然居首。 Apache的安装在许多Linux发行版中都是预装的,如...

    实战Nginx:取代Apache的高性能Web服务器 第一章

    在Web服务器领域,有多种不同的服务器被广泛使用,包括但不限于Apache、Nginx和Lighttpd等。这些服务器各有特点,适用于不同场景。 - **Apache**:作为最老牌且最知名的Web服务器之一,Apache提供了丰富的功能和...

    nginx-1.6.2.tar.gz nginx-1.6.2下载

    - **与Lighttpd对比**:Lighttpd 同样轻量,但在负载均衡和反向代理方面,Nginx 更具优势。 7. **常见问题与解决** - **错误日志分析**:通过`error.log`文件定位并解决问题,如配置错误、权限问题等。 - **访问...

    nginx 官网配置.pdf

    Nginx与Apache、Lighttpd或httpd相比,其守护进程的整体效率、配置选项的数量以及设置的简易性都是其独特之处。 具体到配置时,首先需要加载一些MIME类型包含文件,并实时压缩输出数据,设置Expires头以减少客户端...

    Nginx环境搭建

    为了解决这个问题,异步服务器如Nginx和Lighttpd应运而生。Nginx使用更少的资源就能处理更多的并发连接,对于大型网站和高流量服务尤为适用。 Nginx安装与运行控制包括以下步骤: 1. **安装支持软件**:在RHEL 6中...

    agentzh写的Nginx教程

    4. 文章的适用对象:教程适用于所有级别的Nginx用户,包括那些有着丰富Apache和Lighttpd经验但可能从未使用过Nginx的用户。 5. 文章中的示例兼容性:文章中的示例至少与Nginx版本0.8.54兼容,不建议使用低于该版本...

    实战Nginx.取代Apache的高性能Web服务器

    1.4 Nginx与Apache、Lighttpd的综合对比 第2章 Nginx服务器的安装与配置 2.1 安装Nginx服务器所需要的系统资源 2.2 Nginx的下载 2.3 Nginx的安装 2.4 Nginx的启动、停止、平滑重启 2.5 Nginx的平滑重启 2.6 ...

Global site tag (gtag.js) - Google Analytics