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

Is a new connection created for each pub/sub channel subscribed? #872

Closed
shravan2x opened this issue Jul 1, 2018 · 8 comments
Closed

Is a new connection created for each pub/sub channel subscribed? #872

shravan2x opened this issue Jul 1, 2018 · 8 comments

Comments

@shravan2x
Copy link

As the title asks, is a new connection created for each pub/sub channel subscribed? How about when publishing to multiple channels?

This might be useful to add to the docs.

@NickCraver
Copy link
Collaborator

Nope, no new connections. As the docs already note: you create and use one ConnectionMultiplexer and it handles all this internally. In total there are 2 connections to redis: 1 every non-subscriber operation, and 1 more for subscriber pub/sub operations.

@shravan2x
Copy link
Author

Interesting, are more subscriber connections created if the bandwidth is required?

@NickCraver
Copy link
Collaborator

@shravan2x No new connections are ever created, only restored if broken. Redis is processing them in a single-threaded-behavior style, and the client must also do so to have the order maintained. From redis's point of view, 2 connections are 2 clients. If we connected twice, we'd just get every message twice, or we'd be randomly choosing how to shard subscriptions and have no real knowledge of how we're balancing. Given the client and server are in the same places respectively, adding a connection isn't going to add more bandwidth unless you're in a high latency/TCP window constrained environment. If that's the case, it'd only matter for very large payloads in which case...lots of bad things are being combined and the situation should really be evaluated at a higher level before this is an issue.

@shravan2x
Copy link
Author

shravan2x commented Jul 1, 2018

This was all really good to know, could it be added to the docs (or am I just missing it somehow)?

@NickCraver
Copy link
Collaborator

Sure, we can look at noting the behavior with some doc updates we'll do in 2.0. Tagging it for that pass.

@NickCraver NickCraver added this to the 2.0 milestone Jul 1, 2018
@ericpauley
Copy link

Related clarification, when does SubscribeAsync complete, when the command has been sent or when the SUBSCRIBE acknowledgement is received? Using PubSub for key change notifications so I need to wait until SUBSCRIBE is ack'd before fetching initial key status.

Alternatively, give an additional SUBSCRIBE callback, since the same change checking code would need to run on connection drop as well.

@mgravell
Copy link
Collaborator

mgravell commented Jul 6, 2018 via email

@NickCraver
Copy link
Collaborator

This is improved since #1947 - the command returns once actually subscribed (unless FireAndForget) and should behave in the expected way now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants