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

Streaming proxy subscriptions over GRPC #722

Merged
merged 26 commits into from
Oct 9, 2023
Merged

Streaming proxy subscriptions over GRPC #722

merged 26 commits into from
Oct 9, 2023

Conversation

FZambia
Copy link
Member

@FZambia FZambia commented Oct 6, 2023

Proposed changes

This is the second iteration of the idea in #680. The differences here:

  • we are dropping client connections streams, leaving only subscription streams
  • moving proto definititions to existing 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.

on_demand_stream_connections

@FZambia FZambia merged commit 97735b4 into master Oct 9, 2023
4 checks passed
@FZambia FZambia deleted the stream_in_proxy branch October 9, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant