siege
- siege官网
- 源码地址
- 核心是以用户为单位进行模拟
- Siege是一款开源的压力测试工具
- Siege设计用于评估WEB应用在压力下的承受能力
- siege可以从您选择的预置列表中请求随机的URL:所以siege可用于仿真用户请求负载,而ab则不能
- 不要使用siege来执行最高性能基准调校测试,这方面ab就准确很多
目前主流包管理都提供在线安装
apt install -y siege
0x1 参数
这里先截取一份帮助文本
root@docker:~# siege --help New configuration template added to /root/.siege Run siege -C to view the current settings in that file 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: /var/log/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.
核心参数如下:
-c
:模拟几个用户-r
:重复测试几次-t
:设定持续测试多久与-r
冲突,单位:-t3600S, -t60M, -t1H.
-d
:设置每个请求之间的延时,默认0.5s-f
:给定一个文件,文件中存放需要测试的url-g
:打印出请求的header
信息,debug专用-H
:指定请求的headers信息-l
:指定测试结果的路径
0x2 使用案例
模拟50个用户对url
http://10.25.153.231/
进行100次测试siege -c 50 -r 100 http://10.25.153.231/
输出结果如下
root@docker:~# siege -c 50 -r 100 http://10.25.153.231/ ** SIEGE 4.0.4 ** Preparing 50 concurrent users for battle. The server is now under siege... Transactions: 35000 hits Availability: 100.00 % Elapsed time: 17.50 secs Data transferred: 510.51 MB Response time: 0.02 secs Transaction rate: 2000.00 trans/sec Throughput: 29.17 MB/sec Concurrency: 49.60 Successful transactions: 35000 Failed transactions: 0 Longest transaction: 0.24 Shortest transaction: 0.00
核心参数如下
Transactions
:传输总数Availability
:服务达成比例Elapsed time
:总耗时Data transferred
:数据传输总量Response time
:响应时间Transaction rate
:传输速率Throughput
:每秒传输的数据量Concurrency
:最高并发Successful transactions
:成功传输总数Failed transactions
:失败的传输Longest transaction
:最长的一次传输时间Shortest transaction
:最短的一次传输时间