feat(kad): provider record spillover#537
Open
gmelodie wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
kad-dht/provider-record-spillover.md, a working-draft specification for an opt-in extension to the Kademlia DHTADD_PROVIDERflow that addresses provider record hotspots on popular keys.Problem
Under the base
kad-dhtprotocol, thekclosest peers to a key unconditionally accumulate everyADD_PROVIDERrecord for it.For popular keys, this creates an unbounded load concentration with no mechanism for a peer to decline new provider records or for advertisers to spill over to other peers. This has been a known scalability issue, including:
libp2p/go-libp2p-kad-dht#316ipfs/kubo#5613This proposal implements the “rejection + sloppy hashing / spillover” approach originally proposed in
libp2p/specs#163, drawing from the Coral DHT paper:What This Spec Defines
Server-side — provider record limits
A node MAY enforce
maxProvidersPerKey.Once at capacity, it MUST reject
ADD_PROVIDERrequests from new providers for that key, while always accepting re-advertisements from existing providers so records can continue to be refreshed.Wire protocol
A new optional
providerStatusfield (field 11) is added to theADD_PROVIDERresponse message with two possible values:accepted (0)rejected (1)For backward compatibility:
providerStatusfield MUST be treated asaccepted.providerStatusis response-only.Client-side — spillover algorithm
The advertiser performs the normal iterative
FIND_NODElookup, then processes the sorted candidate list in chunks of sizeα, from closest to farthest.After each chunk, it counts peers that:
toward the replication target
k.If
khas not yet been reached, the advertiser continues to the next chunk (a spillover round).The process stops when either:
ksuccessful placements are reached, orNon-responding peers count as accepted to preserve compatibility with nodes that predate this extension.
Compatibility
This extension is fully backward compatible.
Nodes that do not implement the extension:
providerStatusproviderStatusif receivedNo changes are made to:
GET_PROVIDERSFIND_NODERelated