十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

Web服务器压力测试工具http_load、webbench、ab、Siege使用教程

上一篇 / 下一篇  2010-11-22 21:51:41 / 个人分类:其它

Web服务器压力测试工具http_loadwebbench、ab、Siege使用教程
一、http_load
程序非常小,解压后也不到100K
http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载。但是它不同于大多数压力测试工
具,它可以以一个单一的进程运行,一般不会把客户机搞死。还可以测试HTTPS类的网站请求。
下载地址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz
#^X.q*BzJO L0安 装很简单
-l+\+hG5{/d;o `-o5?0#tar zxvf http_load-12mar2006.tar.gz51Testing软件测试网L1w*F/o@i4X4X
#cd http_load-12mar200651Testing软件测试网s C0m(f y G6@5}
#make && make install
命令格式:http_load  -p 并发访问进程数  -s 访问时间  需要访问的URL文件
参数其实可以自由组合,参数之间的选择并没有什么限制。比如你写成http_load -parallel 5 -seconds
300 urls.txt也是可以的。我们把参数给大家简单说明一下。
C3N.XpF-u u6\AIg0-parallel 简写-p :含义是并发的用户进程数。
6b5m1H&v/L*P(HK0-fetches 简写-f :含义是总计的访问次数51Testing软件测试网i*MBBm?-bz
-rate    简写-p :含义是每秒的访问频率51Testing软件测试网8Vj6ikEL d3TU
-seconds简写-s :含义是总计的访问时间
准备URL文件:urllist.txt,文件格式是每行一个URL,URL最好超过50-100个测试效果比较好.文件格式
如下:51Testing软件测试网8m3c`(?cD6N
http://www.vpser.net/uncategorized/choose-vps.html
w9no'V(\D0http://www.vpser.net/vps-cp/hypervm-tutorial.html51Testing软件测试网([8OE0HX&q6Nl
http://www.vpser.net/coupons/diavps-april-coupons.html
)}pg4{6FYW%E0http://www.vpser.net/security/vps-backup-web-mysql.html51Testing软件测试网)z0c*k)]!B M$u(Pf
例 如:
http_load -p 30 -s 60  urllist.txt51Testing软件测试网#DH R3` ]5FV
参数了解了,我们来看运行一条命令来看看它的返回结果
a"^!W$mp(Y4HS ~0命 令:% ./http_load -rate 5 -seconds 10 urls说明执行了一个持续时间10秒的测试,每秒的频率为5。
49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds5916 mean bytes/connection4.89274
fetches/sec, 28945.5 bytes/secmsecs/connect: 28.8932 mean, 44.243 max, 24.488 minmsecs/first
-response: 63.5362 mean, 81.624 max, 57.803 minHTTP response codes: code 200 — 49 
结果分析:
a-y0K.{/L"Ln%@n| T{-?01.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
%c:g'rBs:c+j0T}I0说明在上面的测试中运行了49个请求,最大的并发进程数是2,总计传输的数据是289884bytes,运行的时间是 10.0148秒51Testing软件测试网R.Q e)GJ6T
2.5916 mean bytes/connection说明每一连接平均传输的数据量289884/49=591651Testing软件测试网0|6I+M U8u4f F
3.4.89274 fetches/sec, 28945.5 bytes/sec51Testing软件测试网 G'W{lCI0f
说明每秒的响应请求为4.89274,每秒传递的数据为28945.5 bytes/sec
yB-Grx:yB&LvEJ04.msecs/connect: 28.8932 mean, 44.243 max, 24.488 min说明每连接的平均响应时间是28.8932 msecs
,最大的响应时间44.243 msecs,最小的响应时间24.488 msecs
'k4M#Y0m([n:] }05.msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
)r$KA*o\/}^wgo&t06、HTTP response codes: code 200 — 49     说明打开响应页面的类型,如果403的类型过多,那可能
要注意是否系统遇到了瓶颈。
]'a.m'd#h.~C0特殊说明:51Testing软件测试网f)OK.Mn ]
测试结果中主要的指标是 fetches/sec、msecs/connect 这个选项,即服务器每秒能够响应的查询次数,
用这个指标来衡量性能。似乎比 apache的ab准确率要高一些,也更有说服力一些。51Testing软件测试网,I$ADE Gyt|+eO
Qpt-每秒响应用户数和response time,每连接响应用户时间。51Testing软件测试网Q2}a7oB
测试的结果主要也是看这两个值。当然仅有这两个指标并不能完成对性能的分析,我们还需要对服务器的
cpu、men进行分析,才能得出结论
 
二、webbench
webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。下载地址可以到google搜,我 这里给出一个51Testing软件测试网[k8X RW/XYR(AD!q
下载地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
.nY:|5Cz a0这 个程序更小,解压后不到50K,呵呵
2LZ.Rtyq5v*w"]:T0安装非常简单
"uKtJ9zbF ZM0#tar zxvf webbench-1.5.tar.gz
wlS NA#w9B%M0#cd webbench-1.5
D.U5?+\%n ~@OV0#make && make install
r`.|2L0Q0会在当前目录生成webbench可执行文件,直 接可以使用了
用法:
webbench -c 并发数 -t 运行测试时间 URL
3w'IA%~r0N-f0如:
{d1E(qXoU+@0webbench -c 5000 -t 120http://www.vpser.net
三、ab
vD)xrr*a0ab是apache自带的一款功能强大的测试工具
ODz FaF0g0v [0安装了apache一般就自带 了,51Testing软件测试网p~9}\9aF.Fa
用法可以查看它的说明
$ ./ab51Testing软件测试网Hw:S/K:BSZ
./ab: wrong number of arguments
~{B6|I%JWE&m)D(y0Usage: ./ab [options] [http://]hostname[:port]/path
+h]#bV&^1p.p OO6U$Q[0Options are:
D{7y~2F.A?BE0-n requests Number of requests to perform51Testing软件测试网 GH)l8NT
-c concurrency Number of multiple requests to make51Testing软件测试网:A"EG]c"bX
-t timelimit Seconds to max. wait for responses51Testing软件测试网/h3E-[1k{
-p postfile File containing data to POST51Testing软件测试网$E:E$Y!U;c+LO L:~
-T content-type Content-type header for POSTing51Testing软件测试网0n st1`uSzx6G
-v verbosity How much troubleshooting info to print51Testing软件测试网9iO$m y T:C?
-w Print out results in HTML tables
p*BI2`s0-i Use HEAD instead of GET
,FW1?$sn8GsDvx0-x attributes String to insert as table attributes
GL D `1C]|$BU uW3Z'\0-y attributes String to insert as tr attributes
i }0i8v hFs3c0-z attributes String to insert as td or th attributes
&\sm6fsZ7J7rO0-C attribute Add cookie, eg. ‘Apache=1234. (repeatable)
^,Y X7L N0-H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’51Testing软件测试网%o@,re,J6b|
Inserted after all normal header lines. (repeatable)51Testing软件测试网7wy"l ];k5i1NVs
-A attribute Add Basic WWW Authentication, the attributes51Testing软件测试网Rh;|Nz-l v
are a colon separated username and password.
qg]4D6`*x0-P attribute Add Basic Proxy Authentication, the attributes
,TdwfJi0are a colon separated username and password.51Testing软件测试网 o Reb1};~%q
-X proxy:port Proxyserver and port number to use51Testing软件测试网5V3P9N#Z%[ MVb
-V Print version number and exit51Testing软件测试网~B*l2^+yUF
-k Use HTTP KeepAlive feature
n }z+n T0-d Do not show percentiles served table.51Testing软件测试网_D.NP]hM4~
-S Do not show confidence estimators and warnings.
nh;C:N X7uw2e0-g filename Output collected data to gnuplot format file.51Testing软件测试网G_m \eCES}
-e filename Output CSV file with percentages served
3fP*_G5}!r5W!d0-h Display usage information (this message)51Testing软件测试网ky tl${'c a6`
参数众多,一般我们用到的是-n 和-c51Testing软件测试网\oU&P"Z)KZ x;Sit
例如:51Testing软件测试网5wd5`'o9q%Ls
./ab -c 1000 -n 100http://www.vpser.net/index.php
这个表示同时处理1000个请求并运行100次index.php文件.51Testing软件测试网0L)v f;pKl
四、Siege51Testing软件测试网1P/U|(Lm*l
一 款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。51Testing软件测试网W~!E;o~go
官 方:http://www.joedog.org/51Testing软件测试网n/{8y"E"[1TV
Siege 下载:http://soft.vpser.net/test/siege/siege-2.67.tar.gz
8mVb[`M0解 压:
}:OB#`1S0# tar -zxf siege-2.67.tar.gz
gMFfPg8t'{ ec0进入解压目录:
!q#J6Y[x0# cd siege-2.67/
'MS{\%c i0o0安装:51Testing软件测试网E"P:rm[ S
#./configure ; make
~8M}fE/b0#make install
使用51Testing软件测试网Q IQZz%Su^z
siege -c 200 -r 10 -f example.url51Testing软件测试网ib.D5p2PzL
-c是并发量,-r是重复次数。 url文件就是一个文本,每行都是一个url,它会从里面随机访问的。
example.url内容:
结果说明
A#G6QI9k\0Lifting theserversiege… done.
t.J G D G[0Transactions: 3419263 hits //完成419263次处理51Testing软件测试网6is'G5l+s0g-o2~$F
Availability: 100.00 % //100.00 % 成功率
p"Qx4NfZ.}0Elapsed time: 5999.69 secs //总共用时51Testing软件测试网5h({:M&RdU
Data transferred: 84273.91 MB //共数据传输84273.91 MB
nk-YL~$S_k0Response time: 0.37 secs //相应用时1.65秒:显示网络连接的速度51Testing软件测试网z*n%ap |;W
Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次处理:表示服务器后
aL PsgP0Throughput: 14.05 MB/sec //平均每秒传送数据51Testing软件测试网-p`8by-ad
Concurrency: 213.42 //实际最高并发数51Testing软件测试网\F Uo4Fz%c6Z1F
Successful transactions: 2564081 //成功处理次数
A~ U1y K*\@0Failed transactions: 11 //失败处理次数51Testing软件测试网6j@*l4u"S[\yZ3W
Longest transaction: 29.04 //每次传输所花最长时间
%n2nwfY%N!vZ'E0Shortest transaction: 0.00 //每次传输所花最短时间

TAG: webBench http_load webbench ab Siege

msnshow的个人空间 引用 删除 msnshow   /   2011-05-30 22:08:39
这就是步骤啊,看来你不熟悉linux

原帖由导弹贝贝于2011-05-24 14:03:12发表
安 装很简单
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006
#make && make.
导弹贝贝的个人空间 引用 删除 导弹贝贝   /   2011-05-24 14:03:12
安 装很简单
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006
#make && make install


????怎么安装啊
 

评分:0

我来说两句

Open Toolbar