Data Science - Technology - Machine Learning - Deep Learning - Natural Language Processing - Research

Blog Archive


February 16, 2019

Exploring Locust - Load Testing Framework

Locust - Load Testing in Python
JMeter and Locust are one of the top testing tools out there for testing the scalibility of production ready web service. Today, we will try to see a practical introduction of setting up Locust for the same purpose.

While load testing with Locust, swarm of locusts attack the endpoint with a certain hatch rate (locusts spawned/second). Locust also provides a real-time web UI to monitor the state during swarming process. The best part, there are no clunky UIs or bloated XML—just a python code as you would normally do.

Locust Installation
Locust supports Python 2.7, 3.4, 3.5, and 3.6. 
 # Python 2.x  
 > python -m pip install locustio  
Read Installation Guide to explore other options.

As a testing process, we will be reading sample test cases from a file and then spawn the swarm of Locusts for that.

Starting Locust
The below command fires up the locusts with the following parameters:
  1. Hatch Rate (-r) of 100 (100 locusts/sec)
  2. Total Locusts (-c) of 1000
  3. Saves results to results.csv
  4. Defines the endpoint (--host)
  5. Disables web view (Useful when running on servers)
 > locust -f --csv=results.csv --no-web -c 1000 -r 100 --host=http://<IP>:<PORT>/  

Feel free to share your thoughts - Thanks


Post a Comment

Please share your valuable feedback. It will help and me and community grow.