Hi,
This is my requirement. I need to measure how much time an async call takes to finish. Gatling calls an API, it immediately returns a response/ack and behind the scenes the task is picked up from queue and once finished, the database is updated. I will either have an API to query that resource(which will eventually check DB) or I need to directly query DB. The resource might take few secs to get generated in DB. Let me know the best way how to do it?
Group(Async API, Query API/DB Query). I need to measure the time for this group to complete. I am not asking where the time has gone.
So first, is your group at the right place?
I have corrected the group. Attaching the code. I guess now it is correct.
Then, you didnât provide any information about how many times the asLongAs
loop ends up being executed, nor how long checkPersonGenerated
takes.
The loop should execute till it gets the resource that should have been created. To avoid bombarding query API, I am introducing a delay.
This is were the extra seconds are being spent.
Yes, I know
Finally, if checkPersonGenerated
is a blocking call (JDBC maybe?), it will harm performance under load. How bad depends on how long it takes.
I am not asking where the time has lost. I know. As I mentioned above, I have switched to API call which eventually queries DB only. It is fast. Please see the simulation logs attached.
Let me know if attached logs are as it should be.
ChainBuilder search =
repeat(3, "n").on((feed(jdbcFeeder).exec(session -> {
Object req = session.get("person_request");
return session;
}).group("Async")
.on(
exec(
http("CreatePerson API")
.post("/owners/new").body(StringBody("#{person_request}"))
.check(status().is(200))
).pause(1).asLongAs(session -> !dataAvailable(session))
.on(
//exec(this::checkPersonGenerated)
exec(
http("Find Person API")
.post("/owners").body(StringBody(findPersonJson(searchLastName)))
.check(status().is(200)).check(bodyString().saveAs(
"person-resp"))
).exec(this::checkPersonGenerated).pause(2)
)))
.pause(1));
One question, For group timing, why it is showing 19ms, 3ms, 3ms. The difference of start and end time which is what I want is coming to be 13 sec, 1 sec, 1 sec approx. That is what I want.
I have executed group 3 times. Only one group I could introduce artificial delay in create a resource at the backend.