What is drift?

I created a custom action to support plain socket requests with gatling 2.0 snapshot . It works pretty well, but i noticed that in some cases, e.g. in scenario like this:

.exec {action1}
.pause(5 seconds)
.exec(during(sessionLength) {
50.0 → action2
, 50.0 → action3
).pause(5 seconds)

the delay between action1 and action2 is much larger than 5 seconds (more like 50) (for 200 users)

I dived into io.gatling.core.action.Pause and see it is using something called drift and in AsyncHandlerActor i see tx.next ! updatedSession.increaseDrift(nowMillis - response.lastByteReceived)

So i wonder how do i use drift correctly in my custom action, and why are pauses so much larger than configured.

Thanks, Aleh

drift is used to account for scheduling (Gatling uses Akka’s scheduler, which sacrifice accuracy for better thoughput) and computing durations.
Drift is then substracted to pauses, but anyhow, pauses can’t be greater than configured value.

“the delay between action1 and action2 is much larger than 5 seconds (more like 50)”

Which delay are you talking about? action2.start - action1.end? or action2.start - action1.start? If the latter, that’s not how Gatling works.
Isn’t this delay expected?

action2.start - action1.end

here is the handler btw http://scastie.org/4567

and here is an excerpt from simulation.log
Standard User 6689134314771824142-102 USER START 1394712155582 0
Standard User 6689134314771824142-102 REQUEST action1 1394712155582 1394712155582 1394712158340 1394712158340 OK
Standard User 6689134314771824142-102 REQUEST action2 1394712202893 1394712202893 1394712202896 1394712202896 KO invalid status 401 Session expired

action2.start - action1.end

Are you sure that it's just that sometimes it takes very long for a given
user to switch to action2. If you run enough users, some might switch to
action3 for a long time.

Also, what’s your snapshot timestamp?

Yeah i’m sure it’s the delay between the first action and the a random one in switch.

The snapshot was built at 08:31 UTC today

Then that’s very weird.
Could I get the server you’re testing too, please? I’d like to reproduce.

Do you mean the application under test? Can’t really expose it, but it’s a pretty dumb app using akka io to handle protobuf formatted requests. Action1 is a login request which returns session id and all other actions are using it in subsequent requests.
Curiously, even with ten users i get at least one which is significantly delayed.
Here is the full log https://drive.google.com/file/d/0B_GCeoyWdXfMeFFsM3FVZTJvRUU/edit?usp=sharing

I suspect a bug with randomSwitch (that I thought I had fixed).

What happens if you change the switch to:

50.0 → action2.pause(5 seconds
, 50.0 → action3.pause(5 seconds

No, the randomSwitch fix looks fine.

Did you try the change I suggested?
Could I have a look at your simulation, please?

I found the culprit.
seems like .pauses(uniformPausesPlusOrMinusPercentage(10)) is causing this.
Without it the pauses are close to 5 seconds as expected.

Just in order to confirm, lowering log level to INFO will display pause durations.

Get it.
uniformPausesPlusOrMinusPercentage expects 0.1, not 10.

I will change it so it works as you expect and 10 = 10%, not 1000% :slight_smile:

Fixed! https://github.com/excilys/gatling/issues/1702

Sorry for this stupid mistake and thanks for reporting!