Hey :wave:, we have observed that our http4k appli...
# http4k
e
Hey 👋, we have observed that our http4k application will block at times when there is a long running request being processed separately. I.e. given this application:
Copy code
fun 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:
Copy code
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
Copy code
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.
d
Update: this seems to be a Netty specific issue (assuming it is one 😉)
e
I does seem to be reproducible with Netty but not with Jetty or Undertow. Definitely not a http4k issue 😅.