PlatON-Go
PlatON-Go copied to clipboard
节点最大连接数MaxPeers的默认值小于最大共识节点连接数MaxConsensusPeers的默认值
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.
ACK
Alaya 网络 MaxPeers 默认值修改为80.
限制最大连接数,要考虑后续扩容后,共识节点超过最大连接数,共识节点尝试直连可能会导致其他节点连不上共识节点
修改后的逻辑: 1、MaxPeers包含了MaxConsensusPeers,即MaxPeers的设置必须大于MaxConsensusPeers 2、共识节点连接数超过了MaxConsensusPeers设置,一律不允许再添加consensusDialedConn 3、共识节点连接数没有超过MaxConsensusPeers设置,但连接总数超过了MaxPeers设置 当前节点是共识节点:断开一个非consensusDialedConn,并允许请求的consensusDialedConn连接(一断一连保持不超过MaxPeers) 当前节点不是共识节点:不允许连接 4、trustedConn、staticDialedConn连接不受MaxPeers限制 5、MaxPeers默认值60,MaxConsensusPeers默认值40
close by done