Linux下使用Siege对WEB压力测试,siege压力测试Siege说明ab的


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时间为0。man 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。

结果分析


待续...


最早使用的压力测试工具是apache的ab(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 发表于 2004年02月18日下午02時53分


留言


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>


相关内容

    暂无相关文章