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:
assertions and the other one is the
Let us see a sample injection. The definition of the injection profile can be done with the inject method. Example:
setUp( scn.inject( 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 ).protocols(httpConf) )
Let us analyze the injection profile we have mentioned above:
The pauses can be configured before simulation and there are several methods to do that. Some are discussed below:
Pause(duration)element and follow an normal distribution.
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), jumpToRps(50), holdFor(2 hours) )
As shown in the above lines of codes, there are sub-functions that build the complete method.
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.