0

I'm newbie in testing with K6. I have read the document of K6 but i'm not clear about "vus" and "iterations". I'm understand that vus = number of people go to the URL that declared, but I'm not sure about "iterations".

  • Can anyone help me to explain this clearly? I have my code below. My target is test a Restful API, try to find out the performance when about 100 users use this API continuously in 5 minutes.
  • Is my code right ? Because I'm understand that we need only "vus" and "duration" that can achive the goal of the test I mentioned (100 users use this API continuously in 5 minutes). So why need to add "iterations"?
  • What is different if i change iterations to 100, 1000 or remove it?
import http from 'k6/http';
     
export let options = {
  vus: 100,
  iterations: 20,
  duration: '300s'
};

export default function () {
  http.get('https://test.k6.io/contacts.php');
}
knittl
  • 246,190
  • 53
  • 318
  • 364

2 Answers2

0

As the documentation suggests, iterations is a shortcut for defining a shared iterations executor, whereas specifying duration is a shortcut for a constant VUs executor. The two conflict with each other, so you basically just want to use one or the other.

You should be able to just comment out the iterations option. The number of completed iterations (which is the number of times the exported default function is executed) will then be based purely on how much the VUs were able to achieve in the duration specified.

Tom
  • 126
  • 1
0

You might also be interested in different executors: If you know your request rate, say 10 requests per second, you could use the constant-arrival-rate executor:

import http from 'k6/http';
     
export let options = {
  scenarios: {
    default: {
      executor: 'constant-arrival-rate',
      duration: '5m',
      rate: 10, timeUnit: '1s', // 10 per second
      preAllocatedVUs: 8
    }
  }
};

export default function () {
  http.get('https://test.k6.io/contacts.php');
}
knittl
  • 246,190
  • 53
  • 318
  • 364