Why Netty one Channel bind one Thread?

255 views
Skip to first unread message

刘洋

unread,
Jul 29, 2013, 11:15:01 PM7/29/13
to ne...@googlegroups.com

Jeff Liu

unread,
Jul 31, 2013, 10:36:27 AM7/31/13
to ne...@googlegroups.com
Its depends on the which transport you use. The blocking IO transport will  occupy one thread each Channel. But AIO and NIO based transport won't. 

On Tuesday, July 30, 2013 11:15:01 AM UTC+8, 刘洋 wrote:

刘洋

unread,
Aug 1, 2013, 1:34:34 AM8/1/13
to ne...@googlegroups.com
Netty used NIO is that get a thread from  work pool to receive tcp's buffer and then release the thread to work pool?
my comprehension is correct?
channelA read event --> get thread from workergroup  -> receive data buffer from tcp --> invoke handler --->  release thread----> channelB can use the thread.



2013/7/31 Jeff Liu <php...@gmail.com>
Its depends on the which transport you use. The blocking IO transport will  occupy one thread each Channel. But AIO and NIO based transport won't. 

On Tuesday, July 30, 2013 11:15:01 AM UTC+8, 刘洋 wrote:

--
 
---
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

刘洋

unread,
Aug 1, 2013, 1:41:20 AM8/1/13
to ne...@googlegroups.com
In other words, Netty's NioEventgroup is used for handling all of channel 's event. NioEventgroup's one thread handle one channel's one tcp pdu and then release to NioEventgroup for other channel support read or send handler.  


2013/8/1 刘洋 <liu...@gmail.com>

刘洋

unread,
Aug 1, 2013, 1:57:22 AM8/1/13
to ne...@googlegroups.com, code...@gmail.com, norman...@googlemail.com
If anybody can answer the question, my question's innate character is same as it.

Multithread DefaultEventExecutorGroup

Min Zhou <code...@gmail.com>




Hi all, 

I started a netty4 nio server with multiple business threads for handling long-term businesses
like below

    public void start(int listenPort, final ExecutorService ignore)
        throws Exception {
  ...
bossGroup = new NioEventLoopGroup();
ioGroup = new NioEventLoopGroup();
businessGroup = new DefaultEventExecutorGroup(businessThreads);

ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, ioGroup).channel(NioServerSocketChannel.class)
        .childOption(ChannelOption.TCP_NODELAY, 
                     Boolean.parseBoolean(System.getProperty(
                             "nfs.rpc.tcp.nodelay", "true")))
        .childOption(ChannelOption.SO_REUSEADDR, 
                     Boolean.parseBoolean(System.getProperty(
                             "nfs.rpc.tcp.reuseaddress", "true")))
        .childHandler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch)
                throws Exception {
ch.pipeline().addLast("decoder",
new Netty4ProtocolDecoder());
ch.pipeline().addLast("encoder",
new Netty4ProtocolEncoder());
ch.pipeline().addLast(businessGroup, "handler",
new Netty4ServerHandler());
        }
        });

b.bind(listenPort).sync();
LOGGER.warn("Server started,listen at: " + listenPort + ", businessThreads is " + businessThreads);
}

I found that there was only one thread working when  the server accepted one connection. 
How can I bootstrap a server that can start multiple business thread for only one connection?

Thanks,
Min


2013/8/1 刘洋 <liu...@gmail.com>
Reply all
Reply to author
Forward
0 new messages