0

trying to run k6 performance test cases by using the following scenario's

how to hit x amount of API per min for example: Produce 500 messages per minute → Check how API behaves

It should be same, next time we run the test case.

knittl
  • 246,190
  • 53
  • 318
  • 364

1 Answers1

1

This is easily achievable with the constant-arrival-rate executor:

import http from 'k6/http';
import { sleep } from 'k6';

export const options = {
  scenarios: {
    500_mps: {
      executor: 'constant-arrival-rate',
      duration: '10m',
      rate: 500,
      timeUnit: '1m',
      preAllocatedVUs: 10,
      maxVUs: 100,
    },
  },
};

export default function() {
  http.get('your api');
}

The above code will try to run the default function 500 times per minute for 10 minutes. It will use at most 100 VUs – if your API is too slow, k6 will not start more VUs and you will not reach the target load.

knittl
  • 246,190
  • 53
  • 318
  • 364