Sorry, I still think that I am missing something
But maybe this could work:
import { sleep } from 'k6';
export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'ramping-vus',
startVUs: 1,
stages: [
{ duration: '2m', target: 10 },
{ duration: '1m', target: 0 },
],
gracefulRampDown: '1m',
},
},
};
// a simple counter of iterations for each VU
let i = 0;
export default function () {
if (i > 0) {
console.log(`no more work for the #VU: ${__VU}`)
// iteration for that user already done
// we just sleep a bit and exit
sleep(10);
return
}
console.log(`VU #${__VU} is doing some job`);
// heavy work (600 requests)
// we are done with the job
i++;
}
Basically, the whole scheduling of execution is still managed by k6, but using this simple i
variable guarantees that the VU executes only once, which means that once you reach the 10 VUs, it’s just a matter of the grace shutdown to wait when the scheduler simply stop all VUs.
Does that help?
Cheers