nginx vs. Lighttpd vs. Apache 高效的web server服务器软件比较

如果你在Linux下用Apache Bench (ab)测试我这个网站的话,就会发现服务器不是常见的Apache, 而是 nginx.

nginx是一个小巧而高效的Linux下的web服务器软件。开发人员 Igor Sysoev 来自俄罗斯,nginx的话其实已经在一些俄罗斯的大型网站上运行多年,相当的稳定,最近才在美国开始知名起来。

而 另外一个热门的web服务器软件是Lighttpd,因为运行在Youtube的后台,所以知名度很高。Lighttpd特色在于它能做Flash streaming和对fastcgi的支持,这样对于Ruby on Rails之类的程序提速不少,比起Apache要好很多。

但是 nginx 要比 Lighttpd 更稳定,功能上并不弱于Lighttpd,差不多什么都有,而且比Lighttpd对于URL rewrite的支持更完善一点。

不管是 nginx 还是 lighttpd, 对于用来提供静态文件都要比Apache好很多很多,主要就是占用的内存小,Apache和这两个小巧的服务器软件来比实在是个庞然大物啊。


测试报告::::::

主机环境:
电脑: PC, CPU: AMD 1800+, MEM: 728M, DISK: IDE 7200RPM 2M, 160G
系统: FreeBSD 6.1-RELEASE-p11
软件:
Apache-2.0.59
Lighttpd-1.4.13-1
nginx-0.5.5

测试机:
电脑: Latop IBM T20, P3-700, MEM: 256M
系统: FreeBSD 6.2-PRERELEASE
软件: WebBench 1.5

静态网页的比较:
index.html 是apache2 自带的 index.html.en 拷贝来的。

nginx(ports install):
mybsd# webbench -c 500 -2 http://192.168.8.249:82/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:82/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=429908 pages/min, 12360223 bytes/sec.
Requests: 214954 susceed, 0 failed.

lighttpd(ports install):
mybsd# webbench -c 500 -2 http://192.168.8.249:81/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:81/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=429182 pages/min, 12506485 bytes/sec.
Requests: 214591 susceed, 0 failed.

apache2+worker(ports install):
mybsd# webbench -c 500 -2 http://192.168.8.249:80/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:80/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=80118 pages/min, 2337701 bytes/sec.
Requests: 40059 susceed, 0 failed.

apache2+worker(ports install)
enable sendfile();
mybsd# webbench -c 500 -2 http://192.168.8.249:80/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:80/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=80728 pages/min, 2355835 bytes/sec.
Requests: 40364 susceed, 0 failed.

/opt/modules/apache2(手工安装):
mybsd# webbench -c 500 -2 http://192.168.8.249:83/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:83/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=95102 pages/min, 2774133 bytes/sec.
Requests: 47551 susceed, 0 failed.

/opt/modules/apache2 worker(手工安装):
mybsd# webbench -c 500 -2 http://192.168.8.249:83/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:83/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=79100 pages/min, 2307692 bytes/sec.
Requests: 39550 susceed, 0 failed.


/opt/modules/apache2p prefork(手工安装):
mybsd# webbench -c 500 -2 http://192.168.8.249:84/index.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:84/index.html (using HTTP/1.1)
500 clients, running 30 sec.

Speed=106000 pages/min, 3093523 bytes/sec.
Requests: 53000 susceed, 0 failed.


PHP支持比较
info.php:

phpinfo();

?>

/opt/modules/apache2 prefork(手工安装)

mybsd# webbench -c 500 -2 http://192.168.8.249:83/info.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:83/info.php (using HTTP/1.1)
500 clients, running 30 sec.

Speed=13628 pages/min, 9712975 bytes/sec.
Requests: 6814 susceed, 0 failed.


nginx(proxy)+apache2(/opt/modules/apache2(手工安装))
mybsd# webbench -c 500 -2 http://192.168.8.249:82/info.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:82/info.php (using HTTP/1.1)
500 clients, running 30 sec.

Speed=9954 pages/min, 7505740 bytes/sec.
Requests: 4977 susceed, 0 failed.


lighttpd(proxy)+apache2apache2(/opt/modules/apache2(手工安装))
mybsd# webbench -c 500 -2 http://192.168.8.249:81/info.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.8.249:81/info.php (using HTTP/1.1)
500 clients, running 30 sec.

Speed=10150 pages/min, 7732128 bytes/sec.
Requests: 5075 susceed, 0 failed.




另外lighttpd和nginx 在fastcgi的支持中,没有明显的差异,就没有将结果记录起来。
从上面的结果来看,在静态支持中,lighttpd和nginx 是比apache优胜很多很多的。
即使Apache2+worker,在支持PHP方面,还是不太让人满意。

另外从运行时对内存、CPU开销来看,最大是Apache,Lighttpd 和 Nginx 比较接近,但是Lighttpd相比Nginx更占资源一些。

因此,如果不考虑虚拟主机安全设置的问题,Nginx无疑是最好的选择,其次是Lighttpd。

转自:http://hi.baidu.com/lvmajia/blog/item/9932be10d7ebae04213f2e90.html

http://blog.s135.com/read.php/314.htm

你可能感兴趣的:(apache,nginx,Web,server,lighttpd,服务器软件)