KatInterview

Build a Real-Time Comment Ranking System

Machine LearningModel answer
HardModel answerMachine Learningrankingml-system-designreal-time

Last updated

Design an ML-powered system to rank comments in discussion threads, balancing quality, safety, and latency at scale.

Problem

You're building a ranking system for discussion threads on a social platform. Each thread contains comments organized hierarchically (replies to comments form a tree structure). Your goal is to order comments so that high-quality discussions appear prominently while minimizing exposure to harmful content.

Requirements

Functionality:

  • Promote substantive, constructive comments over low-value ones
  • Reduce visibility of toxic, spam, or rule-breaking content
  • Support varied perspectives without creating echo chambers

Performance:

  • End-to-end page load must complete within 100ms
  • Newly posted comments should become rankable within a few seconds
  • System must support millions of concurrent threads and billions of daily user interactions

What to Design

Provide a complete ML system design including:

  1. Architecture overview: How data flows from comment creation through to displaying ranked results
  2. Modeling approach: What type of model you'd use, what it predicts, and how you'd generate training labels
  3. Feature engineering: Key signals from comments, authors, viewers, and discussion context
  4. Trade-off analysis: How you'd handle competing constraints like computational cost versus data recency, and strategies for comments with little interaction history

Hints

Hint 1

Think about how comment ranking differs from feed ranking: the candidate pool is already scoped to one thread, and the structure is hierarchical rather than flat.

Hint 2

Consider separating expensive computations that can be shared across all viewers from lightweight personalization that runs per request.

Hint 3

New comments lack engagement history. What signals are available immediately, and how can you ensure they get enough exposure to gather feedback?