Design: News Feed Ranking - Multi-Objective Optimization at Scale
Reading time: ~25 min | Interview relevance: High | Roles: MLE
The Real Interview Moment
"Design the news feed ranking system for a social media platform like Facebook or Twitter." You start describing a binary classifier that predicts clicks. The interviewer pushes: "You're optimizing for clicks. What happens to content quality? What about rage-bait posts that get tons of clicks but make users angry? How do you balance engagement with user well-being?"
Feed ranking is the ML system design question that tests multi-objective thinking. It's not enough to predict clicks - you need to optimize for a portfolio of objectives while avoiding harmful optimization side-effects.
What You Will Master
- Multi-objective ranking: likes, comments, shares, time-spent, and quality
- Real-time feature engineering for social feeds
- Two-stage retrieval + ranking for social content
- Diversity and freshness constraints
- Responsible AI: avoiding engagement traps and filter bubbles
- Creator-side optimization: fair exposure
The Complete Design
Step 1: Requirements (5 min)
Functional requirements:
- Rank posts from friends, groups, and pages for 2B daily active users
- Mix content types: text, images, videos, links, stories
- Show ~50 posts per session from a pool of ~1000 candidate posts
Non-functional requirements:
- Latency: <200ms to render feed
- Freshness: New posts appear within minutes
- Diversity: No single friend/topic dominates the feed
- Safety: Misinformation and harmful content demoted
Step 2: Problem Formulation (5 min)
The key insight: feed ranking is a multi-objective problem.
| Action | Business Value | Model |
|---|---|---|
| Like | Low engagement signal | P(like) - binary classifier |
| Comment | Medium engagement | P(comment) - binary classifier |
| Share | High engagement + virality | P(share) - binary classifier |
| Time spent | Attention signal | E(time) - regression |
| Hide/report | Negative signal | P(hide) - binary classifier |
Combined score: Score = w1*P(like) + w2*P(comment) + w3*P(share) + w4*E(time) - w5*P(hide)
The weights (w1-w5) are tuned via A/B testing to optimize the north star metric (daily active users, time spent per day).
"I'd design this as a multi-objective ranking system. For each candidate post, I predict multiple engagement signals - P(like), P(comment), P(share), E(time spent), and P(negative feedback). These are combined with learned weights into a final score. The system uses a two-stage architecture: candidate generation retrieves ~1000 relevant posts from the social graph, then the ranking model scores them using user features, post features, and real-time context. A re-ranking layer adds diversity constraints and content policy enforcement. The weights in the multi-objective function are the key lever - they determine whether the feed optimizes for engagement, quality, or user well-being."
Step 3: Features & Data (8 min)
Feature Categories
| Category | Features | Freshness |
|---|---|---|
| User | Demographics, interest topics, engagement history, friend list, active hours | Hourly |
| Post | Content type, text embeddings, image features, author, post age, early engagement stats | Real-time |
| Author | Content quality score, posting frequency, follower count, engagement rate | Daily |
| User-Author | Interaction frequency, relationship strength, message history | Daily |
| Context | Time since last session, device, network speed, notification vs. organic open | Real-time |
| Real-time | Likes/comments in last 10 min, trending score, friend engagement on this post | Streaming |
Training Data
- Positive labels: User engaged (like, comment, share, watch > 50%)
- Negative labels: Post was shown but user scrolled past (dwell time < 2 sec)
- Label delay: Immediate for most actions
- Volume: Billions of impressions per day
Optimizing purely for engagement metrics leads to rage-bait, clickbait, and misinformation - content that generates clicks but makes users unhappy. Include "negative engagement" signals: P(hide), P(report), survey-based quality scores (periodically ask users "Was this post worth your time?"). This shows the interviewer you think about responsible AI, not just metrics.
Step 4: Model (8 min)
Architecture: Multi-Task Learning
Why multi-task learning?
- Shared feature extraction is efficient (one forward pass, five predictions)
- Tasks share information (posts that get likes also tend to get comments)
- Can weight objectives independently at serving time without retraining
Model Comparison
| Model | Pros | Cons |
|---|---|---|
| Separate models per objective | Simple, independent tuning | N forward passes, no shared learning |
| Multi-task with shared bottom | Efficient, shared learning | Negative transfer if tasks conflict |
| MMoE (Multi-gate Mixture of Experts) | Handles task conflicts, SOTA | Complex architecture |
Step 5: Serving (8 min)
Candidate Generation Sources
| Source | What It Retrieves | Priority |
|---|---|---|
| Friends' posts | Recent posts from connections | High |
| Groups | Posts from joined groups | Medium |
| Pages/Follows | Posts from followed pages | Medium |
| Recommended | Posts from non-connections (explore) | Low |
Re-Ranking Layer
The re-ranking layer applies constraints after ML scoring:
- Diversity: No more than 2 consecutive posts from the same author
- Content type mixing: Alternate between text, image, and video posts
- Freshness: Boost recent posts, decay old ones
- Content policy: Demote borderline content (misinformation, hate speech)
- Ad insertion: Insert ads at positions 3, 8, 15... without disrupting experience
Step 6: Evaluation & Iteration (8 min)
Online Metrics
| Metric | What It Measures | Optimization Direction |
|---|---|---|
| DAU | Daily active users | Increase |
| Time spent | Minutes per session | Increase (with ceiling) |
| Content production | Posts created per user | Increase |
| Negative feedback rate | Hide/report per impression | Decrease |
| Meaningful social interactions | Comments, shares, meaningful reactions | Increase |
The Weight-Tuning Process
- Start with equal weights for all objectives
- Run A/B tests varying one weight at a time
- Measure impact on north star metrics (DAU, meaningful interactions)
- Iterate - this is a continuous process, not a one-time setup
Practice Problems
Problem 1: Viral Misinformation
Direction
A false news article is going viral on your platform - 500K shares in 2 hours. Your engagement model ranks it highly because of the engagement. How does your system handle this?
Key Insight
This requires a separate content integrity pipeline that runs alongside the ranking model. Signals: rapid virality with unusual patterns, fact-checker flags, user reports. Action: reduce distribution (not just label - actually lower the ranking score). The key design point is that content integrity and engagement ranking must be independent systems - the engagement model should never override content policy decisions.
Problem 2: New User Feed
Direction
A user signs up and has zero friends. What does their feed look like?
Key Insight
Cold start for feed: (1) Onboarding - suggest friends and topics to follow. (2) Trending/popular content filtered by declared interests. (3) Editorially curated "best of" content. (4) As user adds friends and follows topics, gradually blend personalized content. Key metric during onboarding: D7 retention (do they come back after 7 days?).
Interview Cheat Sheet
| Question Pattern | Framework | Key Phrases |
|---|---|---|
| "Design a news feed" | Multi-objective ranking | "Predict multiple engagement signals, combine with learned weights" |
| "How do you balance engagement and quality?" | Negative signals + guardrails | "Include P(hide), P(report) as negative objectives, monitor meaningful social interactions" |
| "How do you handle diversity?" | Re-ranking constraints | "Post-scoring re-ranking with diversity, freshness, and content type mixing constraints" |
Spaced Repetition Checkpoints
- Day 0: Write the multi-objective scoring formula from memory. Explain each term.
- Day 3: Explain multi-task learning vs. separate models. Draw the MMoE architecture.
- Day 7: Design a feed ranking system for a professional network in 45 minutes.
- Day 14: Discuss the engagement vs. quality trade-off. How do you measure "meaningful" interactions?
- Day 21: Mock interview with follow-ups on content policy, misinformation, and creator fairness.
What's Next
- Ad Click Prediction - Ranking with strict calibration and auction mechanics
- Content Moderation - The content integrity side of the equation
