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

Does Pioneer support multiplexing subscriptions over one WebSocket connection? #142

Open
cshadek opened this issue Feb 1, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@cshadek
Copy link

cshadek commented Feb 1, 2024

Does Pioneer support multiplexing multiple subscriptions over one WebSocket connection?

This is relevant when a client wants to subscribe to a high number of subscriptions.

@cshadek cshadek added the enhancement New feature or request label Feb 1, 2024
@d-exclaimation
Copy link
Owner

Pioneer only opens 1 WebSocket connection for each client and uses either graphql-ws or subscriptions-transport-ws protocol to handle multiple subscription operations within that 1 connection.

If you notice that this isn't the case, let me know and I'll try to get it fixed

@cshadek
Copy link
Author

cshadek commented Feb 1, 2024

Got it. I assumed as much but I wasn't sure.

Do you know if there is any downside to having many subscriptions open at the same time from a client?

I am using Redis PubSub.

@d-exclaimation
Copy link
Owner

Not quite sure if there would be obvious problems having many subscriptions open. I haven't done many tests with a significantly large number of subscription operations active

@cshadek
Copy link
Author

cshadek commented Feb 2, 2024

So, if I understand correctly the protocol handles multiplexing from the client and Pioneer Redis PubSub's Broadcast makes sure there is only one Redis connection per topic?

@cshadek
Copy link
Author

cshadek commented Feb 2, 2024

And if that's the case, in d-exclaimation/pioneer-redis-pubsub#8,

Maybe the answer is that in:


let redisConfig = try RedisConfiguration(
            url: redisUrl,
            tlsConfiguration: nil,
            pool: .init(
                maximumConnectionCount: .maximumActiveConnections(10),
                minimumConnectionCount: 0,
                connectionBackoffFactor: 2,
                initialConnectionBackoffDelay: .microseconds(100),
                connectionRetryTimeout: .milliseconds(100)
            )

Then maximumConnectionCount needs to be at least as great as the number of subscription types that the GraphQL API offers.

I'm assuming the number of Redis connections is not based on the number of clients and only on the number of unique subscription topics.

@d-exclaimation
Copy link
Owner

d-exclaimation commented Feb 2, 2024

The protocol handle multiplexing of subscriptions on both the client and server on but only at the network/API level.

RedisPubSub and PubSub also try to multiplex Redis subscriptions for each channel. RedisPubSub will multiplex all async stream of the same channel to 1 RediStack subscription, so basically 1 RediStack subscription for every GraphQL subscription of the same channel.

The number of connections to Redis is dependent on how RediStack handle channel subscriptions and I don't know if they make a new Redis connection for each channel subscriptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants