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: maintain max open connection & prune unhealthy connections from peer store #2168

Open
Tracked by #1969
danisharora099 opened this issue Oct 8, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@danisharora099
Copy link
Collaborator

Problem

Currently, js-waku nodes manage to maintain 15-30 connections at the same time when run against TWN, which raises concerns about bandwidth consumption. There is no cap on the number of connections, and without proper connection management, this could result in excessive resource usage, especially as the network grows. Additionally, the PeerStore could grow with unhealthy peers, complicating future dials when connections are needed

Key concerns:

  • No cap on active connections, potentially increasing bandwidth consumption.
  • Peers in the PeerStore may include unhealthy peers that can’t be dialed efficiently when needed.
  • Dialing is necessary to determine if a peer supports the needed protocols, but excessive dials could result in resource wastage.

Proposed Solutions

  • Implement a cap of N active connections
  • Remove unhealthy peers from the PeerStore to avoid attempting dials on unreliable peers. Retain only healthy and dialable peers
    • Implement pruning logic to efficiently scan and filter peers before attempting dials, to ensure only healthy connections are retained
    • Before attempting a dial, use initial filtering based on:
      • Multiaddr supports websockets
      • ENR contains useful information to pre-filter dialable peers
  • Ensure that connections used by critical protocols (e.g., Filter) are never capped or dropped
  • For peers discovered through Peer Exchange, establish connections temporarily, utilize them, and then drop them to maintain the cap

Notes

  • Even though we will prune peers, it’s important to dial peers initially to confirm if they are dialable and then disconnect if they aren’t needed at that time
  • This will also help manage PeerStore more efficiently, especially as the network scales and the number of peers increases
@weboko
Copy link
Collaborator

weboko commented Oct 8, 2024

Subtask of #1969

@weboko weboko self-assigned this Oct 8, 2024
@weboko weboko added the enhancement New feature or request label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Priority
Development

No branches or pull requests

2 participants