I am currently exploring the feasibility of using Couchbase Server, Sync Gateway, and Couchbase Mobile Lite to develop a chat application for both iOS and Android platforms. The app will feature chat rooms where one or more users can participate. Each chat room will have a name, description, and an associated image. Users will be able to send messages within the chat rooms. Additionally, users can be members of multiple chat rooms, with each user having a display name and profile image. It is crucial that documents only sync to the devices of users who are part of the respective chat rooms.
Based on my research in the Couchbase documentation, it seems that Channels would be the appropriate mechanism to achieve this functionality. However, I have a few questions regarding the limitations and scalability of Channels.
Could it scale to have millions of chat rooms/channels?
According to the documentation, each document can only be assigned to a maximum of 50 channels. In the context of my chat app, this raises concerns about the user profile document, as a user could potentially be part of more than 50 chat rooms. Since the user profile data needs to be displayed alongside the messages they send in each chat room, how can this limitation be addressed?
Furthermore, the documentation states that a user can only be assigned to a maximum of 1,000 channels. Considering the scenario of a user potentially being part of more than 1,000 chat rooms, is there a workaround or solution to allow users to participate in an unlimited number of chat rooms?
I also wanted to inquire about the use of scope and collations in this scenario. Would creating a new collection for each chat room help overcome the limitations of the maximum number of channels per user and document? Or are there alternative approaches that can address this challenge more effectively?
Additionally, I’m curious if implementing a role per chat room, which would have access to the chat room channel, is worthwhile? This way, users could be added to the role instead of directly to the channel. I’m wondering if this approach introduces unnecessary processing overhead or if it would be a recommended practice to handle user access to chat rooms.
Example data model
{
"user_id": "User123ABC",
"type": "UserProfile",
"display_name": "John Doe",
"profile_image_url": "https://example.com/profile.jpg",
"channels": [
'chatroom_01', chatroom_02
]
// Other user profile fields...
}
{
"chatroom_id": "chatroom01",
"type": "ChatRoon",
"name": "Chat Room 01",
"description": "This is a sample chat room.",
"image_url": "https://example.com/chatroom.jpg",
"channels": [
"chatroom_01"
]
// Other chat room fields...
}
{
"message_id": "message123",
"type": "Message",
"chatroom_id": "chatroom01",
"sender_id": "User123ABC",
"message_text": "Hello, everyone!",
"timestamp": 1620920123,
"channels": [
"chatroom_01"
]
// Other message fields...
}