artillery 学习一 简单使用

artillery 是一个不错的负载测试套件,功能很强大,支持多协议

安装

npm install -g artillery --unsafe-perm

运行一个简单的快速测试

artillery quick --count 10 -n 20 https://artillery.io/

效果

artillery quick --count 10 -n 20 https://artillery.io/
 
Started phase 0, duration: 1s @ 09:14:49(+0800) 2019-09-11
Report @ 09:14:59(+0800) 2019-09-11
Elapsed time: 10 seconds
  Scenarios launched: 10
  Scenarios completed: 2
  Requests completed: 165
  RPS sent: 17.38
  Request latency:
    min: 198.8
    max: 2113.4
    median: 211.1
    p95: 1057.8
    p99: 1920.7
  Codes:
    200: 165
Report @ 09:15:09(+0800) 2019-09-11
Elapsed time: 20 seconds
  Scenarios launched: 0
  Scenarios completed: 3
  Requests completed: 23
  RPS sent: 2.24
  Request latency:
    min: 205.1
    max: 2057.3
    median: 211.7
    p95: 1348.8
    p99: 2057.3
  Codes:
    200: 23
Report @ 09:15:19(+0800) 2019-09-11
Elapsed time: 30 seconds
  Scenarios launched: 0
  Scenarios completed: 4
  Requests completed: 11
  RPS sent: 0.82
  Request latency:
    min: 200.3
    max: 13235.8
    median: 268
    p95: 13231.4
    p99: 13235.8
  Codes:
    200: 11
Report @ 09:15:20(+0800) 2019-09-11
Elapsed time: 31 seconds
  Scenarios launched: 0
  Scenarios completed: 1
  Requests completed: 1
  RPS sent: NaN
  Request latency:
    min: 1081.2
    max: 1081.2
    median: 1081.2
    p95: 1081.2
    p99: 1081.2
  Codes:
    200: 1
All virtual users finished
Summary report @ 09:15:20(+0800) 2019-09-11
  Scenarios launched: 10
  Scenarios completed: 10
  Requests completed: 200
  RPS sent: 6.46
  Request latency:
    min: 198.8
    max: 13235.8
    median: 211.7
    p95: 1231.8
    p99: 12564.4
  Scenario counts:
    0: 10 (100%)
  Codes:
    200: 200
 

测试脚本方式运行

  • yaml 定义文件
    app.yaml
config:
  target: 'https://artillery.io'
  phases:
    - duration: 60
      arrivalRate: 20
  defaults:
    headers:
      x-my-service-auth: '987401838271002188298567'
scenarios:
  - flow:
    - get:
        url: "/docs"
  • 运行
artillery run app.yaml -o stats.json

效果:
同上

  • 生成报表
artillery report stats.json

效果

 

参考资料

https://artillery.io/docs/cli-reference/
https://github.com/artilleryio/artillery

posted @ 2021-08-05 17:58  陈晓猛  阅读(329)  评论(0编辑  收藏  举报