Design Realtime Comment for Newsfeed
Materials — open to everyone, no sign-in
Topic: Design Realtime Comment for Newsfeed
Interviewer: video from 1-30-2022
Interviewee: Anna
Level: L5 (Senior)
Additional Resources:
System Design Interview
Join Us on Wechat
System design requirements - Real Time Comment for NewsFeed
[8:00]
Requirements:
[13:52]
[14:30] scaling requirements
[18:50]
Push vs pull models
Q: how to implement push
A: Kafka message queue
[Kafka may not work well if there are a large number of topics]
Industry reference:
Tiktok users: 1B monthly actives
Most popular tiktok users: Charli D’Amelio - 141.1M followers
6000 comments on one post
Facebook users: 3B monthly actives
Facebook blog: https://engineering.fb.com/2011/02/07/core-data/live-commenting-behind-the-scenes/
Every page load now requires multiple writes (one for each piece of content being displayed).
Each write of a comment requires a read (to figure out the recipients of an update).
Because of our unique situation, we settled on the completely opposite approach: “write locally, read globally.”
[24:13]
[looks like interviewee talked over the interviewer, who had a question]
Q: why do you need a comment database?
A: need to retrieve old comments
Q: how do we deliver message in real time?
A: delivery/message
[27:18]
A: We create a topic for each post. It may not scale well
Q: if we keep on scrolling, what to do?
A: Scrolling window, each 5-10 posts
[34:22]
Q: tradeoffs?
A: can use user as topic
Add frontend service
Q: How to fan out to many receivers?
A: Introduce a CDN service
Q: CDN supports polling
A: Remove CDN
Q: How does the frontend server find the comment receiver?
A: Receiver sends the post IDs to the frontend
Cache to store recent comments for the post
[tradeoff: send the comment or send the signal a new comment is available]
===