1、官网
https://www.joedog.org/
下载
wget http://download.joedog.org/siege/siege-latest.tar.gz
2、安装
解压、安装
tar -zxvf siege-latest.tar.gz
cd siege-*/ #cd siege-4.0.4/
./configure --prefix=/usr/local/siege
make && make install
命令加入系统环境
编辑文件 vim /etc/profile
export PATH=$PATH:/usr/local/siege/bin/
生效 source /etc/profile
3、siege使用
常见参数
-c 指定并发数
-r 指定重复次数
-d 指定请求的延迟时间,注意每个请求间随机延迟
-f 指定url列表,可以一次给多个地址加压
-t 指定用例执行时间,比如-t 10s -t 1M(H)之类
-g 获取请求的headers信息并打印出来,debug专用
-H 指定请求的headers信息
-l或--log=[File] 指定测试结果的路径
实例:
siege -c 19 -t 10s http://127.0.0.1:8501/xxx
siege -c 5 -t 1M -f url.txt
其中 url.txt为多个包含多个测试地址的文件,如
http://ur.tencent.com/categories/7
http://ur.tencent.com/categories/7/?page=2
http://ur.tencent.com/categories/7/?page=3
结果:
Transactions: 1038 hits #事务数(总共测试成功点击次数)(次数)
Availability: 100.00 % #成功率
Elapsed time: 9.13 secs #总耗时
Data transferred: 0.05 MB #数据传输
Response time: 0.16 secs #响应时间
Transaction rate: 113.69 trans/sec #平均每秒处理的事务数TPS(事务数/秒)
Throughput: 0.01 MB/sec #吞吐率(MB/秒)
Concurrency: 18.54 #平均并发数
Successful transactions: 1038 #成功事务数
Failed transactions: 0 #失败事务数
Longest transaction: 0.41 #每次传输所花最长时间
Shortest transaction: 0.00 #每次传输所花最短时间
post参数
发送post请求时,url格式为:http://www.xxxx.com/ POST p1=v1&p2=v2
或将参数存入文件中
siege -c 100 -r 2 'http://127.0.0.1:8501/search/bytoptime POST <./test_stream.txt'
siege -c 100 -r 1 'http://127.0.0.1:8501/search/bytoptime POST deviceId=868661030443279&app_version=2.4.0