DEV Community

Davide Mauri for Microsoft Azure

Posted on • Edited on

3 1

Running Locust on Azure

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 Running On Azure

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:

https://github.com/yorek/locust-on-azure

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.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay