How to run a sequence of requests: one after another

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

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.

Thanks for your quick answer and a good idea.
I added disableCaching, but it still looks like nothing changes.

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)

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.

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)?

Should I choose doIf for second request and execute it if check is successful?

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?

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.

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?

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

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

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.

Thanks you all for all help!

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

Anna

Great!
Have fun!