problem description:
one or morechannelwe know will register onEventLoop. ThisEventLoopnot only listens to events onChannel, but also handles business logic (including outbound logic) after the event arrives, that is,Nettyhandlercalls on the sameChannelare serial, as shown in the figure below. It causes some simple events to go unanswered (it could also be events on otherchannel). SoNettyis 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
taskand 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
EventLoopso that you can make full use of the thread resources ofNetty, but how can such code be implemented? is there a mature framework?
