Simulate constant rate with a small number of connections

The constant-arrival-rate executor requires one VU to execute each iteration but I think this doesn’t allow us to simulate scenarios where a service has a lot of requests but from a small set of other services instead of end users for example.
Each VU requires one connection to the server so I’m having issues trying to simulate a constant RPS since increasing the VUs leads to increasing the connections and that seems to be impact tail latencies.

Hi @gabrielgiussi, welcome to the community forum :tada:

Sorry for the slow reply :frowning:

I am a bit confused about how you expect this should work:

Each VU requires one connection to the server so I’m having issues trying to simulate a constant RPS since increasing the VUs leads to increasing the connections and that seems to be impact tail latencies.

Wouldn’t that be the same for your services? LIke wouldn’t the services that will be testing need a connection to their requests. So that if previous requests are taking too long they will need to open more connections or wait(impacting tail latencies)?

Have you also tried using arrival-rate executors? Or is your problem with them?

Hi @mstoykov , thanks for the reply.

I’m thinking about HTTP/2 connections here, in that case a service can keep an http2 connection with another service and send multiple requests over the same connection, but that’s something we can’t simulate because each VU currently opens a new connection.

Am I doing any incorrect assumption?

Sorry for the slow reply :frowning:

each VU currently opens a new connection.

This isn’t the problem really. The problem is there is currently no way for a VU to do asyncrhnous http requests as k6 also didn’t have event loop until less then a year ago.

Also we would prefer to work on a new HTTP api and it has quite a few things it should fix (or make possible).

But there is really good chance that we will be adding http.asyncRequest (or similar) which will let you do something like

setInterval(()=>{
    http.asyncRequest(url, data, params).then((resp)=>{
      // usual checks on the response
    })
}, 5000) 

in order to keep making new requests each 5seconds.

As k6 currently does not support saying whether or not you use the same connection - it will default to what the go stdlib does which is to reuse the connection when possible(for http/2 specifically).

This API is under discussion and might not land in v0.43.0 or at all, but at this point seems likely.

Until then I don’t have better suggestions but to use http.batch. I also am not certain creating new connections will have this much of an effect, but I guess you have measured that :person_shrugging:

I will try to update this thread in the future.

Hi Mihail, thanks for the detailed response.
I think that’s exactly what I would need to simulate what I want.
About the effect of creating new connections I was expecting something similar but my measurements seems to indicate they are causing some issue, of course I may be missing something and having this feature could help me to validate if the cxs are an issue or not.
I just wanted to share it here and see if it made sense.

I’ll keep an eye on future releases, tks.

1 Like