简体   繁体   中英

Netty: How many thread is accepting connections on a server port (80)

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM