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

pippip install locust

Methods

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.

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.