k6

Can one K6 Virtual User send two requests asynchronously?

Hi K6 support,

I have the following requirement, could u please kindly help to check if it is possible in K6? Thx!

Support I have two requests, requestA’s ART is 1seconds, request B’s ART is 100 seconds, I want one vus sends these two requests asynchronously with 2 threads, e,g:

0s: send request A, 1s: send request A, 2s: send request A…199s send requestA
0s: send request B, 100s: send request B
Then at 200th seconds, I have send 2 requestB, 200 requestA, the throughput would be 1.01(202/200) requests/second.

Thanks,
Roy Zhang

Hi @royzhang007,
All VUs are independent of each other. So if you just run two VUs and use the __VU to make one request in one of them and another request in another this will do exactly what you want.

You can use modulo arithmetic in order to, for example, split your VUs so a quarter of them do one thing, a third does a second thing and the rest a third thing. This can be a single requests or totally complete tests.
With the new schedulers coming soon ™ this will be even easier.

p.s. I don’t know what request ART is
p.s.s. the link with the modulo arithmetic has other ways of getting the same result which can be argued are more readable.

Thx @mstoykov, hope that new schedulers will come in short time.