10 Tips for Designing a Facebook Live Comments System

Published On Sun Sep 22 2024
10 Tips for Designing a Facebook Live Comments System

Facebook Live Comments System Design Interview Guide

šŸ“¹ What are Facebook Live Comments?

Facebook Live Comments is a feature that enables viewers to post comments on a live video feed. Viewers can see a continuous stream of comments in near-real-time. Check out the top Facebook Live videos of 2016 Facebook Live Biggest 2016 Videos: Chewbacca Mom Tops List

Core Requirements

Below the line (out of scope):

🤩 Fun Fact!

Humans generally perceive interactions as real-time if they occur within 200 milliseconds. Any delay shorter than 200 milliseconds in a user interface is typically perceived as instantaneous so when developing real-time systems, this is the target latency to aim for.

Core Requirements

Below the line (out of scope):

🤩 Fun Fact!

The most popular Facebook Live video was called Chewbacca Mom which features a mom thoroughly enjoying a plastic, roaring Chewbacca mask. It has been viewed over 180 million times. Check it out here.

System Design Strategy

Before you move on to designing the system, it's important to start by taking a moment to plan your strategy. For common product-style system design questions, the plan should be straightforward: build your design up sequentially, going one by one through your functional requirements. This will help you stay focused and ensure you don't get lost in the details as you go.

I like to begin with a broad overview of the primary entities. Initially, establishing these key entities will guide our thought process and lay a solid foundation as we progress towards defining the API.

6 New Facebook Live Features You Need to Know

Why just the entities and not the whole data model at this point? The reality is we're too early in the design and likely can't accurately enumerate all the columns/fields yet. Instead, we start by grasping the core entities and then build up the data model as we progress with the design.

API Design

In your interview, this can be as simple as a bulleted list like:

Now, let's outline the API, tackling each functional requirement in sequence. This step-by-step approach will help us maintain focus and manage scope effectively.

Create a Comment

Design Live Comments Feature: System Design Interview with a Meta ...We'll need a simple POST endpoint to create a comment. The userId is not passed in the request body but is a part of the request header, either by way of a session token or a JWT.

Fetch Past Comments

We also need to be able to fetch past comments for a given live video. Pagination will be important for this endpoint.

Real-Time Comment Broadcasting

When a user posts a comment, we need to broadcast that comment to all viewers in near real-time. Instead of polling, using websockets or Server Sent Events (SSE) can be more efficient solutions.

Handling Pagination

We need to implement pagination to allow users to load older comments as they scroll. Cursor Pagination with Prefetching and Caching is a great solution to efficiently handle pagination in a high-traffic environment like ours.

This approach reduces database load compared to offset pagination and ensures stable results even if comments are added or deleted during user interactions.