Ask Your Question
0

What is the method to restrict the quantity of requests in locust when carrying out tasks in a sequential category?

asked 2022-12-09 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-23 06:00:00 +0000

ladyg gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-09 11:00:00 +0000

Seen: 9 times

Last updated: Dec 23 '22