



JMeter and Locust are one of the top testing tools out there for testing the scalibility of production ready web service. Today, we will try to see a practical introduction of setting up Locust for the same purpose.





While load testing with Locust, swarm of locusts attack the endpoint with a certain hatch rate (locusts spawned/second). Locust also provides a real-time web UI to monitor the state during swarming process. The best part, there are no clunky UIs or bloated XML—just a python code as you would normally do.

Locust Installation

Locust supports Python 2.7, 3.4, 3.5, and 3.6.

# Python 2.x > python -m pip install locustio

Read Installation Guide to explore other options.





Example locustfile.py

As a testing process, we will be reading sample test cases from a file and then spawn the swarm of Locusts for that .

Starting Locust

The below command fires up the locusts with the following parameters:

Hatch Rate (-r) of 100 (100 locusts/sec) Total Locusts (-c) of 1000 Saves results to results.csv Defines the endpoint (--host) Disables web view (Useful when running on servers)

> locust -f locustfile.py --csv=results.csv --no-web -c 1000 -r 100 --host=http://<IP>:<PORT>/