Advice regarding "incrementUsersPerSec" injection

Hi Community, I will appreciate your advice.
I would like to inject “agents” starting with 1 agent and increasing each time with X users , I assume that I need something like that:

  // generate an open workload injection profile
  // with levels of 10, 15, 20, 25 and 30 arriving users per second
  // each level lasting 10 seconds
  // separated by linear ramps lasting 10 seconds
      .startingFrom(10) // Double

my issue is that I want to control the max users (no.).
for example:
Start with 1-Agent - 10A - 20A ..............(max no that I select)
this test duration should be for few hours (Lets say 8h).

my main goal is to test our aws micro service auto scaling.

thanks for you r advice.

Hello Sahar,

If I understand correctly, you want your open workload model to have a cap value for incrementUsersPerSec.

When I have cases that don’t fit the meta DSL exactly, I try to generate a list of simpler steps from the parameters I have available. For example, below I simulate the load a system would receive if it was sitting behind a queue (used in simulations where the queue is not available for various reasons):

def queue(totalVisitors: Int, queueRate: Int) = {
  val cycles = 1 to totalVisitors / queueRate
  val remainingUsersInjectionStep =  heavisideUsers(totalVisitors % queueRate) during (1 minute)
  cycles.flatMap(_ => List(
    heavisideUsers(queueRate) during (1 minute)
  )).toList :+ remainingUsersInjectionStep

This way I translate the available parameters I have to the profile I want. A possible solution for your case could look something like this:

def myProfile(initialUserRate: Int, secondLevelUserRate: Int, userRateIncrement: Int, rampDuration: Int, levelDuration: Int, totalDuration: Int, maxUserRate: Int) = {
  val initialCycle = incrementUsersPerSec(secondLevelUserRate - initialUserRate)

  val cycles = (maxUserRate - secondLevelUserRate) / userRateIncrement
  val incrementalRateCycles = incrementUsersPerSec(userRateIncrement)

  val remainingConstantRateCyclesDuration = totalDuration - (levelDuration + rampDuration) * (cycles + 1)
  val remainingConstantRateCycles = constantUsersPerSec(maxUserRate).during(remainingConstantRateCyclesDuration)

  List(initialCycle, incrementalRateCycles, remainingConstantRateCycles)

Treat this as pseudocode as I haven’t tested any of it. I am also assuming that the duration of your test will allow it to reach the max rate specified and that (maxUserRate - secondLevelUserRate) / userRateIncrement has no remainder. Also, if you don’t have a single user starting the test you might wanna get rid of the initial cycle altogether. All times are in seconds.

Take everything with a grain of salt as I am a noob in Gatling myself and your solution might be as simple as an extra function that I am not aware of. :slight_smile:

Thanks gkallergis!!
I will check it and replay

1 Like