Tried the Wizard?
The below example requests an index page, and then a CSS, JS, and image file as well. You'll see the image request has a custom weight
@task(4) to make it request 4x more images than the other task.
from locust import HttpUser, task, between class QuickstartUser(HttpUser): wait_time = between(5, 9) # this will run once per wait_time @task(1) def index_page(self): self.client.get("/") self.client.get("/app.js") self.client.get("/app.css") # this will run 4x as much as the above # it helps us fake 4x as many images on a page as content @task(4) def image_selection(self): self.client.get("/images/logo.jpg")
Locust Test Example
LoadForge is powered by locust, meaning open source locust users can copy this script as well. If you are a locust user, consider importing your script to LoadForge to supercharge your testing!