Matt
Matt

Reputation: 1043

K6 Load Testing - How to calculate accurate response times when using the rps option

I am recording how long each request takes by capturing Date.now() before and after the request.

I am doing this because the inbuild metric for the response time only records the time taken for the FIRST REQUEST and not for any redirects that it follows.

My method was working fine until I started using the rps option.

The rps option throttles how many requests per second are sent.

The problem that this is causing is that my manual calculations are going up even though the HTTP_REQ_DURATION is roughly the same.

I presume this is because of the RPS throttle i.e. it is WAITING and this is causing my calc using Date.now() to go up - which is not an accurate reflection of what is happening.

How can I calculate the total time taken for a response to a request including all redirects when I am using the rps option?

Upvotes: 0

Views: 1738

Answers (1)

na--
na--

Reputation: 1106

I'd advise against using the RPS option and using an arrival-rate executor instead, for example, constant-arrival-rate.

Alternatively, you can set the maxRedirects option to 0, so k6 doesn't handle redirects itself. Then, when you handle the redirects yourself, you can get the Response object for each of the requests, not just the last one. Then you can sum their Response.timings.duration (or whatever you care about) and add the result in your custom metric, it will not contain any artificial delays caused by --rps.

Upvotes: 1

Related Questions