Multiple Channels vs. One Channel + Server Side handling [GroupChat] #666
Replies: 1 comment 1 reply
-
Hello, this was actually discussed many times in community rooms. It's hard to give an exact answer without knowing full application details. But some thoughts:
Personally, I'd go with individual user channels for the chat-like app.
You can send notifications no matter what and check whether you need to display it comparing with the local app state, or think about more complex strategy like sending acks to messages and having a process on the backend which sends notifications for messages without ack for some period. This is mentioned in Centrifugo FAQ BTW. Relying on presence is possible I believe – but keep in mind it may be racy, user may be online, but when you send real-time message user can be away already. |
Beta Was this translation helpful? Give feedback.
-
Which approach is more suitable for creating large private chat rooms which can have 10k+ members and each users can be part of multiple groups: having separate group channels or user-specific channels?
Approach 1: Separate Group Channels
In this approach, each group chat has its own channel, and users subscribe to the group channels they have joined.
Approach 2: User-Specific Channels
In this approach, each user has their own channel, and the server manages groups without dedicated group channels. Messages are sent to the user-specific channels of the group participants.
Which approach would be easier to scale. I looked at the blog in centrifugo which was following Approach 2. However i had doubts if it would cause issues in large groups.
Also one more thing i am confused about is how to decide whether i want to send the notification or not. In approach 2, one way to achieve this is check if there is any active user that is subscribed to the private user channel and if not then send a notification about the message. Is there any better way to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions