Search⌘ K

User Injection Profiles

Explore different user injection methods in Gatling to simulate various load scenarios. Understand functions like atOnceUsers, rampUsers, and constantUsersPerSec to create realistic performance tests and improve your script's load simulation capabilities.

In the previous lesson, we learned about the different ways to pass test data to the Gatling test script using Feeders. In this lesson, we will learn about the different ways to inject users into the simulation.

Gatling provides various ways to inject users and stimulate the load on the environment.

atOnceUsers

Injects a specific number of users at the same time.

Example:

scn.inject(atOnceUsers(10))
Scala
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class SampleSimulation extends Simulation {
val httpProtocol = http
.baseUrl("http://localhost:8080/api/users")
.acceptHeader("*/*")
.doNotTrackHeader("1")
.userAgentHeader(
"Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
)
.disableWarmUp
.disableCaching
val getScenario = scenario("BasicSimulation - GET")
.exec(
http("GET request")
.get("/")
.check(status.is(200))
)
setUp(getScenario.inject(atOnceUsers(10))).protocols(httpProtocol)
}

constantUsersPerSec

Injects the number of users each second for the given duration.

Example:

scn.inject(constantUsersPerSe
...