Creating random bursts of load?

I’m looking for some advice on the best way to achieve the following load test

What we are looking to get is some random bursts of traffic to a specific api endpoint whilst maintaining a constant load on the rest of the api. Stages would look something like this, but a lot more of them

stages : [
  {target : 0, duration: '345s'},
  {target : 13, duration: '2s'},
  {target : 0, duration: '499s'},
  {target : 7, duration: '2s'},
  {target : 0, duration: '291s'},
]

What I have so far is

  • a function that generates the array of random stages based on (seeded for repeatability)
  • apply that array to the scenario
  • run the test

Given that the init context runs runs once per VU is this a sensible approach?

simplified sample of what the relevant init code looks like.

const burstStages = randomStages(burstParameters) // this function returns an array of stages which are used when setting up the scenario below

export const options = {
  scenarios: {
    BaseLoadScenario: {
      executor: "constant-vus",
      exec: "baseload",
      duration: testDuration,
      vus: 70,
    },
    BurstyScenario: {
      executor: "ramping-arrival-rate",
      exec: "burst",
      preAllocatedVUs: 30,
      startRate: 0,
      timeUnit: "1s",
      stages: burstStages
    },
  }
}

hi @steverivers95,

Given that the init context runs runs once per VU is this a sensible approach?

You can always only do it on the VU with __VU == 0 with an if, but IMO it doesn’t really matter.

You can probably test it and see how much it adds to the actual time to start. I expect that as long as you don’t make thousands of stages with thousands of VUs it will not matter all that much.

You can run with -v to see how fast VUs are started as well

Hope this helps!

Thanks for those suggestions, I will continue my investigation now I’m back from vacation :slight_smile: