Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locust : How to make locust run for a specific amount of time

Tags:

official locustio documentation tells about how to write simple locust tasks which run indefinitely.

Couldn't find out how to run load which lasts for a specific amount of time, so that the test will automatically stop after the specified interval.

I dont need it from the web interface, command line/code option will be just great.

like image 969
binithb Avatar asked Aug 19 '14 20:08

binithb


People also ask

How do you put RPS in a locust?

The code your Locust users runs needs to be written in such a way that each user is only making one request. Then in your Locust User class, you set wait_time = constant(1) or wait_time = constant_pacing(1) , whichever behavior you want.

What is wait time in Locust?

The wait_time attribute Locust comes with a few built in functions that return a few common wait_time methods. The most common one is between . It's used to make the simulated users wait a random time between a min and max value after each task execution.

How do you stop locusts after number of requests?

In this case, each user should sign-in and make 3 GET request and locust should stop. So a total of 12 request. I found that previously there was an option -n to specify the number of request, however it is not there in version 0.14. 4.


2 Answers

This answer is out of date. Locust now has a -t / --run-time parameter for specifying run time. See https://docs.locust.io/en/stable/running-without-web-ui.html?highlight=run-time#setting-a-time-limit-for-the-test

I recently started using locust myself and unfortunately locust 0.7.1 does not provide a way to terminate a test based on a length of time.

It does however provide a way to terminate the test based on the number of requests that have been issued. If you run locust using the CLI interface you can specify that it stop execution after a specified number of requests have been handled. From the locust --help output:

-n NUM_REQUESTS, --num-request=NUM_REQUESTS        Number of requests to perform. Only used together with --no-web 

So, you can start a session with something along the lines of:

# locust --clients=20 --hatch-rate=2 --num-request=500 

and once 500 requests have been handled it should terminate the test.

like image 62
aztlan2k Avatar answered Sep 16 '22 11:09

aztlan2k


It's probably too late to answer, but might be helpful for someone in future. Locust now supports -t or --run-time options to specify duration when running Locust with --headless option. From locust --help:

-t RUN_TIME, --run-time=RUN_TIME                         Stop after the specified amount of time, e.g. (300s,                         20m, 3h, 1h30m, etc.). Only used together with --no-                         web 
like image 41
Abhishek Dalvi Avatar answered Sep 20 '22 11:09

Abhishek Dalvi