Should long-running I/O operations be offloaded from Netty event loop threads in Ktor applications? #4790
-
Hi All! From what I understand: Netty event loop threads are designed for lightweight tasks like accepting connections, parsing HTTP requests, and writing responses. These threads should not be used for long-running tasks, even if they are suspending functions in Kotlin. 🧠 My Questions:
Appreciate any confirmation, corrections, or pointers to official Netty/Ktor docs or discussions (e.g., Slack, Discord, GitHub issues) that support this! Thanks in advance 🙌 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, apologies for the lag, I haven't been watching the discussions.
It depends on the task. Suspend functions and async I/O generally won't block the underlying threads and cause problems, but you can still assert more control over the execution of different kinds of tasks when you use a different dispatcher.
We actually made a recent change that prevents launching coroutines on the Netty dispatcher, so you can safely call
You can use |
Beta Was this translation helpful? Give feedback.
Hey, apologies for the lag, I haven't been watching the discussions.
It depends on the task. Suspend functions and async I/O generally won't block the underlying threads and cause problems, but you can still assert more control over the execution of different kinds of tasks when you use a different dispatcher.
We actually made a recent change that prevents launching coroutines on the Netty dispatcher, so you can safel…