Web压力测试工具Siege

来源:互联网 发布:python assert 用法 编辑:程序博客网 时间:2024/06/07 16:32

Siege是我所用过的一款不错的网站压力测试工具,它可以非常容易地定制并发访问人数以及并发时间,安装、使用也非常方便,当然它是在Linux环境下使用的 官方网址:http://www.joedog.org/

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

./configure

make

make install

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

修改siege配置文件
  # vi ~/.siegerc 
  回车后,siege的配置文件显示出来,将要修改的关键字进行修改
  主要修改
verbose=false
concurrent=50
delay
=1
internet
=true
benchmark
=true

输入: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网址。

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

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。

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

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



0 0
原创粉丝点击