Gatling Multiplier Parameter

Published: November 3, 2019

Tags:

Typically, when load testing a system with Gatling, I create a simulation script which consists of a number of scenarios which are executed simultaneously at different ratios. Execution of the scenarios would look something like this:

setUp(
    BouncerHome.inject(rampUsers(360) during (300 seconds)),
    BrowserCategory.inject(rampUsers(60) during (300 seconds)),
    Searcher.inject(rampUsers(40) during (300 seconds)),
    Uncached404.inject(rampUsers(40) during (300 seconds)),
    UncachedPdp.inject(rampUsers(60) during (300 seconds)),
    PurchaseIntent.inject(rampUsers(10) during (300 seconds))
).protocols(httpProtocol)

I then run the simulation a number of times, gradually increasing the load to identify the breaking point.

For example, after running at the ratios above I might double the load as follows:

setUp(
    BouncerHome.inject(rampUsers(720) during (300 seconds)),
    BrowserCategory.inject(rampUsers(120) during (300 seconds)),
    Searcher.inject(rampUsers(80) during (300 seconds)),
    Uncached404.inject(rampUsers(80) during (300 seconds)),
    UncachedPdp.inject(rampUsers(120) during (300 seconds)),
    PurchaseIntent.inject(rampUsers(20) during (300 seconds))
).protocols(httpProtocol)

Then triple (and so on and so forth).

Rather than manually increasing the number of users for each scenario for each test, a better way is to pass a “multiplier” as a command line parameter when invoking Gatling.

Our Gatling script would now look like this…

val multiplier = Integer.getInteger("multiplier", 1)

setUp(
    BouncerHome.inject(rampUsers(360 * multiplier) during (300 seconds)),
    BrowserCategory.inject(rampUsers(60 * multiplier) during (300 seconds)),
    Searcher.inject(rampUsers(40 * multiplier) during (300 seconds)),
    Uncached404.inject(rampUsers(40 * multiplier) during (300 seconds)),
    UncachedPdp.inject(rampUsers(60 * multiplier) during (300 seconds)),
    PurchaseIntent.inject(rampUsers(10 * multiplier) during (300 seconds))
).protocols(httpProtocol)

Now, in order to double the load, instead of increasing the user values for each scenario we’d pass a multiplier value of “2” when invoking Gatling as follows:

$ JAVA_OPTS="-Dmultiplier=2" bin/gatling.sh

Max Chadwick Hi, I'm Max!

I'm a software developer who mainly works in PHP, but loves dabbling in other languages like Go and Ruby. Technical topics that interest me are monitoring, security and performance. I'm also a stickler for good documentation and clear technical writing.

During the day I lead a team of developers and solve challenging technical problems at Rightpoint where I mainly work with the Magento platform. I've also spoken at a number of events.

In my spare time I blog about tech, work on open source and participate in bug bounty programs.

If you'd like to get in contact, you can find me on Twitter and LinkedIn.