When I increase the vus why wouldn’t the http_reqs increase. As an example when I run with one virtual user I get 29 http_reqs but when I increase to 2 I still get 29 requests. In research I found that it doesn’t cache so should get get double the requests?
In general you are right. For example, if I run the following script:
import http from 'k6/http';
export default function() {
const response = http.get("http://test.loadimpact.com");
};
with k6 run --vus 1 --duration 10s script.js
, I’d get 87 requests. But if I run it with k6 run --vus 2 --duration 10s script.js
, I get 172, roughly double. So I’d wager that you’re doing something strange in your case. Can you give some more details about your script and all the script options specifically?
I’m using iterations instead of duration like this:
k6 run --vus 2 --iterations 1 myscript.js
I’m converting my har file to a js file. And it includes a login at the start.
Iterations are shared across all VUs… so when you have just 1 iteration, it doesn’t matter how many VUs you use, only 1 of them is going to execute your default function once. You should even have gotten a warning like this:
WARN[0000] All iterations (1 in this test run) are shared between all VUs, so some of the 2 VUs will not execute even a single iteration!
I did not get a warning but just want to make sure I am understanding this correctly. So if I have 2 VUs and 2 iterations, then 2 users will be hitting the site concurrently and I should then get double the requests like I would expect. So I should basically match VUs with iterations if I’m looking to simulate 2 users for example?
I did not get a warning
Which k6 version are you using? Try running k6 version
, you should be on v0.26.0, since that is the latest one.
So if I have 2 VUs and 2 iterations, then 2 users will be hitting the site concurrently and I should then get double the requests like I would expect
yes
So I should basically match VUs with iterations if I’m looking to simulate 2 users for example?
Essentially yes, you can think of the number of iterations
as a pile of work and the vus
as workers that concurrently do it. But different iterations may take different amounts of time to be executed, depending on network speeds, sleep()
times and so on. So if you have 100 iterations and 5 VUs, it’s currently not guaranteed that each VU would execute exactly 20 iterations. Some may execute 18 or 19, others 21 or 22, but by the end, exactly 100 iterations would have been executed in total, between all of the VUs.
Great! Thank you for the help. I’ll give that a try. Also, I’m on v0.26.0