1

I will be using Locust to perform some load tests on a web api. I am trying to calculate how many locust-users I will need to reproduce the anticipated peak load.

Based on my (loose) calculations, during peak load, I will need each locust-user to be able to send http requests to my api every 2.67 seconds.

  • I am new to Locust, so I have to ask- is this request-rate possible?

  • Suppose, during one request (during peak time), the response from the api takes longer than 2.67 seconds. Will the locust user fire another request at the 2.67 mark- even if it has not recived a response from its previous request?

For some extra info, I will be using a set of Azure virtual machines to generate the locust users.

DalhousieDuck
  • 329
  • 1
  • 16

1 Answers1

3

Is this request-rate possible?

Yes! Using constant_pacing https://docs.locust.io/en/stable/writing-a-locustfile.html#wait-time-attribute you can limit the number of tasks an individual user can perform per unit of time.

Suppose, during one request (during peak time), the response from the api takes longer than 2.67 seconds. Will the locust user fire another request at the 2.67 mark- even if it has not recived a response from its previous request?

No. Every user is syncronous so it cannot fire a new request before the previous one has finished. The easiest way to ensure constant throuhgput when latency might go up during the test is to increase the number of users beforehand and adjust the per-user pacing (e.g. double the number of users and increase the pacing time to 5.33 seconds).

Dont forget that in most real world cases, when you have saturated your system so much that response times are increasing, sending more concurrent requests are unlikely to yield higher throughput (instead causing even higher response times and/or errors).

Edit: If you want to set a global rate, instead of a per-user one, check out locust-plugins constant_total_ips() timer instead: https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/constant_total_ips_ex.py

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40