Skip to content

Configure the channel pool to open a new channel when all of the currently open channels reach 100 subscriptions each #3380

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

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented Oct 15, 2024

Summary

When you make ‘too many’ subscriptions over a single channel/connection/socket, RPC providers will throw errors. The idea behind this PR is to set the default subscriptions-per-channel low enough so as to avoid running afoul of even the most restrictive provider's limit.

This was determined experimentally by hitting various nodes with this script.

  • Triton Public Mainnet (api.mainnet-beta.solana.com): 100
  • Helius: ~1450
  • QuickNode: ~4500

The ground truth is this:

  1. Some nodes have definite limits set, like the public Triton mainnet node.
  2. Some nodes don't have limits set, but unceremoniously close the connection roughly around the same number of subscriptions.

The right thing to do here would be for providers not to kill the channels, but rather to respond to the suscription request with a JSON-RPC response, of the form:

{
  "error": {
    "code": ???,
    "message": "OK, that's enough subscriptions for now.",
  },
  "id": 123,
  "jsonrpc": "2.0"
}

If everyone did that, and we all decided on an error code in the range -32000 to -32099, as demanded by what the JSON-RPC spec says about errors, then the channel pool could catch that error to know when a new channel needed to be added to the pool. Because they don't, we have to participate in this tragedy of the commons, and hardcode the limit to 100 so that people using the public endpoint will not get caught off-guard by the limit.

Note

There might actually be two kinds of errors: ‘I can't give you this subscription over this channel, open a new one’ and ‘I can't give you this subscription over any channel, please stop opening subscriptions.’

cc/ @linuskendall, @WilfredAlmeida, @vovkman

…ently open channels reach 100 subscriptions each
Copy link

changeset-bot bot commented Oct 15, 2024

⚠️ No Changeset found

Latest commit: b02fb40

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @steveluscher and the rest of your teammates on Graphite Graphite

Copy link
Contributor

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks for the detailed explanation of this limit. Looking forward to seeing these consistent error codes in the future. 🙏

@steveluscher steveluscher merged commit 30f9254 into master Oct 16, 2024
9 checks passed
@steveluscher steveluscher deleted the 10-15-configure_the_channel_pool_to_open_a_new_channel_when_all_of_the_currently_open_channels_reach_100_subscriptions_each branch October 16, 2024 18:12
Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants