1. Scale & Fundamental Design Principles
WhatsApp delivers over 100 billion messages per day across 2 billion users. The system is designed with a core tenet: messages are ephemeral in server memory. Once a message is delivered and acknowledged with double blue ticks, it is purged from server storage.
Peak throughput reaches ~1.2 million messages per second. The architecture must guarantee low latency (<100ms globally), high connection density per server, and end-to-end privacy.
2. Gateway Connection Tier & Epoll Multiplexing
Each mobile device maintains a persistent TLS-encrypted connection over TCP using a customized XMPP or WebSocket protocol. Erlang/BEAM or modern Rust/Go servers handle 2M+ concurrent idle connections per server using Linux epoll.
A distributed Session Registry in Redis/DynamoDB maps active UserIDs to their current Edge Server ID and connection file descriptor. When User A sends a message to User B, the router looks up User B's server location in under 2ms.
3. Message Delivery Flow & Offline Queuing
If the recipient is online, the message is routed directly to their connected edge server, pushed over TCP, and an ACK is returned to the sender. If the recipient is offline, the message is persisted to an append-only Offline Message Store (Cassandra / RocksDB) with a 30-day TTL.
Upon reconnecting, the client triggers a sync handshake, pulls pending messages in batches of 50, and sends receipt acknowledgments so the server safely deletes them.
4. Group Chat & Fan-Out Optimization
For group chats with hundreds of members, sending messages individually from the client wastes mobile bandwidth. Instead, the sender encrypts the message once with a Sender Key, sends a single copy to the Group Service, and server-side workers fan out the payload to all group participants.
Model this architecture on the HLDForge Canvas
Turn static box diagrams into living, collaborative systems. Drag and drop microservices, Kafka clusters, and cache tiers. Run automated SPOF detection and STRIDE threat modeling in real time.
Written by HLDForge Architecture Team
Lead Communications Systems Architect
The HLDForge Architecture Team publishes practical engineering guides, real-world case studies, and high-concurrency blueprints to help engineers build scalable and fault-tolerant software.