KatInterview

Architecting a News Feed Comment Ranking System

Machine LearningModel answer
MediumModel answerMachine Learningranking-systemmulti-task-learningsystem-design

Last updated

Design an end-to-end machine learning system to rank comments on high-traffic posts, balancing user engagement, content quality, low latency, and cold-start handling.

Problem Statement

Design an end-to-end machine learning architecture to rank user comments on a high-traffic social news feed. The objective is to surface high-quality, engaging discussions while actively filtering out toxic content, spam, and low-effort noise.

The system serves a platform with hundreds of millions of active users where viral posts can quickly rack up thousands of comments.

Key Requirements

  1. Functional Requirements:

    • Deliver a personalized, ordered list of top-level comments and nested reply previews whenever a user expands a comment thread.
    • Boost constructive engagement (likes, high-quality replies, long dwell time) while suppressing negative interactions (reports, hides, block actions, toxicity).
    • Address the cold-start problem for newly posted comments so good content rises quickly.
  2. Non-Functional Requirements:

    • Low Latency: p99 latency must be under 100ms for thread retrieval and ranking.
    • Scalability: Handle high read traffic (10,000+ QPS at peak) and rapid incoming comment velocity during breaking news events.
    • Freshness: Newly created comments must be eligible for candidate generation within seconds, and interaction counters (e.g., vote counts) must update within minutes.

System Scope & Expectations

Walk through the complete system lifecycle, covering:

  1. Problem Formulation & Optimization Objectives
  2. Data Pipeline & Feature Engineering
  3. Multi-Stage Serving Architecture (Retrieval, Filtering, Heavy Ranking, Policy)
  4. Machine Learning Model Architecture & Loss Functions
  5. Offline & Online Evaluation Strategy (including guardrail metrics and bias mitigation)

Hints

Hint 1

Break the serving workflow into distinct stages: lightweight candidate generation, hard integrity filtering, deep ranking, and business rule re-ranking.

Hint 2

Consider how to combine multiple distinct interaction probabilities (likes, replies, reports) into a single composite score while maintaining modular control.

Hint 3

Address position bias explicitly in your training strategy; otherwise, top-ranked comments will dominate engagement loops artificially.