Practice/Meta/Design a News Feed Ranking System
Design a News Feed Ranking System
ML System DesignMust
Problem Statement
You are tasked with designing a recommendation engine that surfaces personalized content to users across a social media platform. The system must handle billions of content items (posts, videos, articles, stories) and serve recommendations to hundreds of millions of active users daily. Each user should receive a ranked feed of content that balances relevance, recency, engagement potential, and diversity. The system needs to learn from user interactions in real-time and adapt recommendations accordingly.
The challenge extends beyond simple popularity ranking -- you must account for individual user preferences, social graph relationships, content freshness, engagement patterns, and business objectives like ad placement. Your design should handle the cold start problem for new users and new content, while maintaining sub-second latency for feed generation even during peak traffic hours.
Key Requirements
Functional
- Content Ingestion -- ingest millions of new content items per hour from various sources (user posts, shared links, videos, ads)
- Personalized Ranking -- generate a ranked feed of content tailored to each user's interests and behavior
- Real-time Updates -- incorporate fresh user interactions (likes, shares, comments) to refine future recommendations
- Multi-objective Optimization -- balance engagement, content diversity, ad revenue, and network effects
- Feedback Loop -- learn from implicit (scroll time, click-through) and explicit (likes, shares) user signals
Non-Functional
- Scalability -- support 500M+ daily active users, 10B+ content items in catalog, 100K+ content updates per second
- Reliability -- 99.95% uptime with graceful degradation when ML models fail
- Latency -- p99 feed generation latency under 500ms, model inference under 100ms
- Consistency -- eventual consistency acceptable for user profiles and content metadata; strong consistency for critical signals like blocks/reports
What Interviewers Focus On
Based on real interview experiences, these are the areas interviewers probe most deeply:
1. Candidate Generation vs. Ranking Architecture
The two-stage funnel approach is critical for handling massive scale. You cannot score billions of items in real-time.
Hints to consider:
- Discuss retrieval strategies like collaborative filtering, content-based filtering, and social graph-based retrieval to narrow down from billions to thousands of candidates
- Consider using approximate nearest neighbor (ANN) search with embeddings for efficient candidate retrieval
- Explain how to parallelize multiple candidate generation strategies and merge results before the ranking stage
- Address how to ensure diversity in the candidate set to avoid filter bubbles
2. Feature Engineering and Model Architecture
The quality of recommendations depends heavily on signal extraction and model design choices.
Hints to consider:
- Identify user features (demographics, historical interactions, engagement patterns), content features (topic, format, recency), and contextual features (time of day, device type)
- Discuss embedding representations for users and content items in a shared latent space
- Consider using a pointwise, pairwise, or listwise learning-to-rank approach
- Explain tradeoffs between complex deep learning models (transformers, two-tower networks) and simpler gradient boosted trees for production serving
3. Real-time vs. Batch Processing Pipeline
Balancing freshness with computational efficiency is a core design challenge.
Hints to consider:
- Use batch processing (daily or hourly) for expensive operations like full model retraining and embedding generation
- Implement near-real-time feature updates via streaming pipelines for engagement signals (clicks, likes within the last hour)
- Consider online learning or model fine-tuning to quickly adapt to trending content or viral posts
- Discuss how to invalidate or update cached recommendations when user preferences change
4. Cold Start and Exploration vs. Exploitation
New users and new content create unique challenges that pure ML approaches cannot solve alone.
Hints to consider:
- For new users, leverage demographic information, initial interests survey, or popular content until sufficient interaction history exists
- For new content, use content-based features and creator history to bootstrap predictions
- Implement exploration strategies like epsilon-greedy or Thompson sampling to expose users to diverse content and gather training data
- Discuss position bias correction since users are more likely to engage with top-ranked items regardless of actual relevance
5. Evaluation Metrics and A/B Testing
Defining success for a recommendation system involves multiple competing metrics.
Hints to consider:
- Track online metrics like click-through rate (CTR), dwell time, engagement rate (likes/shares per impression), and daily active users
- Use offline metrics like AUC, NDCG (normalized discounted cumulative gain), or MRR (mean reciprocal rank) for model evaluation
- Consider counter-metrics to prevent gaming the system (e.g., monitoring clickbait, low-quality content, or echo chamber formation)
- Design experiments carefully to account for network effects where one user's experience affects others through social interactions