InterviewLegend

Design Nested Comment Threads

Signature problem
Alex Chen45 min readUpdated 118 real interview reports

A Reddit post is a link or a piece of text submitted to a subreddit, one of the topic communities the site is built from. Below it sits the comment section: replies that hang off the post, replies that hang off those replies, and so on with no fixed limit. That recursive shape is the whole problem. A chat is a flat list you append to. A Reddit thread is a tree you have to store, rank and hand back in pieces, because the biggest ones are far too large to send at once.

Reddit interviewers point the system design round at Reddit's own systems, and the comment tree is one they name directly, sometimes as a low-level design prompt called the "comment threading model." So the job is concrete. Model the data so a deep thread reads cheaply. Rank the replies so the good ones surface. Page the tree so a post with fifty thousand comments loads a screenful at a time instead of everything at once.

The Reddit angle
What marks this as Reddit and not "design a chat app" is treating the comment section as a read-heavy tree whose default order is a statistical confidence score, not newest-first. Reddit's default comment sort is Best, and Best is not "most upvotes" or "most recent." It ranks each comment by the lower bound of a Wilson confidence interval on its up-and-down votes. A reply with nine of ten upvotes can sit above one with forty of seventy, and the age of the comment never enters the formula. Say that in the first few minutes. If you sort comments by score or by time and move on, you have described a generic forum, and an interviewer who knows Reddit's ranking cold will hear the gap. The tree shape drives the storage and pagination decisions; the confidence sort drives the ranking one. Naming both up front is what frames the rest of the answer.
What's inside
  • 1 diagram
  • 5 sections
  • about 45 min

Premium lessonReddit interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Reddit interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Reddit interview guide

Know what Reddit asks before you walk in.

16 coding · 5 system design · 23 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.