Hi. For Http4k based services, what's the recomme...
# http4k
s
Hi. For Http4k based services, what's the recommended approach to improve scalability? The problem I'm experiencing is that under heavy concurrent load, when upstream dependencies start slowing down, the service just runs out of threads and stops responding. The current setting is
Copy code
val customJetty = jettyServer(maxRequestThreads = 200, meterRegistry = prometheusMeterRegistry)
myService.asK8sServer(serverConfig = customJetty, environment, healthApp = healthApp()).start()
With a Quarkus based framework I'd switch to virtual threads using an annotation and that solves the issue. For http4K, should we switch to a different http server or change config for the existing one? Is the recommended approach to try and use java virtual threads?
m
You can switch to other servers, probably easies would be Jetty, as it comes with
JettyLoom
https://www.http4k.org/ecosystem/http4k/reference/servers/
s
Thank you. I'll have a look into JettyLoom.
It looks like I can configure jetty to use a virtual thread pool, I just need to find a work around for our current ThreadPool that has metrics enabled. e.g.
Copy code
val threadPool = InstrumentedQueuedThreadPool(
                meterRegistry,
                emptyList(),
                maxRequestThreads,
                min(maxRequestThreads, 8),
                60_000,
                requestQueue
        )