What is a simulation Set-up in Gatling?

In simulation-setup, we define load we want to inject inside our server. The assertions and protocols can be configured with the help of the two methods:

One is assertions and the other one is the Protocols.


Let us see a sample injection. The definition of the injection profile can be done with the inject method. Example:

    nothingFor(4 seconds), // 1
    atOnceUsers(10), // 2
    rampUsers(10) over (5 seconds), // 3
    constantUsersPerSec(20) during (15 seconds), // 4
    constantUsersPerSec(20) during (15 seconds) randomized, // 5
    rampUsersPerSec(10) to 20 during (10 minutes), // 6
    rampUsersPerSec(10) to 20 during (10 minutes) randomized, // 7
    splitUsers(1000) into (rampUsers(10) over (10 seconds)) separatedBy (10 seconds), // 8
    splitUsers(1000) into (rampUsers(10) over (10 seconds)) separatedBy atOnceUsers(30), // 9
    heavisideUsers(1000) over (20 seconds) // 10

Let us analyze the injection profile we have mentioned above:

  • nothingFor(duration) : Pause the simulation for a given duration.
  • atOnceUsers(nbUsers) : This will inject a given number of users at a time.
  • rampUsers(nbUsers) over(duration) : This function inject users with a linear ramp-over within a given duration.
  • constantUsersPerSec(rate) during(duration): This function inject users at a constant rate, calculated as user per second, within a duration.
  • constantUsersPerSec(rate) during(duration) randomized: This function injects users at a constant rate. Users injected at randomized intervals.
  • rampUsersPerSec(rate1) to (rate2) during(duration): This function injects users from starting to target. Users will be injected in regular intervals.
  • rampUsersPerSec(rate1) to(rate2) during(duration) randomized: This function inject users from starting to target. Users are injected at randomized intervals.
  • splitUsers(nbUsers) into(injectionStep) separatedBy(duration): This function repeatedly executes the defined injection step separated by a pause.
  • splitUsers(nbUsers) into(injectionStep1) separatedBy(injectionStep2): This function repeatedly execute the first defined injection step, separated by the second injection step.
  • heavisideUsers(nbUsers) over(duration): This function injects a given number of users following a smooth approximation of the Heaviside step function stretched to a given duration.

Pause Configuration

The pauses can be configured before simulation and there are several methods to do that. Some are discussed below:

  • disablePauses:
  • Disable the pauses for the simulation.
  • constantPauses:
  • Specify the duration of each pause.
  • normalPausesWithStdDevDuration(stdDev: Duration):
  • Specified that the duration of each pause is in the average.
  • normalPausesWithPercentageDuration(stdDev: Double):
  • The duration of each pause is on the average, that specified in the Pause(duration) element and follow an normal distribution.
  • customPauses(custom: Expression[Long]):
  • The pause duration is measured by the Expression[Long].


Sometimes, might require to reason in terms of request per second rather than in terms of concurrent users per second. Therefore, to set the arrival rate of users, and also requests, we need for throttling.

For some reason by default, this may not be possible, therefore we there is the method throttle, for performing throttling. Let us see how the throttle can be build:

									setUp(scn.inject(constantUsersPerSec(100) during (30 minutes))).throttle(
									reachRps(100) in (10 seconds),
									holdFor(1 minute),
									holdFor(2 hours)

As shown in the above lines of codes, there are sub-functions that build the complete method.

  • reachRps(target) in (duration) : It targets a throughput with a ramp within a given duration.
  • jumpToRps(target) :
  • It jumps immediately to a given targeted throughput.
  • holdFor(duration) :
  • It holds the current throughput for a given duration.

Also, there is a method maxDuration. We can use this method, when we require to stop our simulation. It may be required at a time, when we may not be able to predict the time of the simulation and we may need to stop it as per our customized timings.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Protractor Training

new tutorial I am starting new Protractor training batch on Weekends. Course starts from 08-june-2019 [10am IST to 1 pm IST] based on online for 6 days, and course fee is INR 10, 000.

Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224

Find the course content : View Content