Can weightage be added to each request like


Would like to make some HTTP request more than the others to make it as close to the real traffic (As all the APIs are not called equally).

This is possible in where one could add weight to the request. Is there something similar in K6…?

Hi @vividhsv,

As far as I can see you are talking about Locust’s weight ? I have not used locust but as far as I understand you can define multiple locust’s that will be run one after the other and with weight you can say you want one to be ran … more.
This at the moment is not how k6 works. Currently there is a single script that all k6’s VUs(virtual users) run constantly, more or less as fast as possible.

You could use modulo arithmetic to say that you want more of those iterations to be of given code than other.

export default function() {
  if(__ITER % 5 = 0) {
    functionCall1(); // every 1 of 5  iterations of each VU will run this code
  } else if (__ITER %5 == 1) { 
    functionCall2(); // again every 1 of 5 itertaion of each VU will run this code
  } else {
    functionCall3(); // this one will be ran every 3 iteration of every 5 of each VU

You can read more about __ITER (and __VU) at our documentation.
You can also see another solution for the same problem here.

We are currently working on the brand new executors(although they are currently called schedulers, but this is about to change). With them you will be able to say something like … "execute this function 10 times a second and this other function 5 times a second, and this third one … "


Thanks you, that is helpful and also waiting for the new executor changes.