Throttling based on error rates

I’m looking into Gatling, and am attempting to integrate feedback into the throttling mechanism, in particular I’d like to stop a throughput ramp based on error rates. I know this has been talked about before, but the latest post on the matter I can find is from 9/2015, so I figured it’s fair game to ask again.

I’m not sure how this would be properly implemented, but as an initial pass I was hoping to dynamically update the throttle’s rps as errors come in. As a simple definition, let’s say that any time a scenario’s status is KO, the maximum rps would be set to the current rps. In pseudo-gatling, I was going to try and do something like:

class BasicSimulation extends Simulation {
val httpConf = http.baseURL(“”)

val throttleStep = reachRps(1000) in (10 minutes)

val scn = scenario(“BasicSimulation”)
.check(status).in(200 to 399))
.exec(session => {
if (session.status != OK) {
val newCap = somehowComputeCurrentRps() = newCap


Meaning, I inject a throttle into the simulation, and I’d dynamically adjust its target as I hit errors. In practice I’d want this logic to be more complicated, but I haven’t figured out exactly what I’d want to do (it’ll depend on what I can do). It’ll probably involve something like checking general error rates and if they’re out of spec go backwards in time until they go back in.

I have a feeling I could get this to work if I defined my own ThrottleStep implementation, but since ThrottleStep is a sealed trait, that’d require me to build my own custom version of Gatling, which I’d like to avoid doing. I’m also completely fine with it not being a generally applicable solution, since I can imagine this getting quite complicated when trying to handle a complicated throttle chain.

Any pointers on how one could hack this into a simulation? I’m not really looking for a solution that involves me manually watching graphs/log files to look for errors. Nor am I looking for a solution that completely aborts the Gatling run.