http_load的一些参数:
-parallel/-p N:并发的用户进程数。
-fetches/-f N: 总计的访问次数
-rate/-p N: 每秒的访问频率
-seconds/-s N: 总计的访问时间下面是简单测试后的结果:
IN[~]>>>http_load -parallel 5 -fetches 1000 url.txt
1000 fetches, 5 max parallel, 3.7365e+07 bytes, in 20.0007 seconds
37365 mean bytes/connection
49.9981 fetches/sec, 1.86818e+06 bytes/sec
msecs/connect: 0.097766 mean, 1.208 max, 0.043 min
msecs/first-response: 0.691867 mean, 2.7 max, 0.443 min
HTTP response codes:
code 200 -- 1000
结果说明:1000 fetches,获得1000个请求,5个并发的进程,20.0007秒内在一共传输了3.7365e+07 bytes。每个进程的传输数据量的大小为37365bytes.每秒有49.9981个请求和1.86818e+06 bytes的数据。每一连接的响应时间为0.097766毫秒,最大响应时间为1.208毫秒,最小响应时间为0.043毫秒。第一次响应时间为0.691867毫秒,最大的响应时间为2.7毫秒,最小的响应时候为0.443毫秒。响应页面的类型是200. 1000请求都为200!
IN[~]>>>http_load -parallel 5 -fetches 1000 urls.txt
1000 fetches, 5 max parallel, 3.7365e+07 bytes, in 39.9998 seconds
37365 mean bytes/connection
25.0001 fetches/sec, 934129 bytes/sec
msecs/connect: 0.129849 mean, 1.714 max, 0.047 min
msecs/first-response: 0.623193 mean, 4.695 max, 0.37 min
HTTP response codes:
code 200 -- 1000
结果说明:1000 fetches,获得1000个请求,5个并发的进程,39.9998秒内在一共传输了3.7365e+07 bytes。每个进程的传输数据量的大小为37365bytes.每秒有25.0001个请求和934129 bytes的数据。每一连接的响应时间为0.129849毫秒,最大响应时间为1.714毫秒,最小响应时间为0.047毫秒。第一次响应时间为0.623193毫秒,最大的响应时间为4.695毫秒,最小的响应时候为0.37毫秒。响应页面的类型是200. 1000请求都为200!
IN[~]>>>http_load -rate 5 -seconds 10 url.txt
49 fetches, 1 max parallel, 1.83088e+06 bytes, in 10.0164 seconds
37365 mean bytes/connection
4.89197 fetches/sec, 182788 bytes/sec
msecs/connect: 0.226449 mean, 0.706 max, 0.179 min
msecs/first-response: 0.233184 mean, 0.786 max, 0.194 min
HTTP response codes:
code 200 -- 49
IN[~]>>>http_load -rate 5 -seconds 10 urls.txt
49 fetches, 1 max parallel, 1.83088e+06 bytes, in 10.0106 seconds
37365 mean bytes/connection
4.8948 fetches/sec, 182894 bytes/sec
msecs/connect: 0.332449 mean, 1.048 max, 0.274 min
msecs/first-response: 0.196571 mean, 0.305 max, 0.167 min
HTTP response codes:
code 200 -- 49
而url.txt和urls.txt的内容分别是
url.txt (nginx)
http://localhost:8080/
urls.txt (lighttpd)
http://localhost/它们的配置文件如下:
lighttpd1.5
server.modules = (
"mod_access","mod_accesslog" )
server.document-root = "/data/"
server.errorlog = "/var/log/lighttpd.error.log"
index-file.names = ( "index.php", "index.html")
server.pid-file = "/var/run/lighttpd.pid"
server.tag = "Lighttpd"
server.username = "www"
server.groupname = "www"
# mimetype mapping
mimetype.assign = (
,
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".dtd" => "text/xml",
".xml" => "text/xml"
)
accesslog.filename = "/var/log/lighttpd.access.log"
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
nginx0.8.49
user www www;
worker_processes 1;
error_log /var/log/nginx.error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx.access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /data;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
}从这里可以简单的看到,nginx的性能比lighttpd真的好一点,不过我发现了几个nginx不足的地方:
1 日志文件过于简单.我刚配置的时候,nginx无法支持php,我查看错误日志,错误日志只显示1051 directory index of "/data/blog/" is forbidden这个信息,并没指出错误所在,这一点就不够lighttpd了。其实nginx的错误日志有几种格式,我试过几个都不行!
2 启动后内存有点大。启动后nginx所占的内存比lighttpd大了快一倍。我想应该是nginx在启动后就加载了所有的模块,而lighttpd对模块的加载是可选的
上面只是我刚开始玩nginx的片面之谈。其实nginx有很多lighttpd无法比拟的地方。