WhatsApp Detailed Design
Take a deep dive into the design of the WhatsApp system and understand the interaction of various microservices.
Detailed design
The high-level design discussed in the previous lesson does not answer the following questions.
-
How is a communication channel created between clients and servers?
-
How can the high-level design be scaled to support billions of users?
-
How the user’s data is stored?
-
How is the receiver identified to whom the message is delivered?
To answer all these questions and similar other questions, let’s dive deep into the high-level design and explore each component in detail. Let’s start with how users make connections with the chat servers.
Connection with a WebSocket server
In WhatsApp, each active device is connected with a WebSocket server via WebSocket protocol. A WebSocket server keeps the connection open with all the active (online) users. Since one server is not enough to handle billions of devices, there will be enough servers to handle billions of users. The responsibility of each of these servers is to provide a port to every online user. The mapping between servers, ports, and users is stored in the WebSocket manager that resides on top of a cluster of datastore i.e. Redis.
Why is WebSocket preferred over HTTP(S) protocol for client-server communication?
Send/receive messages
The WebSocket manager is responsible for maintaining a mapping between an active user and a port assigned to the user. Whenever a user is connected to another WebSocket server, this information will be updated in the ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy