I want to avoid spending a lot of CPU resources on waking up netty's thread. Every time the packet is flushed, the netty is wakened up. When I have a lot of packet sending I have a lot of these wake-ups, which is really hard for the CPU to process. How to make it spend less time on waking up, I found something like SelectStrategy.BUSY_WAIT, but as soon as I pick this option, my CPU is at 20% at all times. Is there a way to do something like delayed sleep/awaiting for wakeup?
I also tried to merge EventLoops of channels, but it seems that every channel has its own EventLoop.
There are multiple
EventLoops and these are shared betweenChannels. How many of these are used is depending on how netty is configured and how theChannels are bootstrapped.Regarding the wakups you might be able to reduce the overhead by do one of these:
flushfrom within theEventLoop.writemultiple times before callflushif you need to do it from outside theEventLoop.writeAndFlush(...)and have your ownChannelOutboundHandlerthat "decompose" this object into messages.