项目背景
我们需要对于自己的web服务器模拟现实环境进行测试!!!
实验环境:
vmware workstation 11
centos6.5的系统下
服务器:ip:192.168.0.39
SecureCRT (ssh远程连接软件)
软件介绍:
Httperf:测试服务器能承载的最大服务,可以指定规律压力测试模拟真实环境。
实验过程:
一、软件安装
1:软件源码下载
wget ftp://ftp.hpl.hp.com/pub/httperf/httperf-0.9.0.tar.gz
2:解压
tar zxvf httperf-0.9.0.tar.gz
3:编译安装
./configure && make && make install
二、软件使用
通过如下命令:
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
测试一下百度的服务器
[root@user httperf-0.9.0]# httperf --server 61.135.169.121 --port 80 --num-conns 2000 --rate 100 --timeout 2
httperf --timeout=2 --client=0/1 --server=61.135.169.121 --port=80 --uri=/ --rate=100 --send-buffer=4096 --recv-buffer=16384 --num-conns=2000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 5
Total: connections 2000 requests 1888 replies 189 test-duration 22.961 s
Connection rate: 87.1 conn/s (11.5 ms/conn, <=287 concurrent connections)
Connection time [ms]: min 460.2 avg 2163.5 max 3586.6 median 2157.5 stddev 647.3
Connection time [ms]: connect 413.1
Connection length [replies/conn]: 1.000
Request rate: 82.2 req/s (12.2 ms/req)
Request size [B]: 67.0
Reply rate [replies/s]: min 3.2 avg 6.3 max 12.4 stddev 4.1 (4 samples)
Reply time [ms]: response 320.6 transfer 1461.0
Reply size [B]: header 1008.0 content 98036.0 footer 2.0 (total 99046.0)
Reply status: 1xx=0 2xx=189 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.34 system 21.91 (user 1.5% system 95.4% total 96.9%)
Net I/O: 801.5 KB/s (6.6*10^6 bps)
Errors: total 1811 client-timo 1811 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
每秒回应最大请求数为12.4
最大并发数为287
平均响应时间为320.6毫秒
测试一下南阳理工的官网
[root@user httperf-0.9.0]# httperf --server 222.139.215.198 --port 80 --num-conns 2000 --rate 100 --timeout 2
httperf --timeout=2 --client=0/1 --server=222.139.215.198 --port=80 --uri=/ --rate=100 --send-buffer=4096 --recv-buffer=16384 --num-conns=2000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 6
Total: connections 2000 requests 1241 replies 12 test-duration 22.898 s
Connection rate: 87.3 conn/s (11.4 ms/conn, <=357 concurrent connections)
Connection time [ms]: min 3621.2 avg 4146.7 max 4982.7 median 3985.5 stddev 520.1
Connection time [ms]: connect 453.4
Connection length [replies/conn]: 1.000
Request rate: 54.2 req/s (18.5 ms/req)
Request size [B]: 68.0
Reply rate [replies/s]: min 0.0 avg 0.6 max 1.4 stddev 0.7 (4 samples)
Reply time [ms]: response 1262.0 transfer 1824.3
Reply size [B]: header 174.0 content 35654.0 footer 2.0 (total 35830.0)
Reply status: 1xx=0 2xx=12 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.43 system 22.07 (user 1.9% system 96.4% total 98.3%)
Net I/O: 21.9 KB/s (0.2*10^6 bps)
Errors: total 1988 client-timo 1988 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
每秒回应最大请求数为0.6
最大并发数为357
平均响应时间为1262.0毫秒
项目总结:
httperf是一款开源的简单易用的web服务器性能测试软件,能让我们客观的了解我们web服务器的压力!!!
谢谢大家,希望大家有所得~~~~