Web压力测试工具Siege介绍

Siege是我所用过的一款不错的网站压力测试工具,它可以非常容易地定制并发访问人数以及并发时间,安装、使用也非常方便,当然它是在Linux环境下使用的,下面来对它作一个介绍。

官方网址:http://www.joedog.org/

下载网址:ftp://ftp.joedog.org/pub/,进入到ftp://ftp.joedog.org/pub/siege/下载最新版:

siege-2.70.tar.gz


一 siege的安装

安装解压:tar zxvf siege-2.70.tar.gz,进入到解压后的目录:siege-2.70,运行命令:

./configure

make

make install

安装完毕后如果有错误,则按照提示信息处理即可(有可能会出现错误,我安装的时候就报了错,不过有很清楚地提示信息)。

输入:siege –help,如果安装没问题会出现以下类似信息:

SIEGE 2.70

Usage: siege [options]

siege [options] URL

siege -g URL

Options:

-V, –version           VERSION, prints the version number.

-h, –help              HELP, prints this section.

-C, –config            CONFIGURATION, show the current config.

-v, –verbose           VERBOSE, prints notification to screen.

-g, –get               GET, pull down HTTP headers and display the

transaction. Great for application debugging.

-c, –concurrent=NUM    CONCURRENT users, default is 10

-i, –internet          INTERNET user simulation, hits URLs randomly.

-b, –benchmark         BENCHMARK: no delays between requests.

-t, –time=NUMm         TIMED testing where “m” is modifier S, M, or H

ex: –time=1H, one hour test.

-r, –reps=NUM          REPS, number of times to run the test.

-f, –file=FILE         FILE, select a specific URLS FILE.

-R, –rc=FILE           RC, specify an siegerc file

-l, –log[=FILE]        LOG to FILE. If FILE is not specified, the

default is used: PREFIX/var/siege.log

-m, –mark=”text”       MARK, mark the log file with a string.

-d, –delay=NUM         Time DELAY, random delay before each requst

between 1 and NUM. (NOT COUNTED IN STATS)

-H, –header=”text”     Add a header to request (can be many)

-A, –user-agent=”text” Sets User-Agent in request

Copyright (C) 2010 by Jeffrey Fulmer, et al.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.

上面也是运行的一些参数,右边是对一些参数的解释说明

比如:

–C :查看siege当前的配置信息

–V:版权说明信息

–c:并行启动(访问)用户数,默认是10

-t:压力测试时间,比如-t5表示持续时间是5分钟

-r:每个连接发出的请求数量,这个与t有些类似,所以设置了这个值就不需要设置t了,反之亦然。

-f:对应一个文件,这个文件里每一行为一个URL链接,格式如:

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/2010/12/14/2806/

好了,主要的一些参数说明就介绍这么多,其余的可以参考上面的英文。

使用:

1、  启动100个用户(线程)在5分钟内对某一页面www.zihou.me进行并发访问

siege http://www.zihou.me -c200 -t5

2、  对多个页面进行并发访问

新建一个文件urls,里面的内容为(只是例子,任何url都可以):

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/2010/12/14/2806/

siege -f urls -c200 -t5

表示启动200个用户在5分钟内并发访问以上的url网址。

并发测试完毕后,会打印出一些结果信息:

Lifting the server siege…      done.

Transactions:                   7555 hits

Availability:                  99.47 %

Elapsed time:                 299.92 secs

Data transferred:              99.17 MB

Response time:                  7.30 secs

Transaction rate:              25.19 trans/sec

Throughput:                     0.33 MB/sec

Concurrency:                  183.84

Successful transactions:        7555

Failed transactions:              40

Longest transaction:           17.94

Shortest transaction:           0.02

如果在并发的过程中,被访问的页面打开出错或及其缓慢,表示在当前并发条件下,被访问网站是不能承受的,也就是抗并发能力弱。

另外,在并发的过程中最好通过top命令来查看CPU和Memory的占用情况。



二  主要参数介绍:

* -cNUM 设置并发的用户(连接)数量,比如-c10,设置并发10个连接。默认的连接数量可以到~/.siegerc中查看,指令为concurrent = x,前面咱们已经调整了默认并发连接为50。
* -rNUM(repetitions),重复数量,即每个连接发出的请求数量,设置这个的话,就不需要设置-t了。对应.siegerc配置文件中的reps = x指令
* -tNUM(time),持续时间,即测试持续时间,在NUM时间后结束,单位默认为分,比如-t10,那么测试时间为10分钟,-t10s,则测试时间为10秒钟。对应.siegerc中的指令为time = x指令
* -b (benchmark),基准测试,如果设置这个参数的话,那么delay时间为0。在.siegerc中咱们修改为默认开启。
* -f url.txt (file),这是url列表文件。对应.siegerc配置文件中的file = x指令
测试结果分析:
[root@bbs ~]# siege -c 500 -r 50 -f bbs.url
** SIEGE 2.67
** Preparing 500 concurrent users for battle.
The server is now under siege..      done.
Transactions:                  25000 hits
Availability:                 100.00 %
Elapsed time:                  65.52 secs
Data transferred:              83.65 MB
Response time:                  0.57 secs
Transaction rate:             381.56 trans/sec
Throughput:                     1.28 MB/sec
Concurrency:                  216.02
Successful transactions:       21707
Failed transactions:               0
Longest transaction:            5.83
Shortest transaction:           0.00
上面是用500并发重复测试50次bbs.url里的url列表的结果,下面一条一条地分析测试结果:
Transactions: 25000 hits
意思是总共完成了25000次测试
Availability: 100.00 %
测试的有效性100%
Elapsed time: 65.52 secs
用时65.52秒
Data transferred: 83.65 MB
传输了83.65MB数据
Response time: 0.57 secs
响应时间
Transaction rate: 381.56 trans/sec
每秒传输381.56次
Throughput: 1.28 MB/sec
数据吞吐量每秒1.28MB
Concurrency: 216.02
实际并发访问
Successful transactions: 21707
成功的传输
Failed transactions: 0
失败的传输
Longest transaction: 5.83
每次传输所花最长时间
Shortest transaction: 0.00
每次传输所花最短时间

另外,提醒一句,如果你的WEB服务器用的是Apache,请不要将并发数设为大于200。



三、siege的使用说明
举例说明:

50个用户(每次并发量,注意不是每秒并发量) 重复100次 共产生 50 * 100 = 5000个请求
/usr/local/siege/bin/siege -c 50 -r 100  https://www.abc.com/a.php

50个用户 重复100次 发送GET参数
/usr/local/siege/bin/siege -c 50 -r 100  https://www.abc.com/a.php?name=zhangsan

50个用户 重复100次 发送POST参数 (注意引号)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST name=zhangsan"

50个用户 重复100次 发送POST参数(从文件中读取)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST < /root/ab_test/post.xml"

另外还有发送时间参数等
详情请man 或 siege -h

siege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。

常见问题见:http://www.joedog.org/siege-faq/


http://www.zihou.me/html/2011/01/27/2737.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值