Skip to content

Using Load Generators

Christopher Bradford edited this page Oct 17, 2018 · 3 revisions

There are several types of Load Generator methods that are available in the framework. All of which are helpers for Gatling's built in load injections (https://gatling.io/docs/2.3/general/simulation_setup).

Load is based on a Gatling User sequence which contains actions/queries and execs during a single second. If a scenario has multiple exec() methods included in it then the total number of queries will be Gatling Users X execs. This is important to remember if using the repeat() function from Gatling or having multiple chained queries in the same scenario.

Standard Loads

Each of the load methods accept both a Gatling Scenario variable and a SimConf variable. The simConf is used to read the params found in the application.conf or runtime variables to determine the load to use. An error will be thrown if the load pattern being used cannot find the correct settings in the application.conf file.

constantToTotal

constantToTotal() load pattern will auto-calculate the total amount of time to run the Simulation based on the usersConstantCnt until the usersTotal is reached.

Required Conf Parameters:

  • usersConstantCnt: Int
  • usersTotal: Int

Example:

constantScenario {
  usersConstantCnt = 100
  usersTotal = 1000
}

constantScenario load will be: run 100 users per second for 10 seconds (1000/10)

rampUpToConstant

rampUpToConstant() load pattern will ramp up from 1 user to usersConstantCnt users over usersConstantCnt time and continue with usersConstantCnt users for the duration of usersConstantTime

Required Conf Parameters:

  • usersRampTime: Duration
  • usersConstantCnt: Int
  • usersConstantTime: Duration

Example:

myscenario {
  usersRampTime = 10s
  usersConstantCnt = 100
  usersConstantTime = 30s
}

myscenario load will be: ramp from 1 to 100 users over 10s and continue with 100 users per second for 30 seconds

Note: If usersConstantCnt = 1 the rampTime will be bypassed.

rampUpToPercentage

rampUpToPercentage() load pattern will calculate the amount of users for each scenario in the Simulation based on the usersPercentage found in each scenarios conf section.

When using this load pattern the usersRampTime, usersConstantTime, and usersConstantCnt should be in the Simulations defaults section and usersPercentage should be set in each scenarios config section.

Required Conf Parameters:

  • usersRampTime: Durations
  • usersConstantTime: Duration
  • usersConstantCnt: Int
  • usersPercentage: Int

Example:

defaults  {
  usersRampTime = 10s
  usersConstantCnt = 100
  usersConstantTime = 30s
}
myscenario1 {
  usersPercentage = 40
}
myscenario2 {
  usersPercentage = 60
}

myscenario1 load will be: ramp from 1 to 40 users over 10s and continue with 40 users per second for 30 seconds

myscenario2 load will be: ramp from 1 to 60 users over 10s and continue with 40 users per second for 30 seconds

Note: If usersConstantCnt = 1 the rampTime will be bypassed.

Debugging

runOnlyOnce

This method should be used for debugging purposes as it will only create a 1 User