# http4k

Eduardo Narros

11/16/2021, 6:09 PM
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()

        "/sleep" bind Method.GET to {
            Thread.sleep(20000).body("woke up")
        "/info" bind Method.GET to { Response(Status.OK).body(counter.addAndGet(1L).toString() + " ") },
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.


11/16/2021, 6:57 PM
Update: this seems to be a Netty specific issue (assuming it is one 😉)

Eduardo Narros

11/16/2021, 8:06 PM
I does seem to be reproducible with Netty but not with Jetty or Undertow. Definitely not a http4k issue 😅.