Eduardo Narros
11/16/2021, 6:09 PMfun main() {
val counter = AtomicLong()
routes(
"/sleep" bind Method.GET to {
Thread.sleep(20000).body("woke up")
Response(Status.OK)
},
"/info" bind Method.GET to { Response(Status.OK).body(counter.addAndGet(1L).toString() + " ") },
).asServer(Netty(7000)).start()
}
If you run it and then using a terminal you run:
curl localhost:7000/sleep& for run in {1..20}; do curl localhost:7000/info; done
you would expect to see all the 20 /info responses and then the initial /sleep response after a few seconds.
However, what happens is that you get around 15 /info responses, then the next request blocks until the /sleep request completes and then the remaining requests are completed. i.e.
curl localhost:7000/sleep& for run in {1..20}; do curl localhost:7000/info; done
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 woke up
16 17 18 19 20
We have tried in different machines and we most of the time you get up to around 15 before the request blocks so we don’t know if that number is driven by a configuration parameter that we aren’t aware of.dave
11/16/2021, 6:57 PMEduardo Narros
11/16/2021, 8:06 PM