selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

Locust logo

Self-host Locust

2.47.0

Load-test any system with plain Python scripts

ReleaseOpen SourceMIT
docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/locustfile.py
Updated3 weeks ago
LanguagePython
Setup difficultyEasy
Stars
28 282
Ports
8089 (Web interface / stats UI (master node)), 5557 (Port the distributed master node listens on for workers)
Requires
Python
Docker
locustio/locust
Web UI start-test screen asking for host and user countRunning test statistics table in the web UICharts tab showing RPS, response times and user countUser and shape class picker in the web UI

What is Locust?

Locust is an open-source load and performance testing tool whose scenarios are ordinary Python code: you subclass a User type, decorate methods as tasks, and Locust runs every simulated user as a lightweight coroutine, so tests live in your normal IDE and version control. HTTP/HTTPS is built in and anything else (gRPC, SocketIO, MQTT, XML-RPC, an SDK) is covered by wrapping a client library and firing request events. Runs are driven either from a browser UI on port 8089 that charts requests per second, response times and failures live and lets you change the load mid-test, or headless with -u/-r/-t flags for CI pipelines. Load generation scales out from one master to many worker processes or machines, with --processes auto-forking workers and an optional Kubernetes operator that models tests as custom resources. Results go to CSV files, JSON on stdout, or a standalone HTML report, and optional instrumentation can export traces, metrics and logs. Install it with pip (or uvx), use the locustio/locust image, or the locustio/locust-otel image with the telemetry extras pre-installed. The code base is deliberately small: many extras come from community extensions, and Microsoft sponsors maintenance while offering a managed service that runs Locust scripts.

Locust alternatives

Should you self-host Locust?

Locust scores 78/100 on selfhost.directory (how scoring works) and ranks #1 of 10 in Testing. It has 28 282 GitHub stars, +82 in the last 30 days.

It shipped 20 stable releases in the past year. The latest, 2.47.0, came out on 21 October 2026. New versions land roughly every 2 weeks.

Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in Python.

Its closest alternative on selfhost.directory is Keploy (78/100, 19 765 stars). Locust scores higher overall. See Locust vs Keploy side by side.

Features

  • Adjustable load during a runAlso possible in headless mode via w/W/s/S keyboard input.
  • CSV results export
  • Custom load shapes
  • Distributed load generation
  • Headless command-line mode
  • HTML Report
  • HTTPS for the web UI
  • JSON stats output
  • Kubernetes operator
  • Multi-protocol extensibility
  • Pytest-style test filesMarked experimental; weighting is not supported and it only applies when no regular User classes exist.
  • SocketIO clientDocs mark SocketIO support as experimental.
  • Task tagging
  • Web-based UI with live statistics

Locust README

Locust

PyPI Supported Python Versions Downloads GitHub contributors Support Ukraine Badge inspect.software

Locust is an open source performance/load testing tool for HTTP and other protocols. Its developer-friendly approach lets you define your tests in regular Python code.

Locust tests can be run from command line or using its web-based UI. Throughput, response times and errors can be viewed in real time and/or exported for later analysis.

You can import regular Python libraries into your tests, and with Locust's pluggable architecture it is infinitely expandable. Unlike when using most other tools, your test design will never be limited by a GUI or domain-specific language.

To get started right away, head over to the documentation.

Features

Write user test scenarios in plain old Python

If you want your users to loop, perform some conditional behaviour or do some calculations, you just use the regular programming constructs provided by Python. Locust runs every user inside its own greenlet (a lightweight process/coroutine). This enables you to write your tests like normal (blocking) Python code instead of having to use callbacks or some other mechanism. Because your scenarios are “just python” you can use your regular IDE, and version control your tests as regular code (as opposed to some other tools that use XML or binary formats)

from locust import HttpUser, task, between


class QuickstartUser(HttpUser):
    wait_time = between(1, 2)

    def on_start(self):
        self.client.post("/login", json={"username": "foo", "password": "bar"})

    @task
    def hello_world(self):
        self.client.get("/hello")
        self.client.get("/world")

    @task(3)
    def view_item(self):
        for item_id in range(10):
            self.client.get(f"/item?id={item_id}", name="/item")
Distributed & Scalable - supports hundreds of thousands of users

Locust makes it easy to run load tests distributed over multiple machines. It is event-based (using gevent), which makes it possible for a single process to handle many thousands concurrent users. While there may be other tools that are capable of doing more requests per second on a given hardware, the low overhead of each Locust user makes it very suitable for testing highly concurrent workloads.

Web-based UI

Locust has a user friendly web interface that shows the progress of your test in real-time. You can even change the load while the test is running. It can also be run without the UI, making it easy to use for CI/CD testing.

Locust UI charts

How to install Locust

Install Locust with Docker

docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/locustfile.py

Assumes locustfile.py in the current working directory; locustio/locust can be used as a base image for extra pip packages.

How to configure Locust

  • LOCUST_LOCUSTFILEThe Python file or module that contains your test, e.g. ‘my_test.py’. Accepts multiple comma-separated .py files, a package name/directory or a url to a remote locustfile. Defaults to ‘locustfile.py’.
  • LOCUST_HOSTHost to load test, in the following format: https://www.example.com
  • LOCUST_USERSPeak number of concurrent Locust users. Primarily used together with –headless or –autostart. Can be changed during a test by keyboard inputs w, W (spawn 1, 10 users) and s, S (stop 1, 10 users)
  • LOCUST_SPAWN_RATERate to spawn users at (users per second). Primarily used together with –headless or –autostart
  • LOCUST_RUN_TIMEStop after the specified amount of time, e.g. (300s, 20m, 3h, 1h30m, etc.). Only used together with –headless or –autostart. Defaults to run forever.

Locust releases & version history

@ Every self-hosted release, weekly

One Monday email with the week's stable releases across the directory.

FAQ

Other questions and issues

Ask on Locust's Discord, check the GitHub issue list, or search and post on Stack Overflow.

Locust web UI doesn’t show my tasks running, says 0 RPS

Locust only records what you tell it: HttpUser with self.client fires the events for you, but a plain User or other client code must fire request events itself.

How to run a Docker container of Locust in Windows Subsystem for Linux (Windows 10 users)?

Under WSL you need one extra step compared to the usual docker run: copy the locustfile into a Windows-side folder and mount that folder into the container.

Create a Locust file based on a recorded browser session

Use the community tool har2locust to turn a recorded browser (HAR) session into a locustfile.

Basic auth (Authorization header) does not work after redirection

The underlying requests behaviour drops the authorization header when the domain changes, so turn off allow_redirects, follow the redirects yourself and re-inject the header.

Control headers or other things about my HTTP requests

Locust's HttpUser client inherits from requests, so nearly all of its parameters and methods work; check the requests docs and Stack Overflow first.

Clear cookies, to make the next task iteration seem like a new user to my system under test

Call self.client.cookies.clear() at the end of the task.

Resolve errors that occur during load (error 5xx, Connection aborted, Connection reset by peer, etc)

Look at your server's logs first: if the system behaves fine at low load, the problem is almost certainly in the system you are testing rather than in Locust.

More in Testing

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…