Live comments are a feature often used in streaming platforms, sports apps, and social media events where users can post and view comments in real time as an event unfolds.
For example, during a live football match or a concert stream, thousands or even millions of viewers may send comments simultaneously, which appear instantly for all participants.
In this chapter, we will aim to design a low-latency, scalable live comment system that allows thousands or even millions of users to exchange messages in real time during a live event.
Key challenges include:
Let’s begin by clarifying the requirements.
Before diving into the design, let's narrow down the scope of the problem. Here’s an example of how a discussion between candidate and interviewer might flow:
Candidate: “Should users only post text comments, or do we also need to support images, emojis, or reactions?”
Interviewer: “For now, only short text-based comments. Reactions or media attachments can be ignored.”
Candidate: “Do comments need to be delivered in real-time to all viewers?”
Interviewer: “Yes, the experience should feel live. Ideally under 500 ms from publish to delivery.”
Candidate: “Do we need to support playback after the live event ends like showing comments alongside recorded video?”
Interviewer: “Yes. Playback is in scope. Users watching later should see the comments synchronized with the original timeline.”
Candidate: “Can users reply to comments or have threaded conversations?”
Interviewer: “No. No replies or threads. Just a flat stream of comments.”
Candidate: “What about comment moderation like spam filtering, profanity, abuse detection?”
Interviewer: “Assume moderation already exists. You can treat it as out of scope.”
Candidate: “For ordering, do we need strict global time ordering across distributed regions?”
Interviewer: “No. Exact strict ordering is not require. We just need roughly correct chronological order that feels consistent to the user.”
After clarifying the requirements, we can summarize the functional and non-functional requirements.
Before designing the system, let’s estimate the scale we need to support.