Configs2026年4月12日·1 分钟阅读

Locust — Scalable Load Testing in Pure Python

Locust is an open-source load testing tool where you define user behavior in plain Python code. Distributed, scalable, and with a real-time web UI for monitoring. No DSL to learn — just write Python.

介绍

Locust is an open-source load testing tool where you define user behavior in plain Python code. No XML, no DSL — just Python classes and decorators. Features a real-time web UI, distributed testing across multiple machines, and easy CI/CD integration.

What Locust Does

  • Python test scripts — define user behavior as classes
  • Web UI — real-time charts, start/stop, user count control
  • Distributed — master + workers for massive scale
  • Headless mode — for CI/CD
  • CSV/JSON output — export results
  • Custom clients — test gRPC, WebSocket, MQTT, databases
  • Events — hook into test lifecycle
  • Task weighting@task(weight) for traffic distribution

Comparison

Tool Language UI Distributed
Locust Python Web UI Master/worker
k6 JavaScript CLI k6-operator
JMeter Java/GUI Desktop Servers
Vegeta Go CLI No
wrk C CLI No

FAQ

Q: How many concurrent users can it test? A: A single machine handles thousands of users (gevent coroutines); distributed setups easily reach tens of thousands. Not as efficient per-machine as k6, but Python makes scripting more flexible.

Q: Compared to k6? A: Locust uses Python (more flexible, can directly call any Python library); k6 uses JS (Go runtime is more efficient). Pick based on team language preference.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产