DEV Community

Discussion on: Designing Live Commenting in youtube/Facebook/Instagram live stream Video

Collapse
 
kutanti profile image
Kunal Tanti • Edited

Thanks for the comment.
While broadcasting comments to the viewers of a video content, viewership information needs to be queried per content. That's why index on ContentId is important.
Now also, when you scroll down(or move out of comment panel) and leave a video, you are not supposed to see the comments.
In that case there can be a update query, which will deactivate your viewership info.
UPDATE Viewership_Info SET IsActive = false Where ContentId = 1 AND UserId = 1

This query will be efficient if we index on both ContentId and UserId.

Now how it can be done?
In RDBMS scenario, we can create a non-clustered on both the columns.
But as we are having very frequent writes, over indexing could bring inefficiency, we can think of NoSQL solutions keeping the indexing requirement intact.

Let me do some reading on this will get back on the NoSQL database selection in this scenario soon.

Collapse
 
athenanouhi profile image
Athena N

Thank you for your response. I am very new into system design area. I learnt a lot from your post. Are you using websocket in this design? Does it mean while user is viewing contents a hash table should store userID, serverID info?
I was thinking with NoSQL, we will have to keep two key value datastores.
1) userID(key) : a set data structure with postIDs -- O(1) insert and delete
1) postID(key) : a set data structure with userIDs -- O(1) insert and delete