Design Comment Ranking and Threading for Facebook Posts
Last updated: November 29, 2026
Quick Overview
Design the backend that stores comments and replies on Facebook posts and returns a ranked, paginated thread for each viewer, including posts with hundreds of thousands of comments.
Meta
November 29, 20260
0
0 solved
Design the backend that stores comments and replies on Facebook posts and returns a ranked, paginated thread for each viewer, including posts with hundreds of thousands of comments.
Comments are a large share of Facebook engagement and a common Meta design prompt for E4 and E5 candidates. The interviewer wants a sensible data model for nested threads, a ranking approach that is cheap enough at read time, and a pagination scheme that stays stable while new comments arrive.
What the Interviewer Expects
- Model top-level comments and replies with a clear depth limit
- Propose a pagination cursor that is stable under inserts and re-ranking
- Split ranking into precomputed quality scores plus light per-viewer adjustments
- Address hot posts with many concurrent comment writes
- Cover edits, deletes, and moderation hiding
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How would you show 'Most relevant' versus 'Newest' toggles without two copies of the data?
- How would you rank friends' comments higher without per-viewer full sorts?
- What changes if replies can nest arbitrarily deep?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: add, edit, delete a comment or reply; list top-level comments ranked ("Most relevant") or chronological; expand replies; show comment counts. Non-functional: list p99 < 150 ms, new...
High-Level Design
- Comment Store sharded by
post_id: row(post_id, comment_id, parent_id, author_id, text, created_at, status). Depth limited to 2 (comment and reply), which matches the product and keeps queri...