Running Locust on Azure

An easy and cheap way to massively call HTTP endpoints

Davide Mauri
Microsoft Azure
2 min readFeb 19, 2020

--

If you are a developer that works in a field where you are asked to create or maintain REST API as your daily job, you’ll surely have found yourself in the need of testing API performance at some point.

I’ve found a very nice and simple tool to do that: Locust.

Locust has several nice features that I really like:

  1. Support distributed deployment. You can create a lot of clients, all managed by a single master, to general a lot of test calls.
  2. Python-based. The code to test target API is plain Python, all in one file (“locustfile.py”), with some specific objects made available by Locust to make life easier. I really like that.
  3. A single locust file can host more than one test, and each test can have its own weight so that you can exactly decide how to distribute workload
  4. Has a nice user interface that clearly shows Request Per Seconds over time and, in case, Exceptions and Failures
  5. Works very well with Docker and can be dockerized in less than 150 Megabytes

In order to use Locust in Azure in the simplest and easiest way possble, I’ve create a docker image on Docker Hub:

https://hub.docker.com/repository/docker/yorek/locustio

As I really wanted some really easy and simple to use, I decided to go for Azure Container Instances, and the repo with the script code to deploy Locust is available here:

If you are more inclined to use a more complex but more complete container orchestrator, of course Kubernetes could be better option.

In the mentioned repo, the script will take care of everything needed to run Locust on Azure:

  1. create a storage account to host to locust file
  2. create a storage share for the locust file
  3. upload the locust file
  4. deploy the master locust and the desired clients in Azure Container Instances
  5. configure master and clients correctly
  6. run the locust swarm

Easy and nice, I can now run test for stability and performance my API.

--

--

Davide Mauri
Microsoft Azure

Data Geek, Storyteller, Developer at heart, now infiltrated in Azure SQL product group to make sure developers voice is heard loud and clear. Heavy Metal fan.