一、http_load
E序非常,解压后也不到100K
http_load以ƈ行复用的方式q行Q用以测试web服务器的吞吐量与负蝲。但是它不同于大多数压力试?/p>
P它可以以一个单一的进E运行,一般不会把客户机搞歅R还可以试HTTPScȝ|站h?/p>
下蝲地址Q?a >http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz
安装很简?br />
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006
#make && make install
命o格式Qhttp_load -p q发讉Kq程?nbsp; -s 讉K旉 需要访问的URL文g
参数其实可以自由l合Q参C间的选择q没有什么限制。比如你写成http_load -parallel 5 -seconds
300 urls.txt也是可以的。我们把参数l大家简单说明一下?br /> -parallel ?p Q含义是q发的用戯E数?br /> -fetches ?f Q含义是总计的访问次?br /> -rate ?p Q含义是每秒的访问频?br /> -seconds?s Q含义是总计的访问时?/p>
准备URL文gQurllist.txtQ文件格式是每行一个URLQURL最好超q?0Q?00个测试效果比较好.文g格式
如下Q?br />
http://www.vpser.net/uncategorized/choose-vps.html
http://www.vpser.net/vps-cp/hypervm-tutorial.html
http://www.vpser.net/coupons/diavps-april-coupons.html
http://www.vpser.net/security/vps-backup-web-mysql.html
例如Q?/p>
http_load -p 30 -s 60 urllist.txt
参数了解了,我们来看q行一条命令来看看它的q回l果
命oQ? ./http_load -rate 5 -seconds 10 urls说明执行了一个持l时?0U的试Q每U的频率??/p>
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
l果分析Q?br />
1Q?9 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
说明在上面的试中运行了49个请求,最大的q发q程数是2Q总计传输的数据是289884bytesQ运行的旉?0.0148U?br />
2Q?916 mean bytes/connection说明每一q接q_传输的数据量289884/49=5916
3Q?.89274 fetches/sec, 28945.5 bytes/sec
说明每秒的响应请求ؓ4.89274Q每U传递的数据?8945.5 bytes/sec
4Qmsecs/connect: 28.8932 mean, 44.243 max, 24.488 min说明每连接的q_响应旉?8.8932 msecs
Q最大的响应旉44.243 msecsQ最的响应旉24.488 msecs
5Qmsecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
6、HTTP response codes: code 200 ?49 说明打开响应面的类型,如果403的类型过多,那可?/p>
要注意是否系l遇C瓉?br /> Ҏ(gu)说明Q?br /> 试l果中主要的指标?fetches/sec、msecs/connect q个选项Q即服务器每U能够响应的查询ơ数Q?/p>
用这个指标来衡量性能。似乎比 apache的ab准确率要高一些,也更有说服力一些?br /> Qpt-每秒响应用户数和response timeQ每q接响应用户旉?br /> 试的结果主要也是看q两个倹{当然仅有这两个指标q不能完成对性能的分析,我们q需要对服务器的
cpu、menq行分析Q才能得出结?/p>
二、webbench
webbench是Linux下的一个网站压力测试工P最多可以模?万个q发q接L试网站的负蝲能力。下载地址可以到google搜,我这里给Z?br />
下蝲地址Q?a >http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
q个E序更小Q解压后不到50KQ呵?br />
安装非常?br />
#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install
会在当前目录生成webbench可执行文Ӟ直接可以使用?/p>
用法Q?/p>
webbench -c q发?-t q行试旉 URL
如:
webbench -c 5000 -t 120 http://www.vpser.net
三、ab
ab是apache自带的一Ƒ֊能强大的试工具
安装了apache一般就自带了,
用法可以查看它的说明
$ ./ab
./ab: wrong number of arguments
Usage: ./ab [options] [http://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. ‘Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-h Display usage information (this message)
参数众多Q一般我们用到的?n ?c
例如Q?br />
./ab -c 1000 -n 100 http://www.vpser.net/index.php
q个表示同时处理1000个请求ƈq行100ơindex.php文g.
四、Siege
一Ƒּ源的压力试工具Q可以根据配|对一个WEB站点q行多用Lq发讉KQ记录每个用h有请求过E的相应旉Qƈ在一定数量的q发讉K下重复进行?br />
官方Q?a >http://www.joedog.org/
Siege下蝲Q?a >http://soft.vpser.net/test/siege/siege-2.67.tar.gz
解压Q?br />
# tar -zxf siege-2.67.tar.gz
q入解压目录Q?br />
# cd siege-2.67/
安装Q?br />
#./configure ; make
#make install
使用
siege -c 200 -r 10 -f example.url
-c是ƈ发量Q?r是重复次数?url文g是一个文本,每行都是一个urlQ它会从里面随机讉K的?/p>
example.url内容:
http://www.licess.cn
http://www.vpser.net
http://soft.vpser.net
l果说明
Lifting the server siege… done.
Transactions: 3419263 hits //完成419263ơ处?br />
Availability: 100.00 % //100.00 % 成功?br />
Elapsed time: 5999.69 secs //d用时
Data transferred: 84273.91 MB //共数据传?4273.91 MB
Response time: 0.37 secs //相应用时1.65U:昄|络q接的速度
Transaction rate: 569.91 trans/sec //均每U完?569.91 ơ处理:表示服务器后
Throughput: 14.05 MB/sec //q_每秒传送数?br />
Concurrency: 213.42 //实际最高ƈ发数
Successful transactions: 2564081 //成功处理ơ数
Failed transactions: 11 //p|处理ơ数
Longest transaction: 29.04 //每次传输所花最长时?br />
Shortest transaction: 0.00 //每次传输所花最短时?/p>