-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
Streaming proxy subscriptions over GRPC #722
Merged
Merged
Conversation
This file contains 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.
Proposed changes
This is the second iteration of the idea in #680. The differences here:
proxy.proto
- so it can be simpler utilized and we could reuse existing features for proxies (like granular proxy mode)Overview
Proposing an experimental feature called Proxy Subscription Streams.
Proxy subscription streams allow pushing data towards client channel subscription directly and individually from your application backend over the unidirectional or bidirectional GRPC stream.
The stream is established between Centrifugo and your application backend as soon as user subscribes to a channel. The scheme may be useful if you want to generate individual streams and these streams should only work for a time while client is subscribed to a channel.
In this case Centrifugo plays a role of WebSocket-to-GRPC streaming proxy – keeping numerous real-time connections from application's clients and establishing GRPC streams to the backend, multiplexing them using a pool of HTTP/2 (transport used by GRPC) connections.
This may be configured similar to our subscribe proxy. For subscription stream proxy we open unidirectional or bidirectional GRPC stream for the time of subscription liveness (backend can close stream at any point).
The downside of the idea is the number of additional goroutines we need for each such stream. Every stream will cost 3 extra goroutines. So for a WS connection with 5 streams the number of goroutines is 2 + 5*3 = 17. This will result into more CPU and more memory. The approach should scale horizontally (scaling GRPC on the backend is not a straightforward but definitely possible). Not every use case involves millions concurrent GRPC streams. This should fit well for short-lived stream use cases. This is like Websocketd - but over GRPC.