Slow requests and broken metrics with multiple scenarios

Hey! I have a problem when declaring my scenarios, the thresholds are not being respected for some reason that I don’t know.

I have 2 scenarios, where the first one will send 1 VU with 1 request to my API, the second scenario will send 10 users to the other endpoint with different data.

The problem is the following, when running the 2 scenarios k6 displays unusual metrics, making the request take around 9 seconds, and if you also run the same test in Postman, the requests do not exceed 4 seconds each.

Below my options:

export const options = {
  scenarios: {
    requisicao_unica_1: {
      executor: 'per-vu-iterations',
      startTime: '0s',
      vus: 1,
      iterations: 1,
      tags: { test_type: 'req1' }, // extra tags for the metrics generated by this scenario
      exec: 'executarTeste', // the function this scenario will execute
    },
    requisicao_unica_10: {
      executor: 'per-vu-iterations',
      vus: 10,
      iterations: 1,
      tags: { test_type: 'req2' },
      exec: 'executarTeste', // the function this scenario will execute
    },
  },
  thresholds: {
    // we can set different thresholds for the different scenarios because
    // of the extra metric tags we set!
    'http_req_duration{test_type:req1}': ['p(95)<4000'], // 95% das requisições devem ser concluídas em menos de 500ms
    'http_req_duration{test_type:req2}': ['p(95)<5000'],

  },
};

k6 version v0.45.0 (2023-06-19T08:41:01+0000/v0.45.0-0-gc3b4587b, go1.20.5, linux/amd64)

Hey @Yuri_Pires :wave:

Welcome to the forum :tada:

When discussing performance issues themselves, it would be tricky for use to provide constructive support without seeing what the script you are running looks like. Would you be able to share without us an anonymized and simplified version of your script?

Could you also elaborate on the following statements too:

k6 displays unusual metrics

What do you mean by unusual, what did you expect to see, and what did you observe instead?

making the request take around 9 seconds

Which request are you referring to, the initial one from the first scenario, the ones you send in the second scenario, or all in general?

Thank you :bowing_man:

1 Like