Gatling Multiplier Parameter

Published: November 3, 2019


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:

    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))

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:

    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))

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)

    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))

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/

Max Chadwick Hi, I'm Max!

I'm a software developer who mainly works in PHP, but also dabbles in Ruby and Go. Technical topics that interest me are monitoring, security and performance.

During the day I solve challenging technical problems at Something Digital where I mainly work with the Magento platform. I also blog about tech, work on open source and hunt for bugs.

If you'd like to get in touch with me the best way is on Twitter.