"Ever wondered how your WhatsApp messages reach instantly, no matter where you are? Scaling chat systems ensures every message gets through, even with millions of users. Let’s explore the tech behind our seamless chats!"
What is Whatsapp?
WhatsApp is a messaging app that allows text, voice, and video calls, along with media and document sharing. It offers end-to-end encryption for privacy and supports group chats and status updates. Users can also share locations and use WhatsApp on the web.
Let’s look at there few features and try to learn them
Send Messages: Users should be able to send text, voice, image, and video messages to individuals and groups.
Read Messages: The system must mark messages as "read" when the recipient views them.
Receive Messages: Users must receive incoming messages in real-time with notifications.
Last Active Status: The app should display the last active status of a user (e.g., "Last seen" or "online").
Group Messaging: Users should be able to create and manage groups, send messages to multiple participants, and share media within group chats.
- Sending Messages
User sends message
message is been sent using websockets(TCP)
interaction with server is realtime
if the user is active then the message get’s delivered
if the user is not active then the messages are stored in the ready queues
once the user gets online it reaches them
Received Messages
there are multiple users
we have gateways where each of the users are checked and they let them pass
then we have a session microservice which stores the real time location and gateway the other user is connected too with the help of this its easier to find the next user and sending message possible
Activity status
-
We can check with the last seen microservice for the activity status
- Sent, Read, Delivered
Due web sockets which are full-duplex connections, meaning they allow data to be sent and received simulataneously in both directions. This enables real-time, bidiretional communication between client and the server without the need for continous requests like the other protocols, HTTP, pollings and other stuffs
web sockets can be used for P2P peer to peer communications but its not a P2P they are typically client server connections which are real time and full-duplex
Group Messaging
Celebrity Problem
Notifications Problem
Non-Functional Requirements
Scalability
Availability
Eventually consistency
Security and Privacy
Encryption & Decryption
Capacity Estimation
1B DAU (Daily Active User)
2B-3B DMU (Daily Monthly User)
100B Number of messages are sent on a daily basis