How to model the mix of transactions changing as a function of total volume

I’ve analyzed the traffic to my service, and I find that the mix of transactions varies as a function of volume. As overall traffic increases, some flows take up an increasingly larger and larger percentage of the traffic. Others remain flat no matter how much traffic there is overall.

What I’d LIKE to do, if it is technically feasible, is to model the traffic where the percentage of the time when a certain flow is triggered is a function of the total traffic volume. Then as the target volume goes up, instead of taking on a fixed percentage of the traffic, it dynamically adjusts to more closely match what we really see. Basically, I’m thinking a dynamic randomSwitch.

Now, as I recall, randomSwitch can only take constants, not functions, so I can’t model it that way.

What I assume I can do is write a function that calculates the percentages for each flow as a function of total volume and randomly chooses which flow to use, then use a regular switch to actually trigger the flows.

So my question to you is: in my function, how do I know what the target user injection rate is at that moment? For instance, rampUsersPerSec( 5 ) to (100 ) over (2.hours) - half way through the simulation, the users per second rate should be a little over 50. Is there a way I can ask Gatling what the current injection rate is in users per second?

If not, can you think of another way of accomplishing what I’m trying to do?

I’m not sure if that kind of data it’s eseally avaiable but I have a few ideas how to do it without this data,
the best one and with very precise control will be Concurrent Scenarios where every single flow have it individual injectionProfile, example:

                    rampUsers(20).during(10), rampUsersPerSec(20).to(5).during(10), constantUsersPerSec(5).during(15)
                    rampUsers(5).during(10), rampUsersPerSec(5).to(20).during(10), constantUsersPerSec(20).during(15)

Hi John,

a certain flow is triggered is a function of the total traffic volume

Gatling doesn’t expose any stats to the simulation. Also, what would “traffic” mean? injected users per second? concurrent users? rps? “traffic” can means different things to different persons.

Assuming you know what your “traffic” is at any time, what would work is building a switch with function of time (since start).

Pseudo code:

private final long startTimestamp = System.currentTimeMillis();

.exec(session -> {
     long secondsSinceStart = (System.currentTimeMillis() - startTimestamp) / 1000;
     return session.set("choice", computeRandomChoice(secondsSinceStart));
  Choice.withKey("choice1", chain1),
  Choice.withKey("choice2", chain2),

Hope it helps.

Hmmm. An interesting idea.

I’ll have to think about how to make that work for my use case.