当前位置: 首页 > news >正文

Locust no-web 模式与参数详解

 

读前参考:《性能测试工具Locust 》

熟悉 Apache ab 工具的同学都知道,它是没有界面的,通过命令行执行。 Locust 同样也提供的命令行运行,好处就是更节省客户端资源。

命令行运行 Locust 测试


以上一节的 baidu 首页测试(load_test.py)为例 通过 no-web 模式运行测试。

> locust -f load_test.py --host=https://www.baidu.com --no-web -c 10 -r 2 -t 1m

[2017-10-30 22:17:30,292] DESKTOP-SMGQBBM/INFO/locust.main: Run time limit set to 60 seconds
[2017-10-30 22:17:30,302] DESKTOP-SMGQBBM/INFO/locust.main: Starting Locust 0.8
[2017-10-30 22:17:30,302] DESKTOP-SMGQBBM/INFO/locust.runners: Hatching and swarming 10 clients at the rate 2 clients/s...
 Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s

....


 [2017-10-30 22:18:30,301] DESKTOP-SMGQBBM/INFO/locust.main: Time limit reached. Stopping Locust.
 [2017-10-30 22:18:30,302] DESKTOP-SMGQBBM/INFO/locust.main: Shutting down (exit code 0), bye.
  Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s
 --------------------------------------------------------------------------------------------------------------------------------------------
  GET /                                                            117     0(0.00%)      31      17      96  |      28    2.10
 --------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                            117     0(0.00%)                                       2.10

 Percentage of the requests completed within given times
  Name                                                           # reqs    50%    66%    75%    80%    90%    95%    98%    99%   100%
 --------------------------------------------------------------------------------------------------------------------------------------------
  GET /                                                             117     28     30     36     37     49     62     69     72     96
 --------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                             117     28     30     36     37     49     62     69     72     96

启动参数:

–no-web 表示不使用Web界面运行测试。

-c 设置虚拟用户数。

-r 设置每秒启动虚拟用户数。

-t 设置设置运行时间。

 

Locust 参数


打开命令提示符(或Linux终端),输入 locust --help 。

> locust --help
Usage: locust [options] [LocustClass [LocustClass2 ... ]]

Options:
  -h, --help            show this help message and exit
  -H HOST, --host=HOST  Host to load test in the following format:
                        http://10.21.32.33
  --web-host=WEB_HOST   Host to bind the web interface to. Defaults to '' (all
                        interfaces)
  -P PORT, --port=PORT, --web-port=PORT
                        Port on which to run web host
  -f LOCUSTFILE, --locustfile=LOCUSTFILE
                        Python module file to import, e.g. '../other.py'.
                        Default: locustfile
  --csv=CSVFILEBASE, --csv-base-name=CSVFILEBASE
                        Store current request stats to files in CSV format.
  --master              Set locust to run in distributed mode with this
                        process as master
  --slave               Set locust to run in distributed mode with this
                        process as slave
  --master-host=MASTER_HOST
                        Host or IP address of locust master for distributed
                        load testing. Only used when running with --slave.
                        Defaults to 127.0.0.1.
  --master-port=MASTER_PORT
                        The port to connect to that is used by the locust
                        master for distributed load testing. Only used when
                        running with --slave. Defaults to 5557. Note that
                        slaves will also connect to the master node on this
                        port + 1.
  --master-bind-host=MASTER_BIND_HOST
                        Interfaces (hostname, ip) that locust master should
                        bind to. Only used when running with --master.
                        Defaults to * (all available interfaces).
  --master-bind-port=MASTER_BIND_PORT
                        Port that locust master should bind to. Only used when
                        running with --master. Defaults to 5557. Note that
                        Locust will also use this port + 1, so by default the
                        master node will bind to 5557 and 5558.
  --expect-slaves=EXPECT_SLAVES
                        How many slaves master should expect to connect before
                        starting the test (only when --no-web used).
  --no-web              Disable the web interface, and instead start running
                        the test immediately. Requires -c and -r to be
                        specified.
  -c NUM_CLIENTS, --clients=NUM_CLIENTS
                        Number of concurrent Locust users. Only used together
                        with --no-web
  -r HATCH_RATE, --hatch-rate=HATCH_RATE
                        The rate per second in which clients are spawned. Only
                        used together with --no-web
  -t RUN_TIME, --run-time=RUN_TIME
                        Stop after the specified amount of time, e.g. (300s,
                        20m, 3h, 1h30m, etc.). Only used together with --no-
                        web
  -L LOGLEVEL, --loglevel=LOGLEVEL
                        Choose between DEBUG/INFO/WARNING/ERROR/CRITICAL.
                        Default is INFO.
  --logfile=LOGFILE     Path to log file. If not set, log will go to
                        stdout/stderr
  --print-stats         Print stats in the console
  --only-summary        Only print the summary stats
  --no-reset-stats      Do not reset statistics once hatching has been
                        completed
  -l, --list            Show list of possible locust classes and exit
  --show-task-ratio     print table of the locust classes' task execution
                        ratio
  --show-task-ratio-json
                        print json data of the locust classes' task execution
                        ratio
  -V, --version         show program's version number and exit

 

参数说明:

参数说明
-h, –help查看帮助
-H HOST, –host=HOST指定被测试的主机,采用以格式:http://10.21.32.33
–web-host=WEB_HOST指定运行 Locust Web 页面的主机,默认为空 “。
-P PORT, –port=PORT, –web-port=PORT指定 –web-host 的端口,默认是8089
-f LOCUSTFILE, –locustfile=LOCUSTFILE指定运行 Locust 性能测试文件,默认为: locustfile.py
–csv=CSVFILEBASE, –csv-base-name=CSVFILEBASE以CSV格式存储当前请求测试数据。
–masterLocust 分布式模式使用,当前节点为 master 节点。
–slaveLocust 分布式模式使用,当前节点为 slave 节点。
–master-host=MASTER_HOST分布式模式运行,设置 master 节点的主机或 IP 地址,只在与 –slave 节点一起运行时使用,默认为:127.0.0.1.
–master-port=MASTER_PORT分布式模式运行, 设置 master 节点的端口号,只在与 –slave 节点一起运行时使用,默认为:5557。注意,slave 节点也将连接到这个端口+1 上的 master 节点。
–master-bind-host=MASTER_BIND_HOSTInterfaces (hostname, ip) that locust master should bind to. Only used when running with –master. Defaults to * (all available interfaces).
–master-bind-port=MASTER_BIND_PORTPort that locust master should bind to. Only used when running with –master. Defaults to 5557. Note that Locust will also use this port + 1, so by default the master node will bind to 5557 and 5558.
–expect-slaves=EXPECT_SLAVESHow many slaves master should expect to connect before starting the test (only when –no-web used).
–no-webno-web 模式运行测试,需要 -c 和 -r 配合使用.
-c NUM_CLIENTS, –clients=NUM_CLIENTS指定并发用户数,作用于 –no-web 模式。
-r HATCH_RATE, –hatch-rate=HATCH_RATE指定每秒启动的用户数,作用于 –no-web 模式。
-t RUN_TIME, –run-time=RUN_TIME设置运行时间, 例如: (300s, 20m, 3h, 1h30m). 作用于 –no-web 模式。
-L LOGLEVEL, –loglevel=LOGLEVEL选择 log 级别(DEBUG/INFO/WARNING/ERROR/CRITICAL). 默认是 INFO.
–logfile=LOGFILE日志文件路径。如果没有设置,日志将去 stdout/stderr
–print-stats在控制台中打印数据
–only-summary只打印摘要统计
–no-reset-statsDo not reset statistics once hatching has been completed。
-l, –list显示测试类, 配置 -f 参数使用
–show-task-ratio打印 locust 测试类的任务执行比例,配合 -f 参数使用.
–show-task-ratio-json以 json 格式打印 locust 测试类的任务执行比例,配合 -f 参数使用.
-V, –version查看当前 Locust 工具的版本.

 

个别参数,我没用过,也太清楚其含义,暂时就不翻译了。

相关文章:

  • 我所理解的Remoting (2) :远程对象的生命周期管理[下篇]
  • windows 10、8.1、7 用户自动登陆,避免输入密码登陆的注册表项:
  • 北京航空航天大学王田苗教授:人工智能与机器人前沿科技发展与投资布局
  • YYHS-猜数字(并查集/线段树维护)
  • Linux链接文件
  • js跳出循环
  • 难以避免的泄漏事故:怎么解?
  • python 基础 4.5 用函数实现九九乘法表
  • html回顾随笔1(*^__^*)
  • Java新版本的开发已正式进入轨道,版本号18.3
  • npm cli 调试方法
  • socket接受大的数据
  • redis开启远程访问
  • AE与AO的区别
  • Java 并发集合的实现原理
  • CSS中外联样式表代表的含义
  • ES6系统学习----从Apollo Client看解构赋值
  • Java多态
  • java多线程
  • java概述
  • JAVA之继承和多态
  • Mysql5.6主从复制
  • TypeScript迭代器
  • yii2权限控制rbac之rule详细讲解
  • 编写符合Python风格的对象
  • 创建一种深思熟虑的文化
  • 回顾2016
  • 前端路由实现-history
  • 我看到的前端
  • 源码之下无秘密 ── 做最好的 Netty 源码分析教程
  • 怎样选择前端框架
  • Semaphore
  • ​Distil-Whisper:比Whisper快6倍,体积小50%的语音识别模型
  • #define、const、typedef的差别
  • #鸿蒙生态创新中心#揭幕仪式在深圳湾科技生态园举行
  • (2)(2.4) TerraRanger Tower/Tower EVO(360度)
  • (2)STM32单片机上位机
  • (C++17) optional的使用
  • (delphi11最新学习资料) Object Pascal 学习笔记---第7章第3节(封装和窗体)
  • (javascript)再说document.body.scrollTop的使用问题
  • (Redis使用系列) Springboot 使用Redis+Session实现Session共享 ,简单的单点登录 五
  • (黑客游戏)HackTheGame1.21 过关攻略
  • (转)VC++中ondraw在什么时候调用的
  • (转)真正的中国天气api接口xml,json(求加精) ...
  • .NET 的程序集加载上下文
  • .net6解除文件上传限制。Multipart body length limit 16384 exceeded
  • .NetCore项目nginx发布
  • .net生成的类,跨工程调用显示注释
  • @Async注解的坑,小心
  • @Bean有哪些属性
  • @EventListener注解使用说明
  • [ 渗透测试面试篇 ] 渗透测试面试题大集合(详解)(十)RCE (远程代码/命令执行漏洞)相关面试题
  • [120_移动开发Android]008_android开发之Pull操作xml文件
  • [2024] 十大免费电脑数据恢复软件——轻松恢复电脑上已删除文件
  • [AI]文心一言爆火的同时,ChatGPT带来了这么多的开源项目你了解吗