【性能测试工具】- Siege

优点:比http_load好用,因为相同的url.txt文件在httpload不好使,所以在易用性上httpload不如siege,仍需进一步调研。

缺点:安装过程中,不能自动创建siege.log文件,需手动创建。

 

概述:

Siege(英文意思是"围攻") 是一个压力测试工具。与http_load类似的是,Siege也是读取urls.txt文件,可以根据配置对一个web站点进行多用户的并发访问,记录每个用户所有请求过程的响应时间,并在一定数量的并发访问下重复进行。这样就比apachebench只能对1个url执行压力测试要占优势。 Siege 支持基本的认证,cookies,HTTP和HTTPS协议。

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

 

安装:

# tar -zxvf siege-2.72.tar.gz
# cd siege-2.72

/siege-2.72#./configure
/siege-2.72# make

/siege-2.72#make install

基本使用:

XXXXXXXXXXXX:~/siege-2.72$ siege -c 5 -r 10 -f urlsdamai.txt                  /*并发5个用户,迭代10次,-f 表示后面是要读取的urls列表*/

** SIEGE 2.72

** Preparing 5 concurrent users for battle.

The server is now under siege..      done.

 

操作结果:

Transactions:                          50 hits                                              /*访问服务器50次,或叫做完成50次处理*/

Availability:                         100.00 %                                                   /*成功率100%*/

Elapsed time:                       8.14 secs                                              /*总共用时8.14秒*/

Data transferred:               5.25 MB                                               /*共数据传输5.25兆*/

Response time:                                  0.19 secs                                /*响应用时0.19秒:显示网络连接的速度*/

Transaction rate:                6.14 trans/sec                                   /*平均每秒完成6.14次处理,服务器端的处理速度*/

Throughput:                         0.65 MB/sec                                       /*平均每秒传输数据0.65兆*/

Concurrency:                       1.15                                                       /*实际最高并发数是1.15个用户*/

Successful transactions:          50                                                 /*成功处理了50个请求*/

Failed transactions:              0                                                      /*失败处理了0个请求*/

Longest transaction:          0.46                                                       /最长的每次处理时间是0.46秒/

Shortest transaction:                      0.11                                         /最短的每次处理时间是0.11秒/

 

FILE: /usr/local/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.

[error] unable to create log file: Permission denied                          /*当非root用户执行了并发的命令之后 siege -c 5 -r 10 -f urlsdamai.txt,siege的log不能够写入“siege.log”文件,原因是这个文件在make && make install的时候并没有创建。所以解决的方式有2个,第1个解决此问题的方式是到“/usr/local/var/”目录内手动建1个“siege.log”,第2个方式是直接切换成root用户,执行后会自动创建这个siege.log 文件*/

 

参数说明:

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           /*测试执行的时间,比如-t 1M是跑60秒*/

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

  -r, --reps=NUM          REPS, number of times to run the test.                                /*迭代次数,不与-t同时使用*/

  -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

 

讨论/疑问:

  • 测试结果里的“Response time”代表什么意思?
  • 结果里的“Concurrency”是什么意思?

 

posted on 2014-08-18 18:33  nashviller  阅读(614)  评论(0编辑  收藏  举报

导航