0

While I was performing load testing, I tried to increase the number of clients to reach a point where I began to receive HTTP Error 429's, "too many requests".

The statistics for the API appear to include the response time when a 429 is returned. The minimum response time I receive when the API works without any 429 errors is approximately 100 ms. When 429 errors start occurring the min response time is less than 10ms. This leads to the statistics being skewed by the response times for 429 errors since they usually return fairly quickly.

I tried using response.close() if the error occurs, but this closes the connection and prohibits reaching the requested quantity of clients.

I don't know how to remove the 429 error response times since the response time has already been captured. Is there a way to prevent "too many request" failures from being included in the statistics?

Another alternative is to use the regular response package, not HTTPLocust's version, and then build my own histogram based on the elapsed time for the API.

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
BBudak
  • 1

1 Answers1

2

If you throw an exception inside the catch-response block, the request will not be logged at all: https://docs.locust.io/en/stable/writing-a-locustfile.html#manually-controlling-if-a-request-should-be-considered-successful-or-a-failure

from locust.exception import RescheduleTask
...
with self.client.get("/does_not_exist/", catch_response=True) as response:
    if response.status_code == 404:
        raise RescheduleTask()
Cyberwiz
  • 11,027
  • 3
  • 20
  • 40