Ktor Netty Engine: Server vs Client EventLoopGroup Sharing Decision
0 reputation · 03 Jul 2023, 14:06 UTC
When a Ktor application hosts both an HTTP server and a client using the Netty engine, the default configuration creates separate EventLoopGroup instances for each pipeline. This can lead to thread overhead or contention under high concurrency, yet the framework does not expose a straightforward API to enforce sharing of a single group across both engines.
The primary goal is to measure whether the current default behavior introduces a measurable bottleneck before applying any optimizations. Understanding the trade‑offs between isolated and shared event loops is essential for resource‑efficient deployment.
Given this uncertainty, the following questions remain:
- Does Ktor provide any mechanism to automatically detect an existing
EventLoopGroupand reuse it for both server and client engines? - What are the performance and thread‑safety implications of forcing a shared
EventLoopGroupacross multiple Netty engines within the same JVM? - Is there a recommended pattern or configuration option for sharing an
EventLoopGroupthat balances resource usage and latency?