压力测试工具Siege安装与使用

安装 (本案例介绍mac环境)

brew search siege  #搜索
brew install siege #安装
siege -V #查看是否安装成功

SIEGE 4.0.4  #(表示安装成功)
Copyright (C) 2017 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.

使用说明

siege -h
SIEGE 4.0.4
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.
  -p, --print               PRINT, like GET only it prints the entire page.
  -c, --concurrent=NUM      CONCURRENT users, default is 10
  -r, --reps=NUM            REPS, number of times to run the test.
  -t, --time=NUMm           TIMED testing where "m" is modifier S, M, or H
                            ex: --time=1H, one hour test.
  -d, --delay=NUM           Time DELAY, random delay before each requst
  -b, --benchmark           BENCHMARK: no delays between requests.
  -i, --internet            INTERNET user simulation, hits URLs randomly.
  -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.
                            between .001 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
      --no-parser           NO PARSER, turn off the HTML page parser
      --no-follow           NO FOLLOW, do not follow HTTP redirects

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

案例一:

siege -c 100 -r 2 http://127.0.0.1:9975/test

参数说明: -c 是并发量,并发数为100人(默认10) -r 是重复次数, 重复2次

案例二:随机选取txt文件中的列出的所有网址

https://blog.zhizubaba.com
https://www.zhizubaba.com
https://taoke.zhizubaba.com
siege -c 100 -r 2 -f url.txt

参数说明: -c 是并发量,并发数为100人 -r 是重复次数, 重复2次 ,-f 指定文件路径及名称,url.txt文本文件(每行都是一个url),会从里面随机访问

案例三:模拟POST/GET请求

https://blog.zhizubaba.com POST page=1&type=2
siege -c 100 -r 2 -f url.txt
Transactions:                200 hits  #(处理次数,本次处理了500此请求)
Availability:             100.00 %  #(可用性/成功次数的百分比,比如本次100%成功)
Elapsed time:             114.00 secs  #(运行时间,本次总消耗36.67秒)
Data transferred:           0.00 MB  #(数据传送量)
Response time:             42.86 secs  #(响应时间)
Transaction rate:           1.75 trans/sec   #(处理请求频率,每秒钟处理8.89次请求)
Throughput:             0.00 MB/sec  #(吞吐量,传输速度)
Concurrency:               75.20  #(实际最高并发连接数)
Successful transactions:         200  #(成功的传输次数)
Failed transactions:               0  #(失败的传输次数)
Longest transaction:           59.38  #(处理传输是所花的最长时间)
Shortest transaction:           2.49  #(处理传输是所花的最短时间)
鲁ICP备16017569号-2