Design News Feed Ranking: ML System Design for a Personalized Feed
ML system design for a personalized news feed like Facebook or LinkedIn: multi-objective engagement prediction, ranking, integrity and freshness.
The question: design the ML system that ranks posts in a social network's news feed, like Facebook, Instagram or LinkedIn. Each user has thousands of eligible posts from friends, followed pages and groups; the feed should show the ones they'll find most valuable, keep integrity problems out, and still feel fresh. The backend side of feeds (fan-out, storage) is covered in fan-out; this page is the ranking.
1. Clarify requirements
| Question | Answer |
|---|---|
| Goal? | Meaningful engagement and daily return visits, not just clicks |
| Scale? | 2B daily users; on average 1,500 eligible posts per user per session |
| What's eligible? | Posts from friends, followed pages and groups, plus some unconnected recommended posts |
| Latency? | First screen of the feed in under 300 ms end to end |
| Constraints? | Downrank misinformation and low-quality content; respect blocks and privacy settings |
2. Frame it as an ML problem
Pointwise multi-task prediction: for each (viewer, post), predict the probability of several actions, then combine them into a value score. Actions have different worth, and negative actions subtract:
value(viewer, post) = 1.0·p(like) + 4·p(comment) + 6·p(share) + 2·p(dwell > 10 s)
+ 3·p(friend's post interaction) − 20·p(hide) − 50·p(report)
(illustrative weights; tuned by experiments against long-term retention)Integrity classifiers (spam, clickbait, misinformation) run separately and act as demotions or filters. See ML problem framing.
3. Data and labels
- Impression logs with dwell time and position, joined to actions (like, comment, share, hide, report) within a session window.
- Comments and shares are rarer than likes, so each head has its own positive rate; downsample negatives per task.
- Surveys ("is this post worth your time?") give a small but valuable satisfaction label used to tune weights and train a satisfaction head.
- Time-based splits and position-bias handling; see feedback loops.
4. Architecture
5. Features
| Group | Examples |
|---|---|
| Viewer | Activity level, interests, languages, typical session length |
| Author | Relationship strength with viewer (past interactions, messages, tags), author type (friend, page, group) |
| Post | Type (photo, video, link, text), age, early engagement velocity, topic, integrity scores, embeddings of text and media |
| Viewer-post | Viewer's past engagement with this post type and topic, whether friends have engaged |
| Context | Device, connection, time since last session, position |
Relationship strength (affinity) between viewer and author is often the strongest single signal, and post age plus early engagement velocity captures freshness and quality together.
6. Models
- Light ranker: a small model (or distilled heavy model) on precomputed features to trim candidates cheaply.
- Heavy ranker: a multi-task deep network with a head per action and shared embeddings; see choosing a model.
- Integrity models: separate classifiers per harm, so policy changes don't require retraining the ranker; see harmful content detection.
- Calibration: each head is calibrated, because the value formula adds probabilities from different tasks.
7. Serving
Feed loads : 2B users × 8 sessions/day = 16B/day ≈ 185K RPS avg, ~500K peak
Candidates : 1,500 posts → light ranker → 500 → heavy ranker → top 50
Heavy model : 500 × 500K = 250M predictions/s at peak → batched GPU inference
Budget : inventory 40 ms | features 40 ms | light 30 ms | heavy 80 ms | final 20 ms
Pagination : rank 50, return 10; rank the next page when the user scrolls,
using fresh features (they may have engaged with earlier posts)Pre-rank in the background just before a likely session (for example when a notification is opened), and cache the ranked list briefly so back-and-forth navigation doesn't rerank. See model serving.
8. Final pass rules
- No more than two consecutive posts from the same author or page.
- Mix content types (photo, video, text) in the first screen.
- Already-seen posts drop sharply unless there's new activity on them.
- Demote borderline content by a factor from integrity scores rather than removing it outright.
9. Evaluation
| Level | Metrics |
|---|---|
| Offline per head | AUC, normalised log loss, calibration |
| Offline ranking | NDCG@10 using value-weighted labels |
| Online primary | Daily active users, sessions per user, meaningful interactions (comments, shares) |
| Online guardrails | Hide and report rates, integrity prevalence, survey satisfaction, time spent on low-quality content |
Short-term engagement can rise while long-term retention falls (outrage bait). Long-running holdouts and survey metrics protect against optimising the wrong thing. See A/B testing.
Follow-up questions to expect
- *How do you balance friends' posts against recommended content?* A blending policy with a target share, tested online; recommended posts must clear a higher score bar.
- *How do you avoid rewarding outrage?* Weight comments by quality signals, use survey labels, and demote content integrity classifiers flag.
- *How fresh is the feed?* Post age as a feature, early engagement velocity from streams, and reranking on each page fetch.
Where it’s used
Friend and page feeds ranked by multi-task value models with integrity demotions.
Feeds that weight comments and dwell from relevant connections over raw reactions.
Hot and best rankings blended with personalisation for logged-in users.
In an interview
- Write a value formula from several predicted actions, including negative ones.
- Separate integrity models from the engagement ranker.
- Name affinity and early engagement velocity as key features.
- Use long-term and satisfaction guardrails, not only engagement.
Frequently asked questions
How is a news feed ranked with machine learning?
A multi-task model predicts the probability of actions like likes, comments, shares, long dwell, hides and reports for each eligible post, and a weighted value formula combines them, with integrity models demoting harmful content and a final pass adding diversity.
What features matter most for feed ranking?
Relationship strength between viewer and author, post type and age, early engagement velocity, the viewer's past engagement with similar content, and context such as device and time.
Further reading
- Modeling Task Relationships in Multi-task Learning with Multi-gate Mixture-of-ExpertsMa et al., KDD 2018
- Deep Learning Recommendation Model for Personalization and Recommendation SystemsNaumov et al., Meta, 2019