HLS压测工具之vegeta
1. MAC安装
brew update && brew install vegeta
2. 构造target.txt
- 创建target.txt文件,内容如下:
GET http://test.hlslive.ks-cdn.com/live/test/index.m3u8
3. 执行vegeta
- 执行:
vegeta attack -targets="target.txt" -rate=100 -duration=60s > res.bin
4. 分析压测数据
- 执行:
vegeta report -inputs=res.bin -reporter=json > res.json
- res.json文件内容如下:
{
"latencies": {
"total": 359117392211,
"mean": 59852898,
"50th": 59660341,
"95th": 60928097,
"99th": 64543074,
"max": 91903437
},
"bytes_in": {
"total": 3406797,
"mean": 567.7995
},
"bytes_out": {
"total": 0,
"mean": 0
},
"earliest": "2017-11-16T20:11:22.808276069+08:00",
"latest": "2017-11-16T20:12:22.798276018+08:00",
"end": "2017-11-16T20:12:22.85826173+08:00",
"duration": 59989999949,
"wait": 59985712,
"requests": 6000,
"rate": 100.01666952993583,
"success": 1,
"status_codes": {
"200": 6000
},
"errors": null
}
从json文件可以看出来,6000个http请求全部请求成功。
5. 分析压测数据之响应时间
- 执行:
cat res.bin | vegeta report -reporter='hist[0,40ms,100ms,200ms,600ms,1000ms,2000ms]'
响应如下:
Bucket # % Histogram
[0s, 40ms] 0 0.00%
[40ms, 100ms] 6000 100.00% ###########################################################################
[100ms, 200ms] 0 0.00%
[200ms, 600ms] 0 0.00%
[600ms, 1s] 0 0.00%
[1s, 2s] 0 0.00%
[2s, +Inf] 0 0.00%
从数据中可以看出,所有请求的响应时间都是在40ms - 100ms以内。