Incremental RPS scenario

Hello Team,

Can you someone help in creating such a wonderful scenario like below;

here i need to throttle RPS function

what i want here it is,

run 5 RPS → first 10 minutes
run 10 RPS → second 10 minutes
run 20 RPS → third 10 minutes
someone please put your thoughts or snippet on how to make this one

Hi @selva4,

Note: You are the one in charge of your own job.
Please show what you tested before asking code from others.

Did you read the documentation?
Specifically Shaping throughput already have snippets about things like you mention.

@sbrevet thanks for the reply, i am not aware shaping throughput section,

below is the my code

val injections = List(
    ScenarioList.filter(_._1 == "queryPerson").map(_ => personScenario.inject(atOnceUsers(ScenarioList.get("queryPerson").get + additionalUsers)).throttle(
      reachRps(ScenarioList.get("queryPerson").get) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.filter(_._1 == "queryCompanies").map(_ => CompanyScenario.inject(atOnceUsers(ScenarioList.get("queryCompanies").get + additionalUsers)).throttle(
      reachRps(ScenarioList.get("queryCompanies").get) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.filter(_._1 == "queryScoops").map(_ => scoopScenario.inject(atOnceUsers(ScenarioList.get("queryScoops").get + additionalUsers)).throttle(
      reachRps(ScenarioList.get("queryScoops").get) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.filter(_._1 == "queryOppAlerts").map(_ => oppAlertsScenario.inject(atOnceUsers(ScenarioList.get("queryOppAlerts").get + additionalUsers)).throttle(
      reachRps(ScenarioList.get("queryOppAlerts").get) in (5 seconds),
      holdFor(t_holdFor seconds)))
  ).flatten

i am going to enhance scenario like i mentioned in the scenario list.

It’s hard to read, because we cannot know what is this ScenarioList

As I understand your code, ScenarioList is a Map[String, Int]

val injections = List(
    ScenarioList.get("queryPerson").map(defaultUsers => personScenario.inject(atOnceUsers(defaultUsers + additionalUsers)).throttle(
      reachRps(defaultUsers) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.get("queryCompanies").map(defaultUsers => CompanyScenario.inject(atOnceUsers(defaultUsers + additionalUsers)).throttle(
      reachRps(defaultUsers) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.get("queryScoops").map(defaultUsers => scoopScenario.inject(atOnceUsers(defaultUsers + additionalUsers)).throttle(
      reachRps(defaultUsers) in (5 seconds),
      holdFor(t_holdFor seconds))),
    ScenarioList.get("queryOppAlerts").map(defaultUsers => oppAlertsScenario.inject(atOnceUsers(defaultUsers + additionalUsers)).throttle(
      reachRps(defaultUsers) in (5 seconds),
      holdFor(t_holdFor seconds)))
  ).flatten

What is visible, now, is that for each scenario name, you apply the same thing

val scenarioByName: Map[String, ScenarioBuilder] = Map(
  "queryPerson" -> personScenario,
  "queryCompanies" -> CompanyScenario,
  "queryScoops" -> scoopScenario,
  "queryOppAlerts" -> oppAlertsScenario
)

val injectionNames = List("queryPerson", "queryCompanies", "queryScoops", "queryOppAlerts")

val injections = for {
  name <- injectionNames
  scn = scenarioByName(name)
  defaultUsers <- ScenarioList.get(name)
} yield scn.inject(atOnceUsers(defaultUsers + additionUsers))
  .throttle(
    reachRps(defaultUsers) in 5.seconds,
    holdFor(t_holdFor seconds)
  )

So, the only interesting part for your request is:

scn.inject(atOnceUsers(150))
  .throttle(
    reachRps(100) in 5.seconds,
    holdFor(10.minutes)
  )

Now, we can answer your initial question:
You can enhance the last throttle, to add more steps, like so:

scn.inject(atOnceUsers(150))
  .throttle(
    reachRps(5) in 1.seconds,
    holdFor(10.minutes),
    reachRps(10) in 1.seconds,
    holdFor(10.minutes),
    reachRps(20) in 1.seconds,
    holdFor(10.minutes),
  )

Cheers!

1 Like