和以往一样,本次测试均使用默认配置
不对内核以及应用程序做任何优化
配置文件优先采用程序自带的默认配置,
在没有默认配置的前提下,使用最简化的配置文件
平台
WEB:
CentOS 5.1 最小化安装
浪潮NF180
Xeon 2.8
1G RAM
73G SCSI
Nginx 0.6.31
Apache 1.3.41
Apache 2.2.8
Lighthttpd 1.4.19
CLIENT:
CentOS 5.1 最小化安装
浪潮NF260
Xeon 2.4
512M RAM
36G SCSI
http_load-12mar2006
SWITCH:
DLINK DES 1024R+
1.Nginx 0.6.31
编译参数
<?php
./configure --prefix=/usr/local/nginx
配置文件
worker_processes 10;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2.Lighthttpd 1.4.19
编译参数
<?php
./configure --prefix=/usr/local/lighthttpd
配置文件
server.modules = (
"mod_accesslog" )
server.document-root = "/var/www/html/"
server.errorlog = "/var/log/lighttpd/error.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jar" => "application/x-java-archive",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
# default mime type
"" => "application/octet-stream",
)
accesslog.filename = "/var/log/lighttpd/access.log"
url.access-deny = ( "~", ".inc" )
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
3.Apache 1.3.41
编译参数
<?php
./configure --prefix=/usr/local/apache1.3.41
配置文件
ServerType standalone
ServerRoot "/usr/local/apache1.3.41"
PidFile /usr/local/apache1.3.41/logs/httpd.pid
ScoreBoardFile /usr/local/apache1.3.41/logs/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
Port 80
User nobody
Group nobody
ServerAdmin root@test1.hiadmin.com
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
UseCanonicalName On
<IfModule mod_mime.c>
TypesConfig /usr/local/apache1.3.41/conf/mime.types
</IfModule>
DefaultType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile /usr/local/apache1.3.41/conf/magic
</IfModule>
HostnameLookups Off
ErrorLog /usr/local/apache1.3.41/logs/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/local/apache1.3.41/logs/access_log common
ServerSignature On
<IfModule mod_alias.c>
Alias /icons/ "/usr/local/apache1.3.41/icons/"
<Directory "/usr/local/apache1.3.41/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /manual/ "/usr/local/apache1.3.41/htdocs/manual/"
<Directory "/usr/local/apache1.3.41/htdocs/manual">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "/usr/local/apache1.3.41/cgi-bin/"
<Directory "/usr/local/apache1.3.41/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</IfModule>
<IfModule mod_autoindex.c>
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>
<IfModule mod_mime.c>
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .ee
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage he .he
AddCharset ISO-8859-8 .iso8859-8
AddLanguage it .it
AddLanguage ja .ja
AddCharset ISO-2022-JP .jis
AddLanguage kr .kr
AddCharset ISO-2022-KR .iso-kr
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddCharset ISO-8859-2 .iso-pl
AddLanguage pt .pt
AddLanguage pt-br .pt-br
AddLanguage ltz .lu
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .sv
AddLanguage cs .cz .cs
AddLanguage ru .ru
AddLanguage zh-TW .zh-tw
AddCharset Big5 .Big5 .big5
AddCharset WINDOWS-1251 .cp-1251
AddCharset CP866 .cp866
AddCharset ISO-8859-5 .iso-ru
AddCharset KOI8-R .koi8-r
AddCharset UCS-2 .ucs2
AddCharset UCS-4 .ucs4
AddCharset UTF-8 .utf8
<IfModule mod_negotiation.c>
LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
</IfModule>
AddType application/x-tar .tgz
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
</IfModule>
<IfModule mod_setenvif.c>
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>
?>
4.Apache 2.2.8
编译参数
<?php
./configure --prefix=/usr/local/apache2.2.8
配置文件
ServerRoot "/usr/local/apache2.2.8"
Listen 80
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User nobody
Group nobody
</IfModule>
</IfModule>
ServerAdmin you@example.com
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache2.2.8/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/var/www/html">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
DefaultType text/plain
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
测试结果
1.Nginx 0.6.31
200并发
<?php
./http_load -parallel 200 -fetches 1000 urls
1000 fetches, 200 max parallel, 2.23782e+08 bytes, in 19.0757 seconds
223782 mean bytes/connection
52.4228 fetches/sec, 1.17313e+07 bytes/sec
msecs/connect: 318.028 mean, 9293.85 max, 0.183 min
msecs/first-response: 278.832 mean, 2858.73 max, 0.489 min
HTTP response codes:
code 200 -- 1000
500并发
<?php
./http_load -parallel 500 -fetches 1000 urls
1000 fetches, 500 max parallel, 2.23782e+08 bytes, in 19.0797 seconds
223782 mean bytes/connection
52.4119 fetches/sec, 1.17288e+07 bytes/sec
msecs/connect: 243.77 mean, 9104.99 max, 0.194 min
msecs/first-response: 307.939 mean, 2279.38 max, 0.514 min
HTTP response codes:
code 200 -- 1000
1000并发
<?php
./http_load -parallel 1000 -fetches 1000 urls
1000 fetches, 1000 max parallel, 1.41278e+08 bytes, in 12.0671 seconds
141278 mean bytes/connection
82.8699 fetches/sec, 1.17077e+07 bytes/sec
msecs/connect: 692.526 mean, 3251.55 max, 0.265 min
msecs/first-response: 356.194 mean, 2131.45 max, 0.465 min
631 bad byte counts
HTTP response codes:
code 200 -- 631
code 500 -- 369
2.Lighthttpd 1.4.19
200并发
<?php
./http_load -parallel 200 -fetches 1000 urls
1000 fetches, 200 max parallel, 2.23782e+08 bytes, in 19.0897 seconds
223782 mean bytes/connection
52.3842 fetches/sec, 1.17226e+07 bytes/sec
msecs/connect: 354.108 mean, 3638.78 max, 0.143 min
msecs/first-response: 235.485 mean, 3029.56 max, 1.997 min
HTTP response codes:
code 200 -- 1000
500并发
<?php
./http_load -parallel 500 -fetches 1000 urls
1000 fetches, 500 max parallel, 2.23782e+08 bytes, in 19.0725 seconds
223782 mean bytes/connection
52.4315 fetches/sec, 1.17332e+07 bytes/sec
msecs/connect: 287.275 mean, 9455.62 max, 0.224 min
msecs/first-response: 257.751 mean, 2249.71 max, 0.97 min
HTTP response codes:
code 200 -- 1000
1000并发
<?php
./http_load -parallel 1000 -fetches 1000 urls
1000 fetches, 1000 max parallel, 2.1774e+08 bytes, in 22.7961 seconds
217740 mean bytes/connection
43.8672 fetches/sec, 9.55164e+06 bytes/sec
msecs/connect: 1460.29 mean, 21008.3 max, 0.214 min
msecs/first-response: 2799.52 mean, 22539.3 max, 1.229 min
973 bad byte counts
HTTP response codes:
code 200 -- 977
3.Apache 1.3.41
200并发
<?php
./http_load -parallel 200 -fetches 1000 urls
1000 fetches, 200 max parallel, 2.23782e+08 bytes, in 19.0731 seconds
223782 mean bytes/connection
52.4299 fetches/sec, 1.17329e+07 bytes/sec
msecs/connect: 276.673 mean, 9453.83 max, 0.243 min
msecs/first-response: 1599.88 mean, 8320.12 max, 1.113 min
HTTP response codes:
code 200 -- 1000
500并发
<?php
./http_load -parallel 500 -fetches 1000 urls
1000 fetches, 500 max parallel, 2.23782e+08 bytes, in 19.0728 seconds
223782 mean bytes/connection
52.4307 fetches/sec, 1.1733e+07 bytes/sec
msecs/connect: 422.419 mean, 9415.94 max, 0.193 min
msecs/first-response: 4767.44 mean, 18611.4 max, 0.88 min
HTTP response codes:
code 200 -- 1000
1000并发
<?php
./http_load -parallel 1000 -fetches 1000 urls
1000 fetches, 1000 max parallel, 2.17516e+08 bytes, in 42.654 seconds
217516 mean bytes/connection
23.4444 fetches/sec, 5.09954e+06 bytes/sec
msecs/connect: 1074.78 mean, 3355.42 max, 0.265 min
msecs/first-response: 8056.64 mean, 20524.4 max, 0.874 min
28 bad byte counts
HTTP response codes:
code 200 -- 972
4.Apache 2.2.8
200并发
<?php
./http_load -parallel 200 -fetches 1000 urls
1000 fetches, 200 max parallel, 2.23782e+08 bytes, in 19.0764 seconds
223782 mean bytes/connection
52.4207 fetches/sec, 1.17308e+07 bytes/sec
msecs/connect: 244.063 mean, 9526.98 max, 0.175 min
msecs/first-response: 1489.62 mean, 8591.23 max, 1.88 min
HTTP response codes:
code 200 -- 1000
500并发
<?php
./http_load -parallel 500 -fetches 1000 urls
1000 fetches, 500 max parallel, 2.21992e+08 bytes, in 21.037 seconds
221992 mean bytes/connection
47.5352 fetches/sec, 1.05524e+07 bytes/sec
msecs/connect: 253.137 mean, 3475.19 max, 0.159 min
msecs/first-response: 3842.25 mean, 16118.2 max, 1.163 min
8 bad byte counts
HTTP response codes:
code 200 -- 992
1000并发
<?php
./http_load -parallel 1000 -fetches 1000 urls
1000 fetches, 1000 max parallel, 2.1774e+08 bytes, in 26.5296 seconds
217740 mean bytes/connection
37.6938 fetches/sec, 8.20745e+06 bytes/sec
msecs/connect: 1384.75 mean, 9128.98 max, 0.245 min
msecs/first-response: 6792.88 mean, 24075.5 max, 1.493 min
27 bad byte counts
HTTP response codes:
code 200 -- 973
在200以及500并发的情况下
我们可以看到4个httpd软件并没有本质差别
但是当并发数达到1000
我们发现lighthttpd的错误率最高,nginx紧随其后,再仔细分析数据
我们可以发现nginx的631次获取中,有631次count byte wrong,也就是说全部出错
而lighthttpd的977此获取中有973次是出错
nginx更差一些
当然这个差距.可能由于nginx以及lighthttpd的默认timeout值有关
apache作为追求稳定的服务软件,其默认timeout值比较大
策略上的差异导致性能上以及稳定性上的差异
apache 2.2.8在500并发数时就发生了错误,而且在之后的几次测试中,也均发生错误
不论是重启服务器还是其他措施,apahce2在500并发数的表现下均无法令人满意
但是其在1000并发数下的性能表现,在不增加错误数的前提下,比apache 1.3.41有着很大的提高
结论
1.nginx以及lighthttpd的性能在默认配置情况下遇到大流量将会发生无法服务的情况
2.apache 2.x的版本其压力/性能表现呈线性,更适合大型网站使用.在压力不是很大的情况下,可能apache 1.x更适合.
来源:
http://yinqiongjie.blog.163.com/blog/static/56197620096205626932/
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2915/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表