-
Notifications
You must be signed in to change notification settings - Fork 164
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
Does Subscriptions Have a Backplane to Support Multiple Servers #135
Comments
Multiple servers would be tricky to implement. Subscriptions itself would work but how would you get the transport to work? Especially when 99% time client is browser connecting trough web socket. Multiple servers where each connection goes to one server should work. |
Not sure about the connection. How does Signal-R do this? Could Subscriptions use some parts of Signal-R to get this done? |
The way to do it is to have a backplane that notifies all the instances, and adds the message to all the subscriptions. In my team we use Azure Service Bus for this, but you can really use anything you want, that is able to receive a message, and then send the message to multiple other services. |
Just wanted to chime in on this. I love GraphQL and we will be using in our software for queries and mutations, but we will be sticking with SignalR for real time events due to elasticity concerns. |
Apollo GraphQL handles this nicely with Redis as the backplane. Is there no equivalent to that for dotnet? Without something like that, subscriptions have no practical use in production applications. |
I am looking into this as well at the moment. I think the first step would be to make the subscriptions async, to be non-blocking. I think IObservable is not the correct primitive. Either IAsyncObservable or IAsyncEnumerable would be better. |
You are likely right, @SebastianStehle, that another choice would be better. Unfortunately Just FYI, GraphQL.NET Server v7 does not internally block on any calls when called through its So if you wish to write your implementation as Link: https://fuqua.io/Rx.NET/ix-docs/html/M_System_Linq_AsyncEnumerable_ToObservable__1.htm I use |
We may want to write connectors for various existing broadcast layer tooling (e.g. Azure Service Bus as noted above) to connect with GraphQL.NET subscription support. |
Another question is where you make the decision what to push to a subscription. I would say, in a typical application, only a very small subset of all events are pushed to a subscription. So you probably use domain events or event sourcing and only 1% of these events are actually consumed by a subscriber. So why would you send all these events over the backbone? I think it would be more efficient if you would handle the subscription with these steps:
The only question is: How do you remove subscription in case of errors? (node restart or so) |
I am working on a small system for my personal needs: https://github.com/SebastianStehle/graphql-ext/tree/main/GraphQLExample/Subscriptions It is just the abstraction yet, but the idea is to make subscription evaluation on the node where the events are published. The subscription is just an interface, so you can implement custom rules to evaluate who should receive events. EDIT: I have added an example to test the abstraction. |
I've tried subscriptions and it works in a single server scenario. How can I make it work when you have multiple load balanced servers? Signal-R uses a concept called a backplane which is basically a data store where a list of subscribers are stored.
Ideally there would be a simple interface I can implement to add, get or delete subscriptions. I could then implement the interface and store the subcriptions in Redis for example.
The closest thing I can find is the
ISubscriptionManager
but that seems to also mix the concepts of storing subscriptions and executing operations.The text was updated successfully, but these errors were encountered: