locust logo locust: settings

1 2 3 4 5 6 7 8

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):"/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 --headless --host -u 1000 -r 50 --tags attempt

Note the use of the tags!