Design a Comment Ranking System for Threaded Post Discussions
Company: Reddit
Role: Machine Learning Engineer
Category: ML System Design
Difficulty: easy
Interview Round: Onsite
Design the system that ranks the comments under a post on a large online discussion platform. Assume users write comments on posts, reply to each other in nested threads, and vote comments up or down. When someone opens a post, the default view should put the most valuable comments first, and the most valuable replies first under each of them. The report gives only the name of the problem, so the objective, the scale and the latency budget are open: settle them with the interviewer before designing.
```hint What a vote really measures
Votes are the obvious label, but think about what a comment's vote count measures when the comments at the top are seen by far more people than the ones further down.
```
```hint A tree, not a list
Decide how ranking replies differs from ranking top-level comments, and what the page needs on its first load.
```
### Clarifying Questions
- What should the order optimize: upvotes, replies and reading time, a measure of discussion quality, or a mix, and which harms such as abuse must it avoid?
- Is the order the same for every viewer of a post, or personalized?
- How many comments can a single post collect, and how many comment sections are loaded per second?
- What latency budget does the comment section have, and how quickly must a new comment or a burst of votes change the order?
- Do other sort options, such as newest or most upvoted, stay available next to the default?
### What a Strong Answer Covers
- An objective and labels that correct for the exposure and position bias in votes, with a sample-size-aware baseline
- Ranking a threaded tree: top-level comments, replies, collapsed threads and pagination
- Features from comment content, engagement per impression, author history, thread context and the viewer
- A model and serving path that separates precomputed from per-request work and keeps hot posts fresh
- Exposure for new comments through exploration, weighed against showing proven ones
- Offline and online evaluation, and defenses against vote manipulation and abusive comments
### Follow-up Questions
- A new comment has no votes yet. How does it ever earn a place near the top?
- A coordinated group upvotes one comment within minutes. How do you detect it and limit its effect?
- Your training data was logged under the current ranking. How do you evaluate a new model offline without favoring the old order?
- A post collects tens of thousands of comments in an hour. What changes in scoring and caching?
Overview: An ML system design question about ranking the comments under a post on a large discussion platform with nested replies and up and down votes. It tests label design that corrects the exposure bias in votes, features, ranking a threaded tree, exposure for new comments, serving hot posts and evaluation.