1 | initial version |
One way to restrict the quantity of requests in Locust when carrying out tasks in a sequential category is to use the wait_time
parameter. By setting a specific wait_time
between requests, you can limit the number of requests that are made within a certain time period.
For example, if you want to make 5 requests per minute, you can set the wait_time
to 12 seconds (60 seconds / 5 requests = 12 seconds) between each request:
class MyTaskSet(TaskSet):
@task
def sequential_task(self):
self.client.get("/page-1")
self.wait_time = 12
self.client.get("/page-2")
self.wait_time = 12
self.client.get("/page-3")
# etc.
By setting the wait_time
to 12 seconds between each request, you ensure that each request is separated by at least 12 seconds, limiting the number of requests that can be made in a minute to 5.