zoukankan      html  css  js  c++  java
  • 【性能测试工具】- 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”是什么意思?
  • 相关阅读:
    单元測试和白盒測试相关总结
    数据结构:图的实现--邻接矩阵
    Android提示版本号更新操作流程
    《集体智慧编程》代码勘误:第六章
    LINUX设备驱动程序笔记(三)字符设备驱动程序
    数学定理证明机械化的中国学派(II)
    《Java并发编程实战》第三章 对象的共享 读书笔记
    Linux系列-安装经常使用软件
    Kubuntu 初始配置
    虚拟互换(virtual swap)
  • 原文地址:https://www.cnblogs.com/musicmovie/p/3920226.html
Copyright © 2011-2022 走看看