System Design Problems
Design Facebook
Facebook serves 3B+ monthly active users with diverse features: news feed, groups, pages, marketplace, and messaging. This design focuses on the core social graph and feed generation.
- Scale β 3B MAU, 2B daily active users, 500M+ posts/day
- Social Graph β 500B+ friend connections
- Feed β Personalized ranking with ML models
Facebook is not just a social networkβit's a platform ecosystem requiring microservice architecture at planetary scale.
Requirements Clarification
Functional Requirements
- Send friend requests and manage friendships
- Post status updates, photos, videos
- View personalized news feed
- Like, comment, share posts
- Create and join groups
- Create and follow pages
- Send messages (Messenger)
- Notifications
Non-Functional Requirements
- Availability: 99.99% uptime
- Latency: News feed < 500ms
- Consistency: Eventual consistency for feed, strong for relationships
- Scale: 3B users, 500M posts/day, 2B feed reads/day
Back-of-the-Envelope Estimation
High-Level Architecture
Social Graph: TAO Architecture
Graph Partitioning
News Feed Generation
Feed Ranking Pipeline
Group Feed
Data Model
Scaling Strategies
Write Amplification vs Read Amplification
Practice Exercises
-
Graph Traversal: Design an algorithm to find "People You May Know" using friend-of-friend traversal. What's the time complexity?
-
Feed Consistency: How do you handle the case where a user unfriends someone, but the unfriended person's posts still appear in the feed? Design a consistency mechanism.
-
Group Scaling: Design a group with 10M members. How do you handle posts, notifications, and moderation?
-
Privacy: How would you implement fine-grained privacy controls (e.g., "friends except coworkers") without impacting feed generation performance?
What to Learn Next
-> Design Instagram Photo sharing and media delivery at scale.
-> Design Twitter Real-time feeds and fan-out architectures.
-> Design WhatsApp Messaging systems and real-time delivery.
-> Design YouTube Video streaming and content delivery.
-> CAP Theorem Consistency vs availability trade-offs.
-> Caching Strategies Distributed caching and invalidation.