随笔-62  评论-29  文章-0  trackbacks-0
 

Siege(英文意思是围攻)是一个压力测试和评测工具,设计用于WEB开发这评估应用在压力下的承受能力:可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。

Siege 

说明

ab的主要弱点在于它不能让你模拟一个更加真实的请求分布——例如你想通过设置一个请求的列表来在这些列表之间来回测试,而siege就可以。

安装

siege需要自己从http://www.joedog.org/上自己下载,然后编译:

./configure --prefix=/usr/local/siege  --mandir=/usr/local/man

make

# 转到超级用户

make install

注意在configure的时候,一定要设置mandir参数,否则当你通过 man siege查看siege帮助的时候会看不到他的manual.

安装完成后,运行bin中的siege_config命令来创建.siege文件之后,你可以通过

./siege -C

命令来查看当前配置

最简单的使用命令:

./siege http://localhost/

#用来测试本地主页

参数介绍

  • -cNUM

设置并发的用户(连接)数量. 默认的连接数量可以到~/.siegerc中查看,指令为concurrent = x。比如-c10,设置并发10个连接

  • -rNUM

repetitions),重复数量,即每个连接发出的请求数量,设置这个的话,就不需要设置-t了。对应.siegerc配置文件中的reps = x指令

  • -tNUM

time),持续时间,即测试持续时间,在NUM时间后结束,单位默认为分,比如-t10,那么测试时间为10分钟,-t10s,则测试时间为10秒钟。对应.siegerc中的指令为time = x指令

  • -b

(benchmark),基准测试,如果设置这个参数的话,那么delay时间为0man siege中有一句话这样说:

it's not recommanded that you use this option while load testing.

说明基准测试和load testing 是完全不同的,至于有什么不同,可以阅读BenchMarkingVSLoadTestingVSPerformance.

  • -f url.txt

(file),这是文件。对应.siegerc配置文件中的file = x指令

  • 其他比较关注的测试方法,比如我想使用Keep-Alive方式进行测试,可以在.siegerc配置文件中进行修改,将connect = close改为 connect = keep-alive
  • 另外您还可以通过-H HEADER参数来设置请求header

结果分析

待续...

最早使用的压力测试工具是apacheab(apache benchmark)apache ab做重复压力测试不错,但是每次只能测试一个链接,如何测试一组链接(比如从日志中导出的1个小时的日志,做真实压力测试),后来找到了这个:
Siege
是一个压力测试和评测工具,设计用于WEB开发这评估应用在压力下的承受能力:可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。
SIEGE is an http regressive testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress, to see how it will stand up to load on the internet. It lets the user hit a webserver with a configurable number of concurrent simulated users. Those users place the webserver "under siege." The duration of the siege is measured in transactions, the sum of simulated users and the number of times each simulated user repeats the process of hitting the server. Thus 20 concurrent users 50 times is 1000 transactions, the length of the test.

下载/安装
Siege
时一个开放源代码项目:http://www.joedog.org/siege/

下载:
wget ftp://sid.joedog.org/pub/siege/siege-latest.tar.gz

安装:
%./configure ; make
#make install

siege包含了一组压力测试工具:
SIEGE (1) Siege
是一个HTTP压力测试和评测工具.
使用样例:
任务列表:www.chedong.com.url文件
http://www.chedong.com/tech/
http://www.chedong.com/tech/acdsee.html
http://www.chedong.com/tech/ant.html
http://www.chedong.com/tech/apache_install.html
http://www.chedong.com/tech/awstats.html
http://www.chedong.com/tech/cache.html
http://www.chedong.com/tech/click.html
http://www.chedong.com/tech/cms.html
http://www.chedong.com/tech/compress.html
http://www.chedong.com/tech/cvs_card.html
http://www.chedong.com/tech/default.html
http://www.chedong.com/tech/dev.html
http://www.chedong.com/tech/gnu.html
....

siege -c 20 -r 2 -f www.chedong.com.url
参数说明:
-c 20
并发20个用户
-r 2
重复循环2
-f www.chedong.com.url
任务列表:URL列表

输出样例:

** Siege 2.59
** Preparing 20 concurrent users for battle.
这次战斗准备了20个并发用户
The server is now under siege.. done.
服务在围攻测试中:
Transactions: 40 hits
完成40次处理
Availability: 100.00 %
成功率
Elapsed time: 7.67 secs
总共用时
Data transferred: 877340 bytes
共数据传输:877340字节
Response time: 1.65 secs
相应用时1.65秒:显示网络连接的速度
Transaction rate: 5.22 trans/sec
平均每秒完成5.22次处理:表示服务器后台处理的速度
Throughput: 114385.92 bytes/sec
平均每秒传送数据:114385.92字节
Concurrency: 8.59
最高并发数 8.59
Successful transactions: 40
成功处理次数
Failed transactions: 0
失败处理次数

注意:由于速度很快,可能会达不到并发速度很高就已经完成。Response time显示的是测试机器和被测试服务器之间网络链接状况。Transaction rate则表示服务器端任务处理的完成速度。

辅助工具:
增量压力测试:

为了方便增量压力测试,siege还包含了一些辅助工具:
bombardment (1)
是一个辅助工具:用于按照增量用户压力测试:
使用样例:
bombardment urlfile.txt 5 3 4 1
初始化URL列表:urlfile.txt
初始化为:5个用户
每次增加:3个用户
运行:4
每个客户端之间的延迟为:1

输出成CSV格式:
siege2csv.pl (1)
siege2csv.pl
bombardment的输出变成CSV格式:
Time Data Transferred Response Time Transaction Rate Throughput Concurrency Code 200 (note that this is horribly broken.)
242 60.22 603064 0.02 4.02 10014.35 0.08
605 59.98 1507660 0.01 10.09 25136.05 0.12
938 59.98 2337496 0.02 15.64 38971.26 0.26
1157 60 2883244 0.04 19.28 48054.07 0.78

参考:
开源测试工具:http://www.opensourcetesting.org/performance.php

[technorati relative tag]

[相关内容]

tristones 发表于 20040218下午0253

留言

SIEGE测试于目标网站的网页动态静态没有关系,只要任务列表是动态网页即可。即使是需要认证的,也可以通过预先设置POST HEADER等方式模拟登录。

done.

Transactions:                    455 hits

Availability:                  75.83 %

Elapsed time:                  85.45 secs

Data transferred:            4097.30 MB

Response time:                 11.32 secs

Transaction rate:               5.32 trans/sec

Throughput:                    47.95 MB/sec

Concurrency:                   60.30

Successful transactions:         455

Failed transactions:             145

Longest transaction:           53.61

Shortest transaction:           0.80

FILE: /usr/local/siege/var/siege.log

You can disable this annoying message by editing

the .siegerc file in your home directory; change

the directive 'show-logfile' to false.

[root@localhost bin]# ./siege -c 300 -r 2 -f /work/siege/siege.txt;

cat /usr/local/siege/var/siege.log

      Date & Time, Trans, Elap Time, Data Trans, Resp Time, Trans Rate, Throughput, Concurrent,    OKAY,   Failed

2009-06-02 13:33:21,    455,      85.45,        4097,      11.32,        5.32,       47.95,       60.30,     455,     145

done.

Transactions:                    192 hits

Availability:                  96.00 %

Elapsed time:                  78.64 secs

Data transferred:               0.09 MB

Response time:                  5.13 secs

Transaction rate:               2.44 trans/sec

Throughput:                     0.00 MB/sec

Concurrency:                   12.53

Successful transactions:         192

Failed transactions:               8

Longest transaction:           51.85

Shortest transaction:           1.14

FILE: /usr/local/siege/var/siege.log

You can disable this annoying message by editing

the .siegerc file in your home directory; change

the directive 'show-logfile' to false.

[root@localhost bin]# ./siege -c 100 -r 2 -f /work/siege/url.txt;


http://211.139.163.252/lsp/leService.do POST < /work/siege/data.txt

<?xml version="1.0" encoding="GBK"?><!DOCTYPE svc_init SYSTEM "MLP_SVC_INIT_320.DTD"><svc_init ver="3.2.0"><hdr ver="3.2.0"><client><id>1001</id><pwd>1001</pwd></client></hdr><slir ver="2.0.0" res_type="SYNC"><msids><msid>8613501502020</msid><msid>8613602887904</msid></msids><loc_type type="CURRENT_OR_LAST" /><prio type="NORMAL" /><req_result type="AREA_CODE" /></slir></svc_init>



 

Web服务器性能/压力测试工具http_loadwebbenchabSiege使用教程

20090414 10:16 | 作者:licess

一、http_load

程序非常小,解压后也不到100K

http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载。但是它不同于大多数压力测试工

具,它可以以一个单一的进程运行,一般不会把客户机搞死。还可以测试HTTPS类的网站请求。

下载地址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz
安装很简单
#tar zxvf http_load-12mar2006.tar.gz
#cd http_load-12mar2006
#make && make install

命令格式:http_load  -p 并发访问进程数  -s 访问时间  需要访问的URL文件

参数其实可以自由组合,参数之间的选择并没有什么限制。比如你写成http_load -parallel 5 -seconds

300 urls.txt也是可以的。我们把参数给大家简单说明一下。
-parallel
简写-p :含义是并发的用户进程数。
-fetches
简写-f :含义是总计的访问次数
-rate   
简写-p :含义是每秒的访问频率
-seconds
简写-s :含义是总计的访问时间

准备URL文件:urllist.txt,文件格式是每行一个URLURL最好超过50100个测试效果比较好.文件格式

如下:
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
例如:

http_load -p 30 -s 60  urllist.txt
参数了解了,我们来看运行一条命令来看看它的返回结果
命令:% ./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 

结果分析:
1
49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
说明在上面的测试中运行了49个请求,最大的并发进程数是2,总计传输的数据是289884bytes,运行的时间是10.0148
2
5916 mean bytes/connection说明每一连接平均传输的数据量289884/49=5916
3
4.89274 fetches/sec, 28945.5 bytes/sec
说明每秒的响应请求为4.89274,每秒传递的数据为28945.5 bytes/sec
4
msecs/connect: 28.8932 mean, 44.243 max, 24.488 min说明每连接的平均响应时间是28.8932 msecs

,最大的响应时间44.243 msecs,最小的响应时间24.488 msecs
5
msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
6
HTTP response codes: code 200 — 49     说明打开响应页面的类型,如果403的类型过多,那可能

要注意是否系统遇到了瓶颈。
特殊说明:
测试结果中主要的指标是 fetches/secmsecs/connect 这个选项,即服务器每秒能够响应的查询次数,

用这个指标来衡量性能。似乎比 apacheab准确率要高一些,也更有说服力一些。
Qpt-
每秒响应用户数和response time,每连接响应用户时间。
测试的结果主要也是看这两个值。当然仅有这两个指标并不能完成对性能的分析,我们还需要对服务器的

cpumen进行分析,才能得出结论

 

二、webbench

webbenchLinux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。下载地址可以到google搜,我这里给出一个
下载地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
这个程序更小,解压后不到50K,呵呵
安装非常简单
#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install
会在当前目录生成webbench可执行文件,直接可以使用了

用法:

webbench -c 并发数 -t 运行测试时间 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)
参数众多,一般我们用到的是-n -c
例如:
./ab -c 1000 -n 100 http://www.vpser.net/index.php

这个表示同时处理1000个请求并运行100index.php文件.
四、Siege
一款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。
官方:http://www.joedog.org/
Siege
下载:http://soft.vpser.net/test/siege/siege-2.67.tar.gz
解压:
# tar -zxf siege-2.67.tar.gz
进入解压目录:
# cd siege-2.67/
安装:
#./configure ; make
#make install

使用
siege -c 200 -r 10 -f example.url
-c
是并发量,-r是重复次数。 url文件就是一个文本,每行都是一个url,它会从里面随机访问的。

example.url内容:

http://www.licess.cn
http://www.vpser.net
http://soft.vpser.net

结果说明
Lifting the server siege… done.
Transactions: 3419263 hits //
完成419263次处理
Availability: 100.00 % //100.00 %
成功率
Elapsed time: 5999.69 secs //
总共用时
Data transferred: 84273.91 MB //
共数据传输84273.91 MB
Response time: 0.37 secs //
相应用时1.65秒:显示网络连接的速度
Transaction rate: 569.91 trans/sec //
均每秒完成 569.91 次处理:表示服务器后
Throughput: 14.05 MB/sec //
平均每秒传送数据
Concurrency: 213.42 //
实际最高并发数
Successful transactions: 2564081 //
成功处理次数
Failed transactions: 11 //
失败处理次数
Longest transaction: 29.04 //
每次传输所花最长时间
Shortest transaction: 0.00 //
每次传输所花最短时间



posted on 2009-06-02 14:01 阅读(7155) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: