problem description:
one or morechannel
we know will register onEventLoop
. ThisEventLoop
not only listens to events onChannel
, but also handles business logic (including outbound logic) after the event arrives, that is,Netty
handler
calls on the sameChannel
are serial, as shown in the figure below. It causes some simple events to go unanswered (it could also be events on otherchannel
). SoNetty
is not recommended to handle complex business logic, such as database operations, inhandler
. What about time-consuming logic like this inNetty
?
my thoughts
I think there should be two ways to deal with it
- uses a custom thread pool to encapsulate the time-consuming logic that needs to be processed into
task
and throw it intoexecutor pool
, but we know that having too many threads is not a good thing and will affect throughput.- throw these tasks into the idle
EventLoop
so that you can make full use of the thread resources ofNetty
, but how can such code be implemented? is there a mature framework?