# \[k6\] How to send x requests after x times?

**URL:** <https://community.grafana.com/t/k6-how-to-send-x-requests-after-x-times/140350>\
**Category:** Grafana k6\
**Created:** [January 15, 2025, 7:51am UTC](https://community.grafana.com/t/k6-how-to-send-x-requests-after-x-times/140350 "2025-01-15T07:51:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoadoan](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@hoadoan](https://community.grafana.com/u/hoadoan)\
**Post date:** [January 15, 2025, 7:51am UTC](https://community.grafana.com/t/k6-how-to-send-x-requests-after-x-times/140350/1 "2025-01-15T07:51:26Z")

</div>

“I want to simulate 50 users logging into the system at the same time. After 10 seconds, another 50 users log in, and so on, until 5 minutes have passed.”

My question is how to configure this in k6?

I have tried the option “constant-arrival-rate” however it is not my expectation  
export const options = {  
scenarios: {  
steady\_load: {  
executor: ‘constant-arrival-rate’,  
rate: 50,  
timeUnit: ‘10s’,  
duration: ‘5m’,  
preAllocatedVUs: 60,  
maxVUs: 6000,  
},  
},  
userAgent: \_\_ENV.RANGE\_BEGIN\_END  
};  
const usernames = new SharedArray(‘Get list account’, function () {  
return papaparse.parse(open(‘…/fixtures/accounts-peak-login.csv’), { header: false }).data;  
.data;  
})  
export default function () {  
const range = execution.test.options.userAgent.split(‘,’)  
const vuIndex = vu.idInTest - 1 + parseInt(range[0]);  
const currentUserName = usernames[vuIndex];

```
console.log(`${new Date().toISOString()} ${currentUserName} - ${__VU}: send request`)

```

}  
Và kết quả là dường như là 1s gửi 5 requests (50/10) instead send 50 requests for each 10 s

e[36mINFOe[0m[0000] 2025-01-15T07:18:38.502Z 011C078558 - 9: send request  
e[36mINFOe[0m[0000] 2025-01-15T07:18:38.702Z 011C077718 - 11: send request  
e[36mINFOe[0m[0000] 2025-01-15T07:18:38.903Z 011C077078 - 2: send request  
e[36mINFOe[0m[0001] 2025-01-15T07:18:39.103Z 011C077978 - 14: send request  
e[36mINFOe[0m[0001] 2025-01-15T07:18:39.304Z 011C041439 - 1: send request  
e[36mINFOe[0m[0001] 2025-01-15T07:18:39.502Z 011C079998 - 17: send request  
e[36mINFOe[0m[0001] 2025-01-15T07:18:39.702Z 011C078506 - 15: send request  
e[36mINFOe[0m[0001] 2025-01-15T07:18:39.902Z 011C078499 - 10: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.104Z 011C078629 - 21: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.303Z 011C079488 - 22: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.502Z 011C078256 - 12: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.702Z 011C078590 - 8: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.903Z 011C079107 - 19: send request

My expected is  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.903Z 011C079101 - 1: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.903Z 011C079102 - 2: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40.903Z 011C079103 - 3: send request  
…  
e[36mINFOe[0m[0002] 2025-01-15T07:18:40 011C079108 - 50: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:50 011C079108 - 51: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:50 011C079108 - 52: send request  
…  
e[36mINFOe[0m[0002] 2025-01-15T07:18:50 011C079108 - 100: send request  
e[36mINFOe[0m[0002] 2025-01-15T07:18:60 011C079108 - 101: send request

Thank you everyone for reading my post, and I look forward to receiving your support.

---

<div class="post-metadata">

**Author:** ![hoadoan](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@hoadoan](https://community.grafana.com/u/hoadoan)\
**Post date:** [January 15, 2025, 10:20am UTC](https://community.grafana.com/t/k6-how-to-send-x-requests-after-x-times/140350/2 "2025-01-15T10:20:06Z")

</div>

My problem has solved already so I will share my solution

export const options = {  
vus: 50,  
duration: ‘5m’,  
userAgent: \_\_ENV.RANGE\_BEGIN\_END  
}  
export default function () {  
const vuIndex = (\_\_VU - 1);  
const iterationIndex = execution.vu.iterationInScenario;  
const totalUsers = usernames.length;  
const totalRequests = options.vus \* (Math.floor((5 \* 60) / 10));  
const requestIndex = vuIndex + iterationIndex \* options.vus;  
const userIndex = requestIndex % totalUsers;

```
const currentUserName = usernames[userIndex]; 
console.log(`${new Date().toISOString()} ${currentUserName} - ${__VU}: send request`)

```

}

Thanks for reading my post.
