← Back to All Questions
Medium~60 minSocial Media

Design Facebook News Feed - Content Ranking & Personalization

MetaLinkedInTwitterTikTokInstagramPinterestReddit

📝 Problem Description

Design a personalized news feed system like Facebook's that displays relevant content to users based on their connections, interests, and engagement patterns. The system should rank posts from friends, pages, and groups to maximize user engagement while handling billions of users and posts.

👤 Use Cases

1.
User wants to open the app so that they see a personalized feed of relevant posts
2.
User wants to scroll through the feed so that new content loads seamlessly
3.
User wants to interact with a post so that future recommendations improve
4.
User wants to publish a post so that it appears in their friends' feeds
5.
Advertiser wants to create an ad so that it appears in relevant users' feeds

✅ Functional Requirements

  • Display personalized feed of posts from friends, pages, groups
  • Rank content by relevance (not just recency)
  • Support multiple content types (text, images, videos, links)
  • Real-time updates for new highly relevant content
  • Infinite scroll with pagination
  • Mix organic and sponsored content
  • Support "See First" and "Unfollow" preferences

⚡ Non-Functional Requirements

  • Feed load time < 500ms
  • Handle 2 billion daily active users
  • Process 1 billion new posts per day
  • Personalization with < 100ms ranking latency
  • Near real-time post availability (< 5 seconds)
  • High availability (99.99%)

⚠️ Constraints & Assumptions

  • Each user follows 200-1000+ friends/pages on average
  • Active users scroll through 300+ posts per day
  • Feed must feel "fresh" - show recent content
  • Balance engagement optimization with content diversity
  • Respect user-defined preferences (muted, prioritized)

📊 Capacity Estimation

👥 Users
2B DAU, average 200 friends each
💾 Storage
50PB for posts, 10PB for engagement data
⚡ QPS
Feed reads: 2M/sec, Post writes: 20K/sec
📐 Assumptions
  • 2 billion daily active users
  • 1 billion new posts per day
  • Average user has 200 friends, follows 50 pages
  • Feed shows 50 posts per session, 6 sessions per day
  • Each post: 1KB metadata + media references

💡 Key Concepts

CRITICAL
Fan-out on Write
Push post_id to all followers' feed caches when posted. Fast reads, but expensive writes for popular users.
CRITICAL
Fan-out on Read
For celebrities, don't push - pull their posts when follower reads feed. Avoids massive write amplification.
CRITICAL
Ranking Model
ML model scores posts based on features: affinity, recency, engagement probability. Optimizes for user engagement.
HIGH
Affinity Score
How close the poster and viewer are: interaction history, mutual friends, shared groups.
MEDIUM
Edge Rank
Facebook's original algorithm: Affinity × Weight × Decay. Modern systems use deep learning.
HIGH
Content Diversity
Don't show all posts from one person. Mix content types and sources for better experience.

💡 Interview Tips

  • 💡Start by clarifying what content goes in the feed (friends, pages, groups)
  • 💡Discuss the fan-out strategy early - it's the core challenge
  • 💡Explain the ranking model at a high level (features, not just ML)
  • 💡Draw the feed generation flow
  • 💡Mention the celebrity problem and hybrid solution
  • 💡Cover both write path (posting) and read path (viewing feed)