WEB压测工具siege用法

WEB压测工具siege用法【备用】
http://www.linuxboy.net/?p=1086
ubuntu下安装:
test@test-Vostro-2421:~$ sudo apt-get install siege
[sudo] password for test:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  chromium-codecs-ffmpeg-extra
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  siege
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 83.0 kB of archives.
After this operation, 263 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main siege amd64 3.0.5-1 [83.0 kB]
Fetched 83.0 kB in 0s (307 kB/s)
Selecting previously unselected package siege.
(Reading database ... 772443 files and directories currently installed.)
Preparing to unpack .../siege_3.0.5-1_amd64.deb ...
Unpacking siege (3.0.5-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up siege (3.0.5-1) ...
test@test-Vostro-2421:~$ siege --help
SIEGE 3.0.5
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.
  -q, --quiet               QUIET turns verbose off and suppresses output.
  -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: /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
  -T, --content-type="text" Sets Content-Type in request

Copyright (C) 2013 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.

test@test-Vostro-2421:~$



siege 版本为2.7
 
./siege -C
查看配置,有用的就三行:
URLs file:                      /root/siege/urls.txt
logging:                        true
log file:                       /root/siege/siege.log
or test@ubuntu:
URLs file:                      /etc/siege/urls.txt
logging:                        true
log file:                       /var/log/siege.log


usrls.txt里面是一条一条的url
http://172.16.23.1/hello
http://172.16.99.2/byebye
 
$ siege -c50 -t60s -f ./urls.txt
并发50,不间断请求60秒
 
$ siege -c1000 -d10 -t5m -f ./urls.txt
并发1000,每次请求间随机等待0-10秒时间,共请求5分钟
    
$ siege -u shemp.whoohoo.com/Admin.jsp -d1 -r10 -c25
 ..Siege 2.65 2006/05/11 23:42:16
 ..Preparing 25 concurrent users for battle.
 The server is now under siege...done
 Transactions:                    250 hits
 Elapsed time:                  14.67 secs
 Data transferred:             448000 bytes
 Response time:                  0.43 secs
 Transaction rate:              17.04 trans/sec
 Throughput:                 30538.51 bytes/sec
 Concurrency:                    7.38
 Status code 200:                 250
 Successful transactions:         250
 Failed transactions:               0


----------------------------------
http://www.2cto.com/kf/201503/385532.html
    Web性能压力测试工具之Siege详解

    2015-03-26      0 个评论    来源:nyist327的专栏   
    收藏    我要投稿

    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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值