100 Billion+ messages per day on minimal infrastructure
WhatsApp Architecture Blueprint
Click ▶ RUN to animate active particle streams across microservices
How Traffic Flows Through WhatsApp
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.
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.
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.
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.
Study WhatsApp'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.
The C1000K Problem: 2.5 Million Concurrent TCP Connections per Server
Standard Linux servers struggle beyond 50,000 concurrent network sockets because thread context-switching overhead and socket memory buffers exhaust kernel resources.
WhatsApp customized FreeBSD kernels and leveraged Erlang's BEAM actor model. Each Erlang actor process requires only ~2.6 KB of memory. A single physical dual-socket server comfortably runs over 2.5 million lightweight processes, each managing one user socket without thread contention.
⚖️ Architectural Trade-Offs & Decisions
Why the engineering team chose this specific stack over competing alternatives
Erlang was purpose-built by Ericsson for high-concurrency telecommunication switches. Its actor model guarantees that if one connection process crashes, it is completely isolated and cannot affect any of the other 2 million connected users. Erlang also supports hot-swapping code in production with zero server restarts.
Storing 100 billion messages daily forever would require hundreds of petabytes of database clusters, massive backup systems, and enormous regulatory compliance liability. Deleting messages immediately upon delivery reduced infrastructure costs by 95% and ensured maximum privacy.
The BGP Routing & DNS Cascade Outage (2021)
WhatsApp, Instagram, and Facebook went dark globally for over 6 hours when Border Gateway Protocol (BGP) routing records were accidentally withdrawn from the internet.
A routine backbone maintenance command accidentally disconnected Facebook's data centers from the internet. Because DNS servers were hosted inside the same autonomous network, global DNS lookups failed, making domains unresolvable.
Isolated out-of-band management networks were built, automated command validation was added to prevent autonomous network isolation, and DNS hosting was geographically diversified.
📋 Complete Microservice Specifications
Every service in the WhatsApp ecosystem with production tech stacks and failure impact
| Component | Tier / Layer | Tech Stack | Production Function | Status / Chaos |
|---|---|---|---|---|
| Sender App | CLIENT | iOSAndroidSignal Protocol | iOS / Android client executing local Signal Protocol end-to-end encryption | |
| Recipient App | CLIENT | iOSAndroidWebSockets | Recipient mobile device receiving ciphertext and sending delivery receipts (✓✓) | |
| WebSocket Connection Gateway | SERVICE | ErlangBEAM VMFreeBSD | Erlang BEAM process farm maintaining persistent long-lived TCP/TLS sockets | |
| Message Router | SERVICE | ErlangMnesia | Stateless Erlang routing service mapping recipient user ID to active server node | |
| Offline Message Queue | QUEUE | EjabberdMnesiaTTL | Temporary memory queue holding messages for recipients who are currently offline | |
| Ephemeral Storage | STORAGE | Mnesia | Encrypted transient storage buffer. Dropped immediately upon delivery acknowledgment. | |
| Media Object Store | STORAGE | AWS S3CDN | Encrypted media files (photos, videos, voice notes) stored with 30-day auto-purge | |
| Push Notification Service | SERVICE | GoAPNsFCM | APNs & FCM bridge waking sleeping mobile apps when new messages arrive | |
| User & Account DB | DATABASE | PostgreSQL | Stores phone numbers, profile public keys, and cryptographic pre-keys | |
| Presence Engine | SERVICE | Redis | Tracks online/offline status and last seen timestamps using Redis |