小试 httperf

阅读更多

httperf是个web 服务器的性能测试工具

Step1) 安装

cd /usr/local/

tar xvzf httperf-0.9.0.tar.gz

cd httperf-0.9.0

./configure --prefix=/usr/local/weip/httperf-0.9.0

make && make install

Step2) 测试

通过如下命令:

httperf --server xx.com \
--port 80 \
--uri /foreground/all_stars
\
--rate
100 \
--num-conn
2000 \
--num-call 1 \
--timeout 5

rate是指每秒多少个请求数,num-conn指共发多少个请求 ,num-call每次连接发送的请求数通常为1

Step3)实战

背景:lighttpd+fcgi+rails部署在192.168.100.234,httperf运行在192.168.100.231

Case1) 利用rails生成了静态页面

httperf输出结果:

。。。。。

Total: connections 2000 requests 2000 replies 2000 test-duration 19.991 s

Connection rate: 100.0 conn/s (10.0 ms/conn, <=1 concurrent connections)

Connection time [ms]: min 0.6 avg 0.7 max 1.1 median 0.5 stddev 0.0

Connection time [ms]: connect 0.0

Connection length [replies/conn]: 1.000

Request rate: 100.0 req/s (10.0 ms/req)

Request size [B]: 86.0

Reply rate [replies/s]: min 100.0 avg 100.0 max 100.0 stddev 0.0 (3 samples)

Reply time [ms]: response 0.5 transfer 0.2

Reply size [B]: header 240.0 content 52164.0 footer 0.0 (total 52404.0)

Reply status: 1xx=0 2xx=2000 3xx=0 4xx=0 5xx=0

CPU time [s]: user 6.43 system 12.60 (user 32.2% system 63.0% total 95.2%)

Net I/O: 5128.2 KB/s (42.0*10^6 bps)

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0

Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

可见每秒100个请求没问题

Case2 )纯动态页面,不做缓存处理

每秒100个请求完全崩溃

将每秒100改为10个,共发送200个请求,服务在19.948 s内顺利完成任务

你可能感兴趣的:(Rails,lighttpd,Socket,Web,.net)