Delay between channel active and channel read Netty 4

150 views
Skip to first unread message

Kimathie

unread,
Aug 24, 2016, 3:27:41 AM8/24/16
to Netty discussions
Hi ,
I have written a HTTP server and I have an issue where there's a 100 ms to 1 second  delay between these two events for majority of requests.
Below are a few of examples I am sharing. There are many more

DEBUG|2016-23-08 22:10:12.239|epollEventLoopGroup-4-1|RequestHandler|channelActive|system|/196.99.89.134:51871 connected
DEBUG|2016-23-08 22:10:13.085|epollEventLoopGroup-4-1|RequestHandler|channelRead0|system|Remote Address: /196.99.89.134:51871|Request Received

DEBUG|2016-23-08 22:10:10.392|epollEventLoopGroup-4-5|RequestHandler|channelActive|system|/196.99.89.134:51870 connected
DEBUG|2016-23-08 22:10:11.233|epollEventLoopGroup-4-5|RequestHandler|channelRead0|system|Remote Address: /196.99.89.134:51870|Request Received

DEBUG|2016-23-08 22:10:08.752|epollEventLoopGroup-4-4|RequestHandler|channelActive|system|/196.99.89.134:51869 connected
DEBUG|2016-23-08 22:10:09.378|epollEventLoopGroup-4-4|RequestHandler|channelRead0|system|Remote Address: /196.99.89.134:51869|Request Received

There's a very strange delay here in which I cannot figure out where it's coming from 

To the source code
For the server 

        this.bootstrap.group(bossGroup, workerGroup)
                .channel(isLinux
                                ? EpollServerSocketChannel.class
                                : NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel c) throws Exception {
                        ChannelPipeline pipeline = c.pipeline();
                        pipeline.addLast("requestIdleHandler", new IdleStateHandler(60, 60, 60, TimeUnit.SECONDS));
                        pipeline.addLast("requestCodec", new HttpServerCodec());
                        pipeline.addLast("requestAggregator", new HttpObjectAggregator(64 * 1024));
                        pipeline.addLast("requestHandler", new RequestHandler(feeder));
                    }
                });

        this.bootstrap.handler(new ChannelInboundHandlerAdapter() {

            @Override
            public void channelActive(ChannelHandlerContext ctx) throws Exception {
                logger.info(Utility.LOG.system(ctx.channel().localAddress() + "  started."));
            }

            @Override
            public void channelInactive(ChannelHandlerContext ctx) throws Exception {
                logger.info(Utility.LOG.system(ctx.channel().localAddress() + " closed."));
            }
        }).option(ChannelOption.SO_BACKLOG, configs.getQueueSize())
                .option(ChannelOption.SO_REUSEADDR, true)
                .option(ChannelOption.TCP_NODELAY, true)
                .childOption(ChannelOption.TCP_NODELAY, true)
                .bind(hostAddress, hostPort).sync();


The Request handler

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        Channel channel = ctx.channel();
        channels.add(channel);
        logger.debug(Utility.LOG.system(channel.remoteAddress() + " connected"));
    }

What could be the problem ?

Norman Maurer

unread,
Aug 24, 2016, 3:29:40 AM8/24/16
to ne...@googlegroups.com
I would attach a profiler and first check if you block the EventLoop. If this not shows anything use something like wireshark to see whats going on on the wire.


--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/629c7d97-7238-4f01-a4d0-fc09f7099ffb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages