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
總結
以上是生活随笔為你收集整理的nginx vs. Lighttpd vs. Apache 高效的web server服务器软件比较的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: subversion for linu
- 下一篇: 开源一些Delphi系统:诗词成语字典