Products›📱 Social Media›Facebook
👤

Facebook

3B+ user social network

99.99%
SLA
25
SERVICES
9
NODES
REQ/SEC0
LATENCY0ms
ERROR RATE0%
CACHE HIT95%
ACTIVE CONNS0
QUEUE DEPTH0

Facebook Architecture Blueprint

Click ▶ RUN to animate active particle streams across microservices

client
gateway
service
database
cache
queue
cdn
storage
SYSTEM ARCHITECTURE WALKTHROUGH

How Traffic Flows Through Facebook

EDGE TIER01

1. Ingress & Edge Routing

User requests arrive at the edge network. Global CDNs cache static assets and media. API Gateways terminate TLS, validate JWT authentication tokens, enforce token-bucket rate limits, and scrub malicious bot traffic before forwarding to internal services.

Client ApplicationAPI GatewayLoad BalancerGlobal Edge CDN
APPLICATION TIER02

2. Microservice Processing

Stateless domain services execute core business logic. Microservices communicate via high-performance internal gRPC/REST APIs and autoscaling worker pods, ensuring that high load on one domain never exhausts compute resources of another.

Facebook Core ServiceAuth & User Service
DATA TIER03

3. In-Memory Caching & Storage

Read-heavy traffic is served from in-memory Redis clusters with sub-millisecond latencies, protecting primary databases. Persistent databases (PostgreSQL, Cassandra, DynamoDB) maintain ACID consistency for financial ledgers, user accounts, and immutable state records.

Redis In-Memory CacheDistributed Database
MESSAGING TIER04

4. Asynchronous Event Streams

Heavy operations (notifications, audit logging, analytics, ML training, fan-out delivery) are decoupled into durable event logs like Kafka and SQS. This prevents user-facing requests from blocking on slow external networks.

Message Stream Queue
📖 SYSTEM DESIGN WHITE PAPERS & LOW-LEVEL SPECIFICATIONS

Study Facebook's database schemas, capacity math & production contracts

Beyond the visual blueprint, explore the exhaustive 7-section engineering whitepaper with real DDL schemas, API endpoints, failure mitigation matrices, and 45-minute FAANG interview scripts.

🏆 #1 HARDEST SYSTEM CHALLENGE

High-Availability Architecture at Facebook

⚠️The Engineering Bottleneck

Handling high concurrency spikes while maintaining sub-50ms latency and strict state consistency in the social domain.

💡The Winning Architectural Solution

Stateless microservices fronted by multi-region load balancers, backed by partitioned Redis caching and asynchronous Kafka event decoupling.

SCALE & PRODUCTION METRICS:99.99% SLA, sub-50ms P99 latency budget.

⚖️ Architectural Trade-Offs & Decisions

Why the engineering team chose this specific stack over competing alternatives

Why microservices with Kafka instead of a monolithic architecture for Facebook?
CHOSEN:✓ Event-Driven Microservicesvs Monolithic Architecture, Shared Database Microservices

Decoupling services allows independent autoscaling during traffic spikes, prevents a single service failure from crashing the entire platform, and enables multiple teams to deploy code autonomously.

🚨 REAL-WORLD POST-MORTEM

Cache Stampede Resilience at Facebook

The Incident

High-traffic cache key eviction previously caused hundreds of concurrent requests to overwhelm the database.

Root Cause Analysis

Lack of mutex locking during cache misses allowed a thundering herd to bypass the cache layer directly into the database.

How They Re-Architected It

Implemented distributed mutex locks (Redlock) and probabilistic early expiration (XFetch) to refresh cache keys before expiration.

📋 Complete Microservice Specifications

Every service in the Facebook ecosystem with production tech stacks and failure impact

ComponentTier / LayerTech StackProduction FunctionStatus / Chaos
Client ApplicationCLIENT
React NativeFlutteriOSAndroid
Native mobile and web applications initiating user requests
API GatewayGATEWAY
EnvoyJWTWAF
Kong/Envoy gateway handling auth, rate limiting, and request routing
Load BalancerLB
AWS ALBHAProxy
High-availability L7 load balancer distributing traffic across availability zones
Facebook Core ServiceSERVICE
GogRPCJava
Primary business logic engine coordinating social operations
Auth & User ServiceSERVICE
Node.jsOAuth2
Manages user accounts, session tokens, security credentials, and ACLs
Redis In-Memory CacheCACHE
Redis Cluster
In-memory cache for hot session data, active states, and sub-millisecond reads
Message Stream QueueQUEUE
Apache KafkaRabbitMQ
Asynchronous event stream decoupling heavy background processing
Distributed DatabaseDATABASE
PostgreSQLCockroachDB
Persistent transactional database maintaining immutable state records
Global Edge CDNCDN
CloudflareAkamai
Edge CDN points of presence caching static assets and media globally