Facebook Feed System Design

Design a scalable social media feed system that delivers personalized content to billions of users in real-time. Learn how Facebook, Instagram, and Twitter build feeds that handle massive scale while maintaining low latency.

🚀 Design Journey with SACRED Framework

We'll design Facebook Feed step-by-step using the SACRED methodology, covering everything from basic requirements to advanced optimizations.

S
Requirements & Scale
A
Entities & Contracts
C
Basic Architecture
R
Scale & Performance
E
Failures & Recovery
D
Advanced Topics

📱 What We're Building

Core Features

  • ✅ Create and view posts (text, images, videos)
  • ✅ Follow/unfollow users
  • ✅ Generate personalized feeds
  • ✅ Real-time updates
  • ✅ Like, comment, and share posts
  • ✅ Push and pull feed generation

Scale Requirements

  • 📊 2 billion daily active users
  • ⚡ 100K posts per second at peak
  • 🔄 500M feed refreshes per hour
  • ⏱️ <100ms feed generation latency
  • 💾 Petabytes of post data
  • 🌍 Global distribution

🎯 Key Challenge

The main challenge is delivering a personalized, ranked feed to billions of users with minimal latency while handling celebrity accounts with millions of followers and ensuring content freshness.

🔑 Core Concepts You'll Master

Push vs Pull Model

Learn when to push updates to followers' feeds vs pulling on-demand, and the hybrid approach.

Feed Ranking

Understand ML-based ranking algorithms that optimize for user engagement and relevance.

Timeline Sharding

Explore how to shard user timelines across databases for horizontal scalability.

Celebrity Problem

Handle accounts with millions of followers without system overload using smart strategies.

Real-time Updates

Implement WebSocket connections and server-sent events for live feed updates.

Cache Strategies

Multi-layer caching with Redis for hot feeds and CDN for media content delivery.

🏗️ Architecture Preview

Facebook Feed High-Level Architecture

ClientAPI GatewayMicroservicesPost ServiceFeed ServiceFollow ServiceRanking ServiceData LayerDynamoDBPosts Table- id (PK)- content- creatorIdFollow Table- userFollowing (PK)- userFollowed (SK)- createdAtPrecomputedFeed- userId (PK)- postIds[]Redis CacheHot FeedsMessage QueueAsync ProcessingS3 + CDNMedia Storage

📝 Write Path

Posts are written to DynamoDB and fanout to followers' feeds asynchronously.

📖 Read Path

Feeds are served from cache or generated on-demand using a hybrid push-pull model.

⚡ Performance

Multi-layer caching and CDN ensure <100ms latency for feed generation globally.

💡 Key Takeaways

Technical Skills

  • • Design systems handling billions of users
  • • Implement hybrid push-pull architectures
  • • Build real-time notification systems
  • • Apply ML-based content ranking
  • • Optimize with multi-layer caching

Problem-Solving Patterns

  • • Celebrity user optimization strategies
  • • Timeline sharding techniques
  • • Async processing with message queues
  • • Consistency vs availability trade-offs
  • • Global content distribution

Ready to master Facebook Feed design? Let's start with requirements!

Begin Journey →