Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does the Netty threading model work in the case of many client connections?
    text
    copied!<p>I intend to use Netty in an upcoming project. This project will act as both client and server. Especially it will establish and maintain many connections to various servers while at the same time serving its own clients. </p> <p>Now, the documentation for <a href="http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.html" rel="noreferrer">NioServerSocketChannelFactory</a> fairly specifies the threading model for the server side of things fairly well - each bound listen port will require a dedicated <em>boss</em> thread throughout the process, while connected clients will be handled in a non-blocking fashion on <em>worker</em> threads. Specifically, one worker thread will be able to handle multiple connected clients. </p> <p>However, the documentation for <a href="http://docs.jboss.org/netty/3.2/api/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.html" rel="noreferrer">NioClientSocketChannelFactory</a> is less specific. This also seems to utilize both <em>boss</em> and <em>worker</em> threads. However, the documentation states:</p> <blockquote> <p>One NioClientSocketChannelFactory has one boss thread. It makes a connection attempt on request. Once a connection attempt succeeds, the boss thread passes the connected Channel to one of the worker threads that the NioClientSocketChannelFactory manages.</p> </blockquote> <p>Worker threads seem to function in the same way as for the server case too. </p> <p>My question is, does this mean that there will be one dedicated <em>boss</em> thread for each connection from my program to an external server? How will this scale if I establish hundreds, or thousands of such connections? </p> <p>As a side note. Are there any adverse side effects for re-using a single Executor (cached thread pool) as both the <em>bossExecutor</em> and <em>workerExecutor</em> for a ChannelFactory? What about also re-using between different client and/or server ChannelFactory instances? <a href="http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Effective-use-of-thread-pool-in-server-client-setup-td6613378.html" rel="noreferrer">This is somewhat discussed here</a>, but I do not find those answers specific enough. Could anyone elaborate on this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload