Netty bootstrap with boss group or with just with

2020-07-24 04:04发布

问题:

The book and examples indicates that we should use the so-called boss group and the worker group when bootstraping the server:

serverBootstrap.group(bossGroup, workerGroup);

And then, in the Vert.x that is based on Netty we have:

bootstrap.group(availableWorkers);

which mean (afaiu) that all workers is going to work the same, so no bosses to handle just the incoming connections.

Why is that?

回答1:

Most of the times using the same group for accepting and handling the accepted connections is working out quite well and so allows you to save some threads. The only time when you may not want to do this is if the handling logic of the accepted connections will keep the EventLoops so busy that you are not able to accept fast enough. So best is to just use the same group when you start and switch to two if you need it.



标签: netty