Locust参数说明

红太狼 2022-01-30 03:36 452阅读 0赞

因为之前jmeter压测,满足不了高并发压测,为了解决,探索使用locust进行压测,一下为locust的使用文档,使用并总结:

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

  1. > locust --help
  2. Usage: locust [options] [LocustClass [LocustClass2 ... ]]
  3. Options:
  4. -h, --help show this help message and exit
  5. -H HOST, --host=HOST Host to load test in the following format:
  6. http://10.21.32.33
  7. --web-host=WEB_HOST Host to bind the web interface to. Defaults to '' (all
  8. interfaces)
  9. -P PORT, --port=PORT, --web-port=PORT
  10. Port on which to run web host
  11. -f LOCUSTFILE, --locustfile=LOCUSTFILE
  12. Python module file to import, e.g. '../other.py'.
  13. Default: locustfile
  14. --csv=CSVFILEBASE, --csv-base-name=CSVFILEBASE
  15. Store current request stats to files in CSV format.
  16. --master Set locust to run in distributed mode with this
  17. process as master
  18. --slave Set locust to run in distributed mode with this
  19. process as slave
  20. --master-host=MASTER_HOST
  21. Host or IP address of locust master for distributed
  22. load testing. Only used when running with --slave.
  23. Defaults to 127.0.0.1.
  24. --master-port=MASTER_PORT
  25. The port to connect to that is used by the locust
  26. master for distributed load testing. Only used when
  27. running with --slave. Defaults to 5557. Note that
  28. slaves will also connect to the master node on this
  29. port + 1.
  30. --master-bind-host=MASTER_BIND_HOST
  31. Interfaces (hostname, ip) that locust master should
  32. bind to. Only used when running with --master.
  33. Defaults to * (all available interfaces).
  34. --master-bind-port=MASTER_BIND_PORT
  35. Port that locust master should bind to. Only used when
  36. running with --master. Defaults to 5557. Note that
  37. Locust will also use this port + 1, so by default the
  38. master node will bind to 5557 and 5558.
  39. --expect-slaves=EXPECT_SLAVES
  40. How many slaves master should expect to connect before
  41. starting the test (only when --no-web used).
  42. --no-web Disable the web interface, and instead start running
  43. the test immediately. Requires -c and -r to be
  44. specified.
  45. -c NUM_CLIENTS, --clients=NUM_CLIENTS
  46. Number of concurrent Locust users. Only used together
  47. with --no-web
  48. -r HATCH_RATE, --hatch-rate=HATCH_RATE
  49. The rate per second in which clients are spawned. Only
  50. used together with --no-web
  51. -t RUN_TIME, --run-time=RUN_TIME
  52. Stop after the specified amount of time, e.g. (300s,
  53. 20m, 3h, 1h30m, etc.). Only used together with --no-
  54. web
  55. -L LOGLEVEL, --loglevel=LOGLEVEL
  56. Choose between DEBUG/INFO/WARNING/ERROR/CRITICAL.
  57. Default is INFO.
  58. --logfile=LOGFILE Path to log file. If not set, log will go to
  59. stdout/stderr
  60. --print-stats Print stats in the console
  61. --only-summary Only print the summary stats
  62. --no-reset-stats Do not reset statistics once hatching has been
  63. completed
  64. -l, --list Show list of possible locust classes and exit
  65. --show-task-ratio print table of the locust classes' task execution
  66. ratio
  67. --show-task-ratio-json
  68. print json data of the locust classes' task execution
  69. ratio
  70. -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格式存储当前请求测试数据。
—master Locust 分布式模式使用,当前节点为 master 节点。
—slave Locust 分布式模式使用,当前节点为 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_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 no-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-stats Do 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 工具的版本.

发表评论

表情:
评论列表 (有 0 条评论,452人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Locust参数说明

    因为之前jmeter压测,满足不了高并发压测,为了解决,探索使用locust进行压测,一下为locust的使用文档,使用并总结: 打开命令提示符(或Linux终端),输入 `