Design: Social Feed Ranking
Ranking posts in a social media feed balancing engagement, relevance, content quality, and creator fairness.
The Problem
Design a social feed for a platform where users follow friends and creators. Each user follows 200 to 500 accounts, generating thousands of new posts daily. Show a personalized feed of 20 posts per screen load. The system serves 100 million daily active users.
High-Level Architecture
User Opens App (Feed Request)
│
▼
┌───────────────────────────────┐
│ STAGE 1: CANDIDATE SOURCING │ (~5ms)
│ Followed accounts + suggested │
│ Output: ~2000 candidate posts │
└───────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ STAGE 2: SCORING │ (~30ms)
│ Multi-objective deep model │
│ Predict engagement signals │
│ Output: Scored candidates │
└───────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ STAGE 3: POLICY & RERANKING │ (~10ms)
│ Content quality, diversity, │
│ creator fairness, ad blending │
│ Output: Final feed (20 posts) │
└───────────────────────────────┘
Stage 1: Candidate Sourcing
Gather candidate posts from multiple sources:
- In-Network: Recent posts from accounts the user follows. This is the core of the feed.
- Out-of-Network Suggestions: Posts from accounts the user does not follow but might enjoy, based on interest graph similarity or friend-of-friend engagement.
- Trending/Breaking: Globally viral content relevant to the user's interests.
- Reshares: Content reshared by people the user follows.
Combine and deduplicate to get roughly 2000 candidate posts.
Stage 2: Multi-Objective Scoring
A deep model predicts multiple engagement probabilities for each candidate:
- $P(\text{Click})$: Will the user click/expand the post?
- $P(\text{Like})$: Will the user like it?
- $P(\text{Comment})$: Will the user comment?
- $P(\text{Share})$: Will the user share it?
- $P(\text{Long Dwell})$: Will the user spend more than 30 seconds on it?
- $P(\text{Hide/Report})$: Will the user actively dislike or report it?
Combine into a value function:
$$\text{Score} = w_1 \cdot P(\text{Like}) + w_2 \cdot P(\text{Share}) + w_3 \cdot P(\text{Long Dwell}) - w_4 \cdot P(\text{Hide})$$
The negative weight on Hide ensures that posts likely to cause dissatisfaction get demoted even if they might get stress-clicks.
Stage 3: Policy and Re-Ranking
Raw model scores are adjusted by business policies:
- Content Quality Signals: Demote posts flagged by a content quality classifier as low-quality, clickbait, or borderline policy violations.
- Diversity: Do not show 5 posts from the same creator in a row. Spread different content types (text, photos, videos) across the feed.
- Creator Fairness: Ensure smaller creators get minimum exposure rather than all traffic going to the top 0.1% of accounts.
- Ad Insertion: Place sponsored posts at positions 3, 8, and 15 (for example) with frequency caps per advertiser.
- Freshness Decay: Progressively discount posts that are more than 24 hours old.
Monitoring and Feedback Loops
Track online metrics after deployment:
- Session Time: Are users spending more or less time on the platform?
- DAU/MAU Ratio: Are users coming back daily?
- Hide/Report Rate: Is the model surfacing content that users actively reject?
- Creator Posting Rate: Are creators still motivated to post? If ranking changes cause creator content to get no views, creators leave the platform.
Watch for feedback loops: if the model promotes a post early, it gets more engagement, which makes the model promote it even more. Use exploration slots (Thompson Sampling) to give new posts fair initial exposure.
Say this out loud
A social feed ranking system sources candidates from followed accounts and suggestions, scores them with a multi-objective model predicting likes, shares, dwell time, and negative signals, then applies policy re-ranking for content quality, diversity, creator fairness, and ad insertion before displaying the final feed.
Followups to expect
- How do you prevent misinformation from going viral? Integrate a content integrity classifier that flags posts for fact-checking. Reduce distribution of flagged content while it is under review rather than removing it immediately.
- How do you A/B test feed ranking changes? Split users into control and treatment groups. Measure guardrail metrics (hide rate, session time, DAU) alongside the target metric. Run the test for at least 2 weeks to capture weekly usage patterns.
Check yourself
Why can a social feed not simply show posts in reverse chronological order?