Operations 4 min read

How to Set User Spawn Rate in Locust via CLI and Web UI

This article explains how to configure Locust’s user spawn rate—the number of virtual users started per second—using command‑line options or the Web interface, includes example commands, steps to launch the service, and considerations for dynamic adjustment and test safety.

Test Development Learning Exchange
Test Development Learning Exchange
Test Development Learning Exchange
How to Set User Spawn Rate in Locust via CLI and Web UI

Setting the user spawn rate (the number of virtual users started per second) in Locust is an important aspect of configuring load tests. It can be done via command‑line arguments or the Web UI. The following steps describe both methods.

Set user spawn rate via command line

When running Locust from the command line, use the -r or --spawn-rate option to specify how many users to start each second, and the -u or --users option to set the total number of concurrent users. For example:

locust -f your_locustfile.py --headless -u 100 -r 10 -t 1m

In this example:

-f your_locustfile.py specifies the Locust script file.

--headless runs Locust without the Web UI.

-u 100 sets the total number of simulated users to 100.

-r 10 sets the spawn rate to 10 users per second.

-t 1m limits the test duration to one minute.

Set user spawn rate via Web UI

If you prefer to use Locust’s Web interface, start Locust (by default accessible at http://localhost:8089 ) and enter the desired total number of users and the hatch rate (users spawned per second) directly in the UI fields.

Start Locust service

locust -f your_locustfile.py

Then open a browser and navigate to http://localhost:8089 . Fill in “Number of users to simulate” and “Hatch rate (users spawned/second)”, and click the “Start swarming” button to begin the test.

Dynamic adjustment

The methods above set the spawn rate before the test starts. Locust does not provide built‑in support for changing these parameters during a running test, but you can implement custom logic (e.g., listening to events and modifying global variables) to achieve similar dynamic behavior.

Precautions

• User experience: Ensure the chosen spawn rate does not overload the target system, causing crashes or severe performance degradation.

• Hardware limits: Verify that the load‑generator machine has sufficient CPU, memory, and other resources to handle the desired concurrency.

• Test purpose: Set the spawn rate according to your testing goals so that you can effectively evaluate system performance and stability.

CLILocustUser Spawn RateWeb UI
Test Development Learning Exchange
Written by

Test Development Learning Exchange

Test Development Learning Exchange

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.