Detailed Design of WhatsApp
Explore the detailed System Design of WhatsApp by tracing the flow of messages and media files. Learn how WebSocket servers scale connections and how services like Message Service and Asset Service use Mnesia, Redis, and Kafka to ensure reliable, low-latency delivery for individual and group chats.
Detailed design
The high-level design leaves several key questions unanswered:
How is a communication channel created between clients and servers?
How can the design scale to support billions of users?
How is user data stored?
How is the receiver identified for message delivery?
Let’s explore each component in detail, starting with how users connect to chat servers.
Connection with a WebSocket server
Each active device establishes a WebSocket connection to the messaging infrastructure. The WebSocket servers maintain persistent connections with online users. To support billions of users, connections are distributed across a cluster of WebSocket servers. Each server maintains a session for every active connection. A WebSocket manager maintains the mapping between users, active connections, and servers. This mapping is ...