Different number of iterations for a single VU

Hello, I’m pretty new to k6 and was wondering how to structure the following scenario !

I have a script as below :

export default function () {


function  login () { //some code here }
function  deposit_100_Euros_Cash () { //some code here }
function  withdraw_5_Euros_Cash () { //some code here }


What I want to achieve is for a VU to login, execute login() and deposit_100_Euros_Cash(); once but execute withdraw_5_Euros_Cash(); 20 times. How do I go about this ? Should I be using scenarios ?

Depends - if separate scenarios work in your case, sure, you can use that. But if all of these calls should happen sequentially, which seems to be the case from their names, you can just call the withdraw_5_Euros_Cash() function in a for loop 20 times.

Thank you for the reply Ned. Yes these should be executed sequentially. I could use loop but was wondering if there is a better solution

There might be, depending on what you want to do :grinning_face_with_smiling_eyes: For example, if you want the withdraw to happen concurrently, you can maybe use http.batch() to do it? And you can probably use scenarios to simulate even more sophisticated workflows with some effort.