Web Perfermance Tester - Locust

Today, we use a web perfermance tool to test our web site.
We use locust.

Install locust

1
pip install locustio

create a web perfermance program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from locust import HttpLocust, TaskSet, task

class WebsiteTasks(TaskSet):
def on_start(self):
self.client.post("/login", {
"username": "admin",
"password": "admin"
})

@task
def index(self):
self.client.get("/")

@task
def tags(self):
self.client.get("/tags")

class WebsiteUser(HttpLocust):
task_set = WebsiteTasks
host = "http://localhost:3000/artc"
min_wait = 10
max_wait = 150

start web test server

1
locust -f locustfile.py

open http://localhost:8089/ for web perfermance tester web-portal

1
http://localhost:8089/

Set Number of users to simulate, Hatch rate (users spawned/second) and start test.

Instructions

1
2
host: the website host that you want to test for;
min_wait, max_wait: set up the test wait time. min_wait will affect the response/sec rate