简体   繁体   English

Netty:有多少线程在服务器端口(80)上接受连接

[英]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.我知道在 Netty 4 中,一旦建立了通道,该通道的所有事件处理都在分配给特定 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. bossExecutor可能有多个线程。

Does this mean under heavy connection storms, there would be more than 1 thread accepting new connections?这是否意味着在严重的连接风暴下,会有超过 1 个线程接受新连接? And all these boss threads can simultaneously try to accept without synchronization?而所有这些boss线程可以同时尝试accept而不同步?

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只有一个线程......在netty 4.1.x中,我们还支持SO_REUSEPORT ,它允许通过多次绑定到同一个端口来接受多个线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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