频道栏目
首页 > 资讯 > 工具软件 > 正文

Web性能压力测试工具——Siege详解

16-09-18        来源:[db:作者]  
收藏   我要投稿

PS:Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力。可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行。siege可以从您选择的预置列表中请求随机的URL。所以siege可用于仿真用户请求负载,而ab则不能。但不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多。

解压并安装:

cd /root/

rz

tar -zxvf siege-2.72.tar.gz

cd siege-2.72

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

mkdir -p /usr/local/siege/etc/

mkdir -p /usr/local/siege/var/

make

make install

创建.siegec.config配置文件到当前用户的家目录下

/usr/local/siege/bin/siege.config

安装完成

查看配置文件

/usr/local/siege/bin/siege -C

CURRENT SIEGE CONFIGURATION

JoeDog/1.00 [en] (X11; I; Siege 2.72)

Edit the resource file to change the settings.

----------------------------------------------

version: 2.72

verbose: false

debug: false

protocol: HTTP/1.1

connection: close

concurrent users: 15

time to run: n/a

repetitions: n/a

socket timeout: 30

delay: 1 sec

internet simulation: false

benchmark mode: false

failures until abort: 1024

named URL: none

URLs file: /usr/local/siege/etc/urls.txt

logging: true

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

resource file: /root/.siegerc

timestamped output: false

comma separated output: false

allow redirects: true

allow zero byte data: true

allow chunked encoding: true

proxy auth:

www auth:

参数详解:

-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]

用法举例:

siege -c 300 -r 100 -f url.txt

说明:-c是并发量,-r是重复次数。url.txt就是一个文本文件,每行都是一个url,它会从里面随机访问的。

如图所示:

 

title=siege

 

结果说明:

** SIEGE 2.72

** Preparing 300 concurrent users for battle.

The server is now under siege.. done.

Transactions: 30000 hits //完成30000次处理

Availability: 100.00 % //100.00 % 成功率

Elapsed time: 68.59 secs //总共使用时间

Data transferred: 817.76 MB //共数据传输 817.76 MB

Response time: 0.04 secs //响应时间,显示网络连接的速度

Transaction rate: 437.38 trans/sec //平均每秒完成 437.38 次处理

Throughput: 11.92 MB/sec //平均每秒传送数据

Concurrency: 17.53 //实际最高并发连接数

Successful transactions: 30000 //成功处理次数

Failed transactions: 0 //失败处理次数

Longest transaction: 3.12 //每次传输所花最长时间

Shortest transaction: 0.00 //每次传输所花最短时间

50个用户(每次并发量,注意不是每秒并发量) 重复100次 共产生 50 * 100 = 5000个请求

/usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/fcgi-bin/rs/

50个用户 重复100次 发送GET参数

/usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/fcgi-bin/rs/?name=zhangsan

50个用户 重复100次 发送POST参数 (注意引号)

/usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/fcgi-bin/rs/ POST name=zhangsan

50个用户 重复100次 发送POST参数(从文件中读取)

/usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/fcgi-bin/rs/ POST < /root/ab_test/post.xml

另外还有发送时间参数等

详情请man 或 siege -h

相关TAG标签
上一篇:支付宝“登陆”欧洲实体店 中国游客在德国可手机支付
下一篇:首席惊喜官、首席漂亮官 明星“封官”只是市场推广
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站