Skip to content

mannansiddiqui/Performance-Load-testing-using-Locust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Step-1: Install Python (3.7 or later)

1

Step-2: Install the package
pip3 install locust

2

Step-3: Validate your installation
locust -V

3

It gives an command not found error. If you see the locust installation screenshot its asking to add /home/ubuntu/.local/bin in PATH. So, for this run export PATH=/home/ubuntu/.local/bin/:$PATH

4

Now, again run locust -V

5

This time it works...

Step-4: Done! Now create your first test

A Locust test is essentially a Python program. Create python program according to your requirements. Here is the official documentation link to create locust file.

Let's understand the architecture:

Approach-1: Without worker

I had used 1 EC2 instance in which locust and nginx server running with two endpoints /index.html and /test.html

Put the code in a file named locustfile.py in your current directory and run :

locust -f locustfile.py

6

7

Now hit InstancePublicIP:8089 after adding rule for 8089 port in security group. Enter number of users, Spawn rate, and Host.

8

Now, click on start swarming. And get the statistics, charts, failures, exceptions, current ratio, and download data.

9 10 11 12 13 14

Approach-2: With worker

I had used 3 EC2 instances, one for locust master, second for locust worker and last for nginx server with two endpoints /index.html and /test.html

Here is the official documentation for distributed load generation.

Put the code (same as used in Approach-1) in a file named locustfile.py in your current directory and run:

From master:

locust -f locustfile.py --master

15

From worker:

locust -f locustfile.py --worker --master-host=<MASTER_INSTANCE_IP>

16

If getting error then allow port no. in security group of master.

Now hit MASTER_INSTANCE_IP:8089 from browser.

17

Enter No. of user, spawn rate and host(don't forget to add http://) then click on start swarming and get the statistics.

18 19 20 21 22 23 24 25

Thank you...

About

Performance/Load testing using Locust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published