... locust.

It's nice to know how much traffic your webapp can handle before it gets this amount of traffic for the first time. A tool that can help you calculate this is called locust.


The new user behavior definition is listed below:

import random 
from locust import HttpUser, between, task, tag

class WebsiteUser(HttpUser):
    wait_time = between(1, 1.5)

    def on_start(self):
        self.uid = str(random.randint(0, 100_000)).zfill(6)

    @tag("attempt", "light")
    def attempt(self):

    @tag("sleep", "heavy")
    def sleep(self):

    @tag("simulate", "light")
    def simulate(self):
        self.client.post("/simulate/", json={
            "uid": self.uid, 
            "n_sim": random.randint(10, 20)

To run this via the terminal in headless mode you can run;

locust -f benchmark.py --headless --host -u 1000 -r 50 --tags attempt

Note the use of the tags!

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.