API Reference
Locust
A scalable load testing tool written in Python where user behavior is defined as plain Python code.
Official Documentation ↗CompatibilityThis documentation covers version
v2.20. Check the official docs for the latest API surface.Installation
pip
pip install locustMethods
No methods match this filter.
Locust runs swarms of simulated users in greenlets and reports request statistics live.
Key Features
- User behavior defined as Python
- Distributed load generation
- Live web UI and stats
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
API reference evidence
Fetched from official sources on 2026-11-08T18:06:00+08:00 via WebFetch https://docs.locust.io/en/stable/writing-a-locustfile.html;WebFetch https://docs.locust.io/en/stable/api.html;WebFetch https://raw.githubusercontent.com/locustio/locust/master/locust/user/task.py.
HttpUser→ signature from https://docs.locust.io/en/stable/api.html; official text: “classHttpUser(*args, **kwargs)”@task→ signature from https://raw.githubusercontent.com/locustio/locust/master/locust/user/task.py; official text: “@overload def task(weight: TaskT) -> TaskT: … @overload def task(weight: int) -> Callable[[TaskT], TaskT]: … def task(weight: TaskT | int = 1) -> TaskT | Callable[[TaskT], TaskT]:”
FAQ
- How do I run it distributed?
- Start a master with locust --master and workers with locust --worker, sharing the same locustfile.
- How do I assert on failures?
- Use the --check-fail-ratio or analyze the stats CSV after the run; the UI shows failure percentages live.
- What is the difference from a script loop?
- Locust manages concurrency, collects statistics, and scales across processes, which a naive loop cannot.
Report a problem with this API docOpens a pre-filled issue on GitHub.