How would you design WhatsApp ?

Design WhatsApp

Features to be included:

  1. One to One chat
  2. Group Chat
  3. Delivered and read status
  4. Push notifications

I tried to come up with a basic design but would like hear some more thoughts and understand how whatsapp actually works.

Here is my initial analysis:
Client Server architecture is preferrable than peer-to-peer for a messaging system.
For a simpler understanding consider two users: Mike and Rachel.
When Mike sends a message("Hi") to Rachel, the message is sent to the Whatsapp server.
Once message is received by the server it is pushed in a dedicated queue for Rachel. (To uniquely identify the queue, it can be created with the ID as mobile number)
Queue acts as a buffer storage to hold the data in case the targeted user is offline.
If Rachel is online(connected to the internet), Rachel's whatsapp client reads the messages from the respective queue.
If Rachel is offline the message stays in the queue.

Expected questions on this initial design:

  • Is creating queue for each user scalable ?
    The number of users in Whatsapp is more than 1.5 Billion, so there would be overhead to manage these >1.5B queues and plus the cost.
  • When will these queues be created? At account creation time or they will be created dynamically when message arrives for that user ?
  • How will you manage ever growing queue size ?
Comments (13)