[SOLVED] I have this get shown below very simple, ...
# ktor
c
[SOLVED] I have this get shown below very simple, does nothing pretty much. I want to simulate an API call which takes 5 seconds to process. If I send 5 http requests within one second, from the trace I see ktor processing one at a time logging: call incoming! call finished! call incoming! call finished! call incoming! call finished! call incoming! call finished! .... This is not what I wanted, what I expected was: call incoming! call incoming! call incoming! call incoming! call incoming! call finished! call finished! call finished! call finished! call finished! Why is ktor not processing the calls in parallel?? @e5l @cy I have 4+4 connectionGroupSize/workerGroupSize threads shared and 8 callGroupSize all setup
e
Hi @coder82, what server engine do you use?
c
netty
and this is how I bootstrap it
Bootstrap.kt
ktor 1.2.2, wondering if I was doing something wrong
I am updating to 1.2.3 to see if something changes
same with newest version, it feels like get requests are getting queued and processed one at a time
I just discovered that if I move the delay(5000) after the call.respond statement, then I see what I want... incoming incoming incoming incoming incoming finished finished finished finished finished
but obviously this doesn't solve the issue because normally a delay happens before I respond because I need to do some blocking calls prior responding of course...
Uhm, one at a time... I am trying to figure out what's wrong...
d
are making calls from the same client?
c
i do, yes from within browser, but I also have a test which uses okhttp and i get the same behavior
well the video doesn't demonstrate much because I would see exactly the same if KTOR processes in parallel
d
maybe the issue with the client?
do you actually make parallel request?
or the client waits for server to respond?
c
let me double check that the client test calls are not blocking, your point is valid
the browser might actually not send parallel as I read in the docs
so can't trust it
wait
brb
turns out you were right
your question pointed me to rewrite the test making sure requests went in parallel
I was mislead by the browser...
in reality the browser doesn't send in parallel, it tries to act smart like explained in the asynchronous example from ktor site
so i rewrote my test like this:
Untitled
and I get the trace i wanted to get:
Untitled
hey! thanks!
😄
i wonder if there was a way to force the browser to send parallel requests!
d
no worries, just didn't make sense to me why your ktor setup wouldn't work 😛
what kind of browser is that on the video? it looks more like postman or something
c
it's the generated doc for like a swagger api, it runs in the browser
it's using "rapidoc" to generate the documentation out of a yaml open api 3.0 spec
so it's a normal chrome page sending XHR requests via javascript
i fugured it all out
wow
disable browser cache and it will send parallel requests
if you send multiple requests to the same url, the browser will wait the first to complete before sending the others so that it can reuse the first answer from the cache
lol
always the friggin' cache
i have it disabled by default on the tools but, on this machine the setting didn't propagate
will show it in a new video:
Now they go in parallel also from browser...
perfect 5 secs processing time
👍
perfect
d
nice
c
that's what i want to see
😄