George
George

Reputation: 27

netty eats 100% of CPU

I'm running a server on netty, and found out that some threads initialized by java server application after a while start to eat 100% of CPU. I've tried to initialize boss and worker group with different number of threads but the result is same.

What could be the reason for it?

EventLoopGroup bossGroup = new NioEventLoopGroup(); 
EventLoopGroup workerGroup = new NioEventLoopGroup(50);
try {
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup)
    .channel(NioServerSocketChannel.class)
    .childHandler(new ChannelInitializer<SocketChannel>() { 
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ch.pipeline().addLast("ReadTimeOutHandler", new ReadTimeoutHandler(20));
            ch.pipeline().addLast(new streamDecoder());
            ch.pipeline().addLast(new streamEncoder());

            ch.pipeline().addLast(new validationHandler());
            ch.pipeline().addLast(new streamDecryptor());
            ch.pipeline().addLast(new streamEncryptor());
            ch.pipeline().addLast(new msgValidatedHandler());
         }
     })
     .option(ChannelOption.SO_BACKLOG, 128)
     .childOption(ChannelOption.SO_KEEPALIVE, true);  

Upvotes: 2

Views: 6073

Answers (1)

AngerClown
AngerClown

Reputation: 6229

Googling for sun.nio.ch.WindowsSelectorImpl$SubSelector high cpu brings up a few hits from as last at 2015. Are you running an older version of Netty?

Also see https://github.com/netty/netty/issues/3857 - you may want to try running with -Dorg.jboss.netty.epollBugWorkaround=true.

Upvotes: 1

Related Questions