Gatling parallel requests from one session

3,581 views
Skip to first unread message

Yegor Andreenko

unread,
Oct 5, 2015, 2:24:42 PM10/5/15
to Gatling User Group
I haven't found the answer in previous topic, also the question is quite popular. I have http client that create some application session and request resources during it.

  val scn = scenario("App session")
    .exec(
http("Authorize")
.get("/authorize")
.queryParam("token", token)
.queryParam("version", version)
.check(bodyString.saveAs("key"))
).exec {
val array = csv("entities.csv").records.flatMap(r => r.seq.values)
foreach(array, "record") {
exec {
http("Get ${record}")
.get("/dump?key=${key}")
.queryParam("model", "${record}")
}
}
}
  setUp(scn.inject(
  rampUsers(3) over(30 seconds)
  )).protocols(conf)

As you can see in second `exec` client iterate some entities and request them sequentially.
I should emulate client does 4 requests in parallel. Client asks and waits answers, If it finishes with one request move to the next, another 3 would be waiting. And so on.
Does anybody know the recipe? 

Alex R.

unread,
Oct 5, 2015, 10:06:48 PM10/5/15
to Gatling User Group
Hi,

What exactly do you need?
I see collision here - "client does 4 requests in parallel" and "it finishes with one request move to the next, another 3 would be waiting"


Thanks,
Alex.

Yegor Andreenko

unread,
Oct 6, 2015, 3:26:17 AM10/6/15
to Gatling User Group
Sorry, I might be not clear. 
Given for example 100 urls to request client has 4 connections.

Alex R.

unread,
Oct 7, 2015, 12:47:11 AM10/7/15
to Gatling User Group
Ok I see,
If you want 4 users each with 100 urls (400 urls total) your code should be OK, just put atOnceUsers(4) or ramp to 4 users in setUp method
If you want 4 users with total 100 urls you have to provide correct repeat value for each user, for example:

val users = 4
val records = csv("entities.csv").records.count - 1

val scn = scenario("App session")
    .exec(
http("Authorize")
.get("/authorize")
.queryParam("token", token)
.queryParam("version", version)
.check(bodyString.saveAs("key"))
)
        .repeat (records / users) {
            feed(csv("entities.csv"))
            .exec {

                 http("Get ${record}")
.get("/dump?key=${key}")
                .queryParam("model", "${record}")
            }
        }
}

setUp(scn.inject(atOnceUsers(users)))


Thanks,
Alex.

Yegor Andreenko

unread,
Oct 7, 2015, 7:59:21 AM10/7/15
to Gatling User Group
Actually you didn't get the idea.
We have clients = N and parallelConnections = M.

        val parallelCount = M

val dumps = scenario("Dumps")
.repeat(array.length / parallelCount) {
feed(csv("entities.csv"))
.exec {
http("Dump ${entity}")
.get("/dump?key=${syncKey}")
.queryParam("model", "${entity}")
}
}


val scn = scenario("App session")
    .exec(
http("Authorize")
.get("/authorize")
.queryParam("token", token)
.queryParam("version", version)
.check(bodyString.saveAs("key"))
).exec(
dumps.inject(atOnceUsers(parallelCount)).scenarioBuilder
)

       setUp(scn.inject(
  rampUsers(N) over(10 seconds)
  )).protocols(conf)

Something like this. This code compile, but doesn't do parallel `http("Dump ${entity}")` for M.

John Arrowwood

unread,
Oct 7, 2015, 9:06:15 AM10/7/15
to Gatling User Group
You are trying to "exec( scenario )" - you can't do that.  Re-think what you are doing and follow the patterns in the documentation.

Yegor Andreenko

unread,
Oct 7, 2015, 12:02:30 PM10/7/15
to Gatling User Group
John, I investigated the documentation and think that
1. Gatling doesn't have such functionality from the box
2. My application creates and manages specific `applicationSession`, and it's difficult scenario that isn't covered by Gatling.

John Arrowwood

unread,
Oct 7, 2015, 12:08:15 PM10/7/15
to gat...@googlegroups.com
Gatling can not call one scenario from within another scenario, but it can call a CHAIN from within another chain.

It looks like what you are really trying to do is have the first virtual user get a token, and all subsequent users use the same token.  Is that how the application would be used in the real world?  Multiple clients all using the same token?  Or would each client have its own token?

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/voqKtBSqIoc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
John Arrowwood
503.863.4823

Reply all
Reply to author
Forward
0 new messages