fix: use multi-filter REQ to avoid subscription explosion#34
Merged
Conversation
The previous chunking approach created separate subscriptions per chunk
(feed, feed:c1, feed:c2), multiplying the subscription count per relay.
Relays with a 10-20 concurrent subscription limit rejected excess REQs
with 'too many concurrent REQs'.
Now packs all author chunks as multiple filters within a single REQ:
["REQ","feed",{authors:[1..200]},{authors:[201..400]},{authors:[401..500]}]
This keeps one subscription ID per logical request while still keeping
each individual filter under 200 authors.
- OutboxRouter: sendChunkedToAll builds a single multi-filter REQ
- RelayPool: revert closeOnAllRelays to simple (no chunk subId scanning)
- SubscriptionManager: revert EOSE matching to exact subId match
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
Fix "too many concurrent REQs" errors caused by subscription explosion from filter chunking.
Problem
PR #30 chunked large author lists into separate subscriptions (
feed,feed:c1,feed:c2). This multiplied the subscription count per relay — with 500 follows and engagement subs, each relay had 15+ concurrent subscriptions. Relays with limits of 10-20 rejected the excess with "too many concurrent REQs".Fix
Pack all author chunks as multiple filters within a single REQ instead of multiple subscriptions:
One subscription ID, multiple filters. Each individual filter stays ≤200 authors (avoiding "total filter items too large"), but the relay only tracks one subscription.
Changes
sendChunkedToAll()now builds a single multi-filter REQ messagecloseOnAllRelays()reverted to simple (no chunk subId scanning needed)Net result: -13 lines. Simpler code, fewer subscriptions.
Testing