How to run a sequence of requests: one after another

4,159 views
Skip to first unread message

Anna Bryzhevskaya

unread,
Dec 12, 2014, 1:07:49 PM12/12/14
to gat...@googlegroups.com
Hello all!

Could you please help me with one moment in scenario?

I have a sequence of requests and I want to start second request after the first, third after second and so on.
Or may be it i a possibility to execute second request as a subrequest (or a part) of first request 

My scenario looks so:



package basic

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class SomeSimulation extends Simulation {
val  scn
= scenario("My scenario").during(600 seconds) {
exec(
http
("First")
.get("http://myserver/some/")
.check(xpath("/result/href/text()").find.saveAs("other"))
)
.exec(
http
("Second")
.get("${other}")
.check(status.is(200))
)
.exec(
http
("Third")
.get("http://myserver/something/else")
)

}
setUp
(scn.inject(atOnceUsers(10000)
))
.throttle(
reachRps
(4000) in (600 seconds),
holdFor
(120 seconds)
)
}


After running the test I see that at first I have few thousands of "first" requests, 
And then the second requests start - and requests are failed, because "other" attribute could not be found 
This "other" attribute is different for every request. 

How can I reach the sequential query execution:
- first
-second
-third
-first
-second
-third 
...
and so on... ?

Thanks in advance,

Anna

Abhinav Gogna

unread,
Dec 12, 2014, 1:36:20 PM12/12/14
to gat...@googlegroups.com
This may not be the right answer but I noticed when I disabled caching globally, I had same number requests for each one of the exec in my chainbuilder.

Anna Bryzhevskaya

unread,
Dec 12, 2014, 2:21:28 PM12/12/14
to gat...@googlegroups.com
Thanks for your quick answer and a good idea.
I added disableCaching, but it still looks like nothing changes.

Abhinav Gogna

unread,
Dec 12, 2014, 2:48:22 PM12/12/14
to gat...@googlegroups.com
Also, you are injecting 10000 users at once. Then throttling for certain time, which does not look right.

Try simple simulation for debugging

setUp(
    scn.inject(rampUsers(10) over (10 seconds))
).protocols(httpProtocol)

Pierre DAL-PRA

unread,
Dec 12, 2014, 2:54:27 PM12/12/14
to gat...@googlegroups.com
The problem here is that the second request depends on the success of the first request, since the URL you're hitting is captured from the response to the first request, using a check.
Therefore, if the check fails on the first request, you don't know which URL you're supposed to hit for second request, hence the failure.

You just can't get around this, unless you have another way to know which URL to hit on the second request.
--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anna Bryzhevskaya

unread,
Dec 12, 2014, 3:08:48 PM12/12/14
to gat...@googlegroups.com
I tried with small number of users for debugging and it works correctly.
How can I reach the same behaviour with 10k rps (total for all requests)? 

Anna Bryzhevskaya

unread,
Dec 12, 2014, 3:12:33 PM12/12/14
to gat...@googlegroups.com
Should I choose doIf for second request  and execute it if check is successful? 


On Friday, December 12, 2014 11:54:27 PM UTC+4, Pierre DAL-PRA wrote:

Pierre DAL-PRA

unread,
Dec 12, 2014, 3:13:33 PM12/12/14
to gat...@googlegroups.com
In that case, the problem is that your SUT simply cannot handle that load, and requests start failing a lot (hence the check that fails).
Are your sure injecting 10000 users is what you want?

Pierre DAL-PRA

unread,
Dec 12, 2014, 3:18:04 PM12/12/14
to gat...@googlegroups.com
TBH, not sure that this is the right solution.
If the fact that the second request fails because the check failed for the first request and that check fails because the your system can't handle the load you're injecting, you would, in a way, only hide away that your SUT can't handle that load.

Anna Bryzhevskaya

unread,
Dec 12, 2014, 3:21:07 PM12/12/14
to gat...@googlegroups.com
I try to reach a load from 1 to 10k requests per second using throttling.
Should I use other method of injecting users, for example rampUsers(10000) over (600 seconds) and then use throttling for current requests rate? 

Abhinav Gogna

unread,
Dec 12, 2014, 5:50:31 PM12/12/14
to gat...@googlegroups.com
Anna,

Why do you want to throttle. If your goal is to simulate load with certain number of users then just ramp up to that many. As is you are using during to run for a certain amount of time. My suggestion is to start small and gauge at which point your application starts to fail or show declined response time in 90th or 95th percentile. Once you have a good grasp on those numbers then play with throttle. At that point, you will have a better understanding of how much your application can handle and you will be able to throttle properly.

Hope that helps.
Abhinav

Anna Bryzhevskaya

unread,
Dec 12, 2014, 6:06:13 PM12/12/14
to gat...@googlegroups.com
Thanks a lot, I ll try it morning!
I throttle because I think that creating users during the whole test is too expensive.
Also I don't need new users every second so it's ok to create users at once at the beginning of the test and then only reach current rps

I try to test with injecting users.
Thank you once again

Stéphane Landelle

unread,
Dec 13, 2014, 4:39:12 AM12/13/14
to gat...@googlegroups.com
I throttle because I think that  creating users during the whole test is too expensive.
Why is that? Probably some preconception from using other tools.

Anna Bryzhevskaya

unread,
Dec 15, 2014, 6:32:12 AM12/15/14
to gat...@googlegroups.com
Thanks you all for all help! 

It`s totally working now with injection without throttling!
Perfect powerfull tools!


Anna

Stéphane Landelle

unread,
Dec 15, 2014, 7:53:17 AM12/15/14
to gat...@googlegroups.com
Great!
Have fun!

--
Reply all
Reply to author
Forward
0 new messages