Select Page
Performance Testing

Distributed Load Testing in Locust

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

Listen to this blog

Today, you will learn how to perform distributed load testing in Locust. If you are not familiar with Locust, then let’s refresh the basics and see how to perform distributed execution. Locust is an open source load testing tool and you can describe all your test in Python code.

Distributed Load Testing in Locust

Installation Locust is a Python library. It does not have any UI to write or configure your test. You can describe all your test in Python code.

pip install locustio

Locust File CreationCreate a python file using the below code.

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    def index(self):

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000

Note: If a file has HttpLocust class, then it will be considered as LocustFile. In the above code, we have two classes, one is TaskSet which is used to declare all your tests and the second one is HttpLocust which represents one user and it should have task_set attribute.

Executing Locust FileUse the below command to run your Locust file.

locust -f locust-examples/ --host=

Note: As per the above command, our LocustFile is placed inside a folder (i.e. locust-examples). Once you execute the above command, Locust web monitor will start and you can start load execution from web monitor

Locust Web MonitorYou can launch the web monitor using http://localhost:8089/.

Locust Web Monitor

Now, click Start Swarming button after entering number of users and Hatch rate.

Distributed Execution

To start locust in master mode:

locust -f --master

And then on each slave (replace with IP of the master machine):

locust -f --slave --master-host=


Submit a Comment

Your email address will not be published. Required fields are marked *

Talk to our Experts

Amazing clients who
trust us