System design interview question · Backend

Design a comment system for social posts

Let millions of people post and read comments under popular posts and videos.

Beginner 35 minutesData systemsFree
More Backend questions

The brief

Let millions of people post and read comments under popular posts and videos. Your design should meet these requirements:

  1. Users can post a comment on a post and see it appear for others shortly after.
  2. Anyone can read a post's comments quickly, newest first, page by page.
  3. A burst of comments on a viral post must not take the service down.

Scale to design for

Comments under posts or videos (Instagram/YouTube style). Viral posts get bursts of thousands of comments per second; reads outnumber writes by orders of magnitude. A few seconds of delay before a new comment is visible to others is acceptable.

State these assumptions out loud in the interview, then let them drive your choices: they decide what needs caching, sharding or asynchronous processing.

Before you start

You'll get more out of this round if you're comfortable with:

  • Message queues as buffers
  • Cache-aside reads
  • Eventual consistency
  • Cursor pagination

Questions an interviewer may ask

Expect follow-ups like these once your high-level design is on the board. Have an answer, and a reason, for each:

  • What happens when a celebrity post gets 50,000 comments in a minute?
  • How does the cache get rebuilt after a restart or a miss?
  • How do you avoid duplicate comments when a consumer retries?
  • How would you add moderation or comment counts?

Common mistakes to avoid

  • Writing synchronously to the database on every request
  • Reading comments straight from the primary store
  • Returning all comments with no pagination
  • Ignoring duplicate deliveries from the queue
  • Not mentioning that a user's own comment should appear immediately (read-your-writes in the client)

Concepts this round covers

  • Separate read and write paths
  • Queue as a write buffer
  • Caching and eventual consistency
  • Data systems

What a complete answer covers

A write path buffered by a queue, a cache-backed read path with pagination, a comment data model, and a clear statement of the consistency users will see.

There is no single correct design. A strong answer meets the requirements at the stated scale and explains the trade-offs behind each choice. New to the format? Read how to prepare for a system design interview.