PlatON-Go icon indicating copy to clipboard operation
PlatON-Go copied to clipboard

节点最大连接数MaxPeers的默认值小于最大共识节点连接数MaxConsensusPeers的默认值

Open niuxiaojie81 opened this issue 4 years ago • 4 comments

MaxPeers 默认值为50,MaxConsensusPeers 默认值为100。 https://github.com/PlatONnetwork/PlatON-Go/blob/83ac8d275ad9fca8a934bbb0e6bf6d83c4dae7a4/node/defaults.go#L48

然而,在节点建立连接,握手检查过程中,存在以下逻辑: https://github.com/PlatONnetwork/PlatON-Go/blob/83ac8d275ad9fca8a934bbb0e6bf6d83c4dae7a4/p2p/server.go#L862 可以看出,MaxPeers “包含”了 MaxConsensusPeers,所以节点在实际运行中,节点连接数一直受 MaxPeers 的上限影响。

建议将 MaxPeers 默认值修改为100.

niuxiaojie81 avatar Jun 05 '21 08:06 niuxiaojie81

ACK

benbaley avatar Jun 05 '21 08:06 benbaley

Alaya 网络 MaxPeers 默认值修改为80.

niuxiaojie81 avatar Jun 08 '21 04:06 niuxiaojie81

限制最大连接数,要考虑后续扩容后,共识节点超过最大连接数,共识节点尝试直连可能会导致其他节点连不上共识节点

benbaley avatar Jun 30 '21 01:06 benbaley

修改后的逻辑: 1、MaxPeers包含了MaxConsensusPeers,即MaxPeers的设置必须大于MaxConsensusPeers 2、共识节点连接数超过了MaxConsensusPeers设置,一律不允许再添加consensusDialedConn 3、共识节点连接数没有超过MaxConsensusPeers设置,但连接总数超过了MaxPeers设置 当前节点是共识节点:断开一个非consensusDialedConn,并允许请求的consensusDialedConn连接(一断一连保持不超过MaxPeers) 当前节点不是共识节点:不允许连接 4、trustedConn、staticDialedConn连接不受MaxPeers限制 5、MaxPeers默认值60,MaxConsensusPeers默认值40

niuxiaojie81 avatar Jul 05 '21 01:07 niuxiaojie81

close by done

benbaley avatar Oct 14 '22 02:10 benbaley