Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(networking): Keep given amount inbound/outbound peers. #1495

Closed
Tracked by #1353
alrevuelta opened this issue Jan 17, 2023 · 1 comment · Fixed by #1739
Closed
Tracked by #1353

feat(networking): Keep given amount inbound/outbound peers. #1495

alrevuelta opened this issue Jan 17, 2023 · 1 comment · Fixed by #1739

Comments

@alrevuelta
Copy link
Contributor

alrevuelta commented Jan 17, 2023

Ideally a node should have a healthy mix of inbound and outbound connections. As it is right now, we have no control on this, we naively try to connect to all nodes and it can happen that we end up having too many outbound connections, leaving no space for inbound connections.

Solution:

Add room in the connectivity loop for inbound peers, so we no longer end up filling our connections with only outbound ones. In nimbus this is currently done by limiting the outgoingPeers to max(node.wantedPeers div 10, 3), so if outgoingPeers > targetOutgoingPeers we don't try to connect to any outgoing peer.

Nuances:

  • Unsure if enforcing a 1/10 ratio outbound/inbound is the right solution for us. Allow to easily parametrize it.
  • There is a risk that if a given node is NotReachable it won't be able to have Inbound connections. So this node will only have targetOutgoingPeers amount of peers, hence having way less peers than other nodes. So perhaps leaving room for inbound peers should be only enforced for Reachable nodes.
@alrevuelta alrevuelta changed the title TODO: Keep given amount inbound/outbound peers. feat(networking): Keep given amount inbound/outbound peers. Jan 17, 2023
@alrevuelta
Copy link
Contributor Author

From Tanguy

This is not a good strategy imo, if every peers try to dial peers until it reaches maxConnections, you will naturally have more outgoing connections than incoming connections, and that cannot work at the network scale (every outgoing connection is someone else's incoming connection)

Ideally, every node leaves > maxConnections / 2 open for incoming connections (also need to account for peers that are "outbound only" and are just using slots without giving any)

What is done in nimbus is that we only dial when we have to (while we are unhealthy), and once we are healthy, we leave all the remaining slots for incoming connections. This makes nimbus very nice to the network (ie on our fleet, we generally have ~30 outgoing connections and >200 incoming). But if we have to, we'll kick every one of this incoming connection to get healthy (in case of attack or whatev)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant