web压力测试工具Siege使用用法参考及选项参数

Siege是一个多线程的WEB性能测试工具,被设计成可以让WEB开发人员了解代码在长时间压力下的性能.可以模拟很多用户同时访问WEB服务器,此数量可以自由定义.这就相当于web server被围攻(siege)了.

性能指标包括已用时间(elapsed time),总数据传输量(total data transferred),服务器响应时间 (response time),执行率?(transaction rate),并发数(concurrency),每次运行后会生成报告.

siege有三种运行模式:regression,internet simulation,brute force(我们最常用的是internet simulation,模拟用户对网站访问的随机性)

==== 选项如下: ====
”-C,或–config”

在屏幕上打印显示出当前的配置,配置是包括在他的配置文件$HOME/.siegerc中,可以编辑里面的参数,这样每次siege都会按照它运行.

”-v”

运行时能看到详细的运行信息

”-c n,或–concurrent=n”

模拟有n个用户在同时访问,n不要设得太大,因为越大,siege消耗本地机器的资源越多

”-i,–internet”

随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性),当urls.txt存在是有效

”-d n,–delay=n”

hit每个url之间的延迟,在0-n之间

-r n,–reps=n

重复运行测试n次,不能与 -t同时存在

-t n,–time=n

持续运行siege‘n’秒(如10S),分钟(10M),小时(10H)

-l

运行结束,将统计数据保存到日志文件中siege.log,一般位于/usr/local/var/siege.log中,也可在.siegerc中自定义

-R SIEGERC,–rc=SIEGERC

指定用特定的siege配置文件来运行,默认的为$HOME/.siegerc

-f FILE, –file=FILE

指定用特定的urls文件运行siege,默认为urls.txt,位于siege安装目录下的etc/urls.txt

-u URL,–url=URL

测试指定的一个URL,对它进行”siege“,此选项会忽略有关urls文件的设定

urls.txt文件:

是很多行待测试URL的列表以换行符断开,格式为:

[protocol://]host.domain.com[:port][path/to/file]

例如:

http://www.telltruth.net/wiki/index.php
 http://www.telltruth.net/index.html
 http://www.telltruth.net/gallery
 www.telltruth.net/blog

Example:

siege -c 100 -t30M -u http://telltruth.net/
表示对http://telltruth.net/这个站点使用100个用户并发访问,持续30分钟进行测试
注意:”-t30M”之间没有空格

关于作者:
siege的作者:Jeffrey Fulmer <jeff@joedog.org>
官方主页:joedog.org
==== 安装 ====
freebsd:
<code>
pkg_add -r siege
</code>
或者使用ports:
<code>
cd /usr/ports/benchmarks/siege
make
make install
</code>
gentoo:
<code>
emerge siege
</code>

==== .siegerc中几个重要的选项 ====
internet = true | false

true表示对urls.txt中的URL随机访问,以模拟实际的Internet;false表示按urls.txt中的URL列表顺序访问

logging = true|false

选择是否记录结果到日志中

logfile = /home/maxim/log/siege.log

运行结果日志的保存位置

protocol = HTTP/1.0 | HTTP/1.1

选择协议的类型

concurrent = 80

设定有多少用户并发访问
time = n(S|M|H)

持续”siege“多长时间,可以秒,分钟,小时为单位
file = /path/to/urls.txt

设定默认的urls.txt文件位置,使用此选项须确保””url = xxx””无效(注释掉即可)

url = http://xxx.xxx.xxx

只针对某个url进行测试,此选项会使urls.txt的设定无效(-f URLSFILE)

此外,siege还支持很多其他的功能,可以通过proxy测试,也可以测试需要用户身份认证的网页

使用样例:
任务列表: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

from http://hi.baidu.com/webtalk/blog/item/55b93ec78a5474dfd1006086.html

发表评论?

0 条评论。

发表评论