Scaling Whatsapp đŸ«›

Scaling Whatsapp đŸ«›

·

3 min read

"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.

  1. 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

  1. 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

  2. Activity status

  • We can check with the last seen microservice for the activity status

  1. 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
sharding, batch processing, caching
Notifications Problem
Implement WebSockets for real-time communication, ensuring low latency. Use push notifications for mobile devices. Store notifications in a queue (e.g., Kafka) to handle high throughput and guarantee delivery.

Non-Functional Requirements

  1. Scalability

  2. Availability

  3. Eventually consistency

  4. Security and Privacy

  5. Encryption & Decryption


Capacity Estimation

  1. 1B DAU (Daily Active User)

  2. 2B-3B DMU (Daily Monthly User)

  3. 100B Number of messages are sent on a daily basis


Did you find this article valuable?

Support Thirumalai by becoming a sponsor. Any amount is appreciated!

Â