Performance tests are designed to check the ability of server, database and application on how it performs under load. Performance testing is often associated with the concepts of Load Testing, Stress Testing, or Endurance Testing. In fact, these are not terms that can be used interchangeably and Performance testing should be treated as a higher-level category, containing all the aforementioned types of tests.

Now come to our discussion about Locust Vs JMeter,

Locust is a distributed, load testing tool predominantly used for the web application, it’s as simple as we say. The behavior of each locust is defined by us and the swarming process is monitored from a web UI in real-time.

Here comes the Question,

Why do we need to look into this new tool when there are lots of well-established tools available in the market for decades like JMeter, LoadRunner, ApacheBench, Gatling, Tsung, etc…

Here is why we should give a try for this new tool,
* Allows a user to write code in plain python.
* Supports distributed user.
* Supports default HTML + JS based reporting.
* Open to test other systems by writing clients.
* Supports user to write code in other languages using locust slave, if needed.
* Open source under the MIT license.
* Locust is completely event-based, and therefore it’s possible to support thousands of concurrent users on a single machine. In contrast to many other event-based apps, it doesn’t use callbacks. Instead, it uses light-weight processes, through gevent.
* Greenlet allows a user to write an expressive scenario in Python without complicating your code with callbacks.

Comparison of Locust with Jmeter:

When we talk about performance testing, the tool which comes into everyone’s mind is JMeter, including myself. But when we dive deep here are the drawbacks it has:
* Point-and-click interface, a graphical interface to point and execute the click events.
* JMeter is thread bounded, internally it means each user we stimulate needs a separate thread, benchmarking thousands of user in a single machine is not feasible.

Locust is created to address these pain points in load testing.

Locust Architecture:

The execution flow starts with the main function of the python file( Locust class is parsed and associated weight tasks(functions) are parsed and stored. Locust browser client works with python standard library urllib2 to manage the HTTP requests. The “browser” that is used by the simulated users is defined in When a request is executed the time until a response has been received is recorded. Locust is implemented using events. When a request is finished, an event is fired to allow the stats module to store a response time or possibly a failure. Each simulated users run in Greenlet threads. A greenlet is actually not a real thread but it makes sense to think of it as such.


How to install Locust:

Once locust is installed locust commands will be available in the shell.

For other OS, installation steps can be found here:

Writing a locust script:

It’s a plain python file. Only thing is, it should have one class which inherits from the class locust.

Sample code snippet:

Below is a code for a very basic locust-file (a python-file) to load test towards locust’s own web
server. It sends GET request to the index page and a URL for fetching updates of the

Triggering the Locust file:

Now start the Locust service with our locust file as mentioned below through terminal:

$ locust -f <locustfile> –web –host
In the next step, you can run the graphical interface in the browser, which is located in

The interface will open a page with two inputs. In the first of them, “Number of users to simulate”, we have to enter the number of users (e.g. 10.0). in the second, “Hatch rate”, you specify the number of users that will be created in a second (e.g. 1). When running a test with given values, you will see the test statistic.

Workaround for dynamic user allocation:

Dis-advantage in both Jmeter and Locust is not having a direct option for the user to dynamically change the number of users, In Jmeter this can be achieved through BeanShell and in Locust, this is a one-time process of editing the to get the UI option to do the dynamic user allocation option.

Topics Locust Jmeter
Platform/Operating System Any Any
Open Source/License Yes. MID Licensed Yes. Apache 2.0 Licensed
Supported Protocols Primarily HTTP and supports everything using a custom script. HTTP,JDBC, FTP, LDAP, SMTP and more.
Support of “Test as Code” Strong(Python) Moderate(Java)
Concurrent Users Efficient and powerful Moderate
Resources Consumption Less (1X) More(GUI – 30X Non-GUI – 14X)
Ramp-up Flexibility Customizable using code Yes.
GUI No Yes
Execution Monitoring Console
Desktop client
Custom plugins
Recording Functionality No Yes
Easy to Use VCS Yes. No

So, which one you should choose?In summary, the choice between JMeter and Locust is definitely not easy. Although both tools are open source, behind the JMeter is the giant in the form of The Apache Software Foundation. On the other hand, Locust is being developed by a small team of developers and the community centered around the tool. Jmeter is written in Java, Groovy and BeanShell, but Locust is written in Python. Locust is an apt tool to measure the load test in real time Big data flow application to avoid peak time application down scenario. This works better where the Dev-QA combined load testing happens to measure the real-time load balancing before moving the product/software to production.