Load Test Your Architecture Before Your Users Do it for You

DZone 's Guide to

Load Test Your Architecture Before Your Users Do it for You

A quick exploration of the free and open source load balancing tool, Locust, and how it works.

· Web Dev Zone ·
Free Resource

Do you happen to host your own website or application? If so, have you load tested your architecture? I hope the answer is yes…

I happen to host applications for myself as well as my customers. As the traffic to my servers started increasing, I began to wonder — how much traffic can my architecture handle? Then naturally the worst came to mind: what if I got a spike of traffic tomorrow and users couldn’t access their services? The reputation of my service would be tarnished! This kept me up at night for a couple of days until I decided to do something about it. 

I made a decision to load test my systems and figure out how many simultaneous users my server can handle. Deciding on something and doing it are two completely different things. I have never done a load test before, therefore, I had a lot to figure out before I could put my servers to the test. Read on to find out how I went about load testing my web applications for the first time and how I can sleep peacefully again. 

Hello Locust

I found multiple tools to load test websites:

  • Paid online tools
  • Selenium
  • JMeter
  • Locust

Out of them all, Locust (https://locust.io) caught my attention and stood out. It’s free, open source and written in Python! 

Here’s a brief entry from it’s manifest: 

“Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites (or other systems) and figuring out how many concurrent users a system can handle.

… Locust is completely event-based, and therefore it’s possible to support thousands of concurrent users on a single machine.”

After briefly reviewing the documentation I had my mind made up and couldn’t wait to get my hands on it. I followed the installation instructions, downloaded PyCharm CE, and was ready to go. 


All I had to do is set the number of concurrent users I wanted to simulate along with the hatch rate. 

Once you start swarming your system, Locust will present you with some important statistics regarding the performance of your servers. The below image represents a genuine test I carried out. It had around 2000 users carrying out an action on the website every 5-9 seconds. In a very short moment I flooded the servers with over 12 thousand requests! That’s using one host, i.e. my MacBook Pro. 


Distributed Mode

Locust has another feature that allows us to simulate much bigger number of users using multiple hosts. You can read more here: https://docs.locust.io/en/stable/running-locust-distributed.html


Running load tests on my servers allowed me to understand the upper limits of my architecture and I realized that I’m still far from the breaking point. I can now sleep again. 

Make sure you also understand the upper limits of your system and take the responsibility for load testing, before your users do it for you. 

load balancing ,locust ,load testing ,web dev ,web application architecture

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}