Mac OS X下压力测试工具Siege安装与使用

安装:

brew siege

查看安装是否成功:

安装路径:
$ which siege
/usr/local/bin/siege

版本:
$ siege -V
SIEGE 4.0.2

参数说明:

$ siege -h
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
  -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

查看当前配置:

$ siege -C

使用一:

$ siege -c 50 -r 10 https://news.gnyy.co

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

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

url.txt

https://news.gnyy.co
https://www.gnyyy.cn
https://8jieke.com
siege -c 5 -r 10 -f url.txt

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

使用三:模拟POST/GET请求

url.txt

# URL (POST):
https://news.gnyy.co/index.php POST uid=yudis&sign=liud
siege -c 5 -r 10 -f url.txt

结果说明:

$ siege -c 50 -r 10 -d 5 https://8jieke.com

/ /请求http://8jieke.com,并发人数为50,重复10次,每次请求间隔5秒

 

Transactions: 500 hits (处理次数,本次处理了500此请求)
Availability: 100.00 % (可用性/成功次数的百分比,比如本次100%成功)
Elapsed time: 36.67 secs (运行时间,本次总消耗36.67秒)
Data transferred: 0.32 MB (数据传送量)
Response time: 0.31 secs (响应时间)
Transaction rate: 13.64 trans/sec (处理请求频率,每秒钟处理8.89次请求)
Throughput: 0.01 MB/sec (吞吐量,传输速度)
Concurrency: 4.21 (实际最高并发连接数)
Successful transactions: 500 (成功的传输次数)
Failed transactions: 0 (失败的传输次数)
Longest transaction: 2.74 (处理传输是所花的最长时间)
Shortest transaction: 0.17 (处理传输是所花的最短时间)

posted @ 2016-12-22 15:22  yudis  阅读(1166)  评论(0编辑  收藏  举报