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

[NEW] Support fan-out/multicast (PUBLISH to multiple channels) #13327

Open
lukehutch opened this issue Jun 5, 2024 · 5 comments
Open

[NEW] Support fan-out/multicast (PUBLISH to multiple channels) #13327

lukehutch opened this issue Jun 5, 2024 · 5 comments

Comments

@lukehutch
Copy link

lukehutch commented Jun 5, 2024

The problem/use-case that the feature addresses

I need to be able to send a message to multiple channels. Currently I loop through the channels and send a PUBLISH command for each channel, which can result in a lot of round-trips to the server.

To give more specific usecase details: a user can be a member of potentially hundreds of chat channels in the history of using my app. Rather than subscribe every online user to every chat channel in their inbox every time they go online, I have chosen to subscribe users to just one chat channel, associated with their user id. Now when a message is sent to a chat channel with multiple users, I need to multicast the message to all users who are members of that chat channel.

Description of the feature

I would like a PUBLISH_MULTIPLE command that will take a list of channels, and publish to all of them.

Alternatives you've considered

Instead, I could SUBSCRIBE each user to the channel id of all chat channels in their chat history, and just send new messages once to the intended channel, but I am worried about how well that will scale, with potentially millions of users, each with potentially hundreds of chat channels (most of which have not had any new messages in a long time).

@sundb
Copy link
Collaborator

sundb commented Jun 6, 2024

what if using lua script to publish message to a channel list? which can avoids the round-trips.

@lukehutch
Copy link
Author

Definitely possible, but this should be built in for speed. Most other message queue platforms support fan-out.

@sundb
Copy link
Collaborator

sundb commented Jun 6, 2024

@lukehutch in this case i recommend using stream instead of pubsub, as stream supports fan-out.

@lukehutch
Copy link
Author

OK, I didn't know that... but streams are a fundamentally different messaging model, so I will probably have a hard time convincing the upstream library I depend upon to switch from pub/sub to streams. Is there a fundamental reason why fan-out is not supported for pub/sub?

@sundb
Copy link
Collaborator

sundb commented Jun 6, 2024

@lukehutch pubsub is not a message queue, it is a simple subscribe and publish, and it is more appropriate to use stream in your scenario.

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

No branches or pull requests

2 participants