πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Design Facebook

System Design ProblemsSocial Media Systems🟒 Free Lesson

Advertisement

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

  1. Send friend requests and manage friendships
  2. Post status updates, photos, videos
  3. View personalized news feed
  4. Like, comment, share posts
  5. Create and join groups
  6. Create and follow pages
  7. Send messages (Messenger)
  8. Notifications

Non-Functional Requirements

  1. Availability: 99.99% uptime
  2. Latency: News feed < 500ms
  3. Consistency: Eventual consistency for feed, strong for relationships
  4. Scale: 3B users, 500M posts/day, 2B feed reads/day

Back-of-the-Envelope Estimation

High-Level Architecture

ClientsGraphQL GatewayProfileServiceFriendServicePostServiceFeedServiceGroupServicePageServiceMessageServiceMessage Queue (Kafka)Graph Store(TAO/MySQL)Post DB(MySQL Sharded)Feed Cache(Redis/Tair)Object Store(Haystack/S3)Search Index(Elasticsearch)TAO: The Associations and Objects Graph StoreDistributed graph database built on MySQL with caching layer

Social Graph: TAO Architecture

Graph Partitioning

News Feed Generation

Feed Ranking Pipeline

CandidateGenerationFeatureExtractionML ModelScoringBlending& FilteringFeedOutput

Group Feed

Data Model

Scaling Strategies

Write Amplification vs Read Amplification

Practice Exercises

  1. Graph Traversal: Design an algorithm to find "People You May Know" using friend-of-friend traversal. What's the time complexity?

  2. 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.

  3. Group Scaling: Design a group with 10M members. How do you handle posts, notifications, and moderation?

  4. 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.

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement