Master-Slave Load Testing using Locust

27 / Jul / 2016 by Mayur Rastogi 0 comments

In the previous blog we have discussed what is locust , why we use locust for load testing and how to implement it. So if you are wondering what locust is and how it works or for a better understanding, see locust .Now in this blog we are here to discuss about running locust in distributive way.

For a single machine it is not enough to simulate the number of users we need,so locust supports running load tests using multiple machines i.e in a master-slave setup.

pasted image 0

Quick Start

  • To start locust in a master mode we have to use –master flag.

    [js]locust -f load.py –master –host=http://example.com[/js]

    This provide us the web interface on master server to start the test and see live statistics:
    master without slave

    Note: Master server do not simulate any user itself. For this we have to start one or more slaves using –slave flag

  • To start locust as a slave machine:
    On the slave-machine use –slave flag and –master-host.

    [js]locust -f load.py –slave –master-host=master-host-ip[/js]

    Note: Both master and slave must have copy of locust script
    Here,we have added one slave machine,we can see at the right corner of web interface which is increment on adding and starting slaves:
    slave1 adde

    Similarly, for the second slave:
    slave 2 master

Now, we are ready with our slaves where can provide the number of users and hatch rate to start generating load on a particular website:
fianle2

Locust Report

The load test report can be downloaded from the from the web interface from the  “Download Data” option or we can also use –logfile option to save report in the server itself.

[js]locust -f load.py –logfile=logfilepath –master –host=http://example.com[/js]

Optional flags for running Locust:
–master: use this flag to assign machine as master in a distributed setup.
–master-host: use this flag to tell the slave about the hostname.
–slave: assign machine as slave.
–master-port: tell slave on which port the locust master in running.
–master-bind-port: use this flag to assign port for master in the master machine (default is 5557).
–master-bind-host: use this flag to bind master to particular host.

I hope this will help in understanding how to load test your applications using master slave setup in locust 🙂

FOUND THIS USEFUL? SHARE IT

Leave a Reply

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