Reputation: 1851
I know in Netty 4 that once a channel is established, all events handling for this channel is done on the same thread assigned to a particular EventLoop. This binding is done at channel creation time.
The part I do not understand is how many threads are needed to actually accept new connections and create new channels and do the bindings?
I keep seeing the following code:
new ServerBootstrap(new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
where the bossExecutor
could potentially have more than one thread.
Does this mean under heavy connection storms, there would be more than 1 thread accepting new connections? And all these boss threads can simultaneously try to accept
without synchronization?
Upvotes: 0
Views: 474
Reputation: 23567
Only one thread... In netty 4.1.x we also have support for SO_REUSEPORT
which allows to accept with multiple threads by binding to the same port multiple times
Upvotes: 0