Whatsapp

Interview Question: Design Messaging service like Whatsapp


Whatsapp messenger or Facebook messenger uses the internet to send messages, images, audio, or video. WhatsApp will never store any messages or other data related to users except for the User’s name and number for accessibility.

Only there is one point of contact with the WhatsApp server when the message is being delivered and once delivered, the data from the server is deleted. However, their servers do store your messages for 30 days if they are undelivered. Beyond this time undelivered messages will be deleted.

If the recipient is online, the message will go to them via WhatsApp servers but not stored in any WhatsApp database servers. All the messages are stored in the phone’s memory, but they are also stored in Google Drive with the user’s permission for backup.

WhatsApp ensures end-to-end encryption hence only the recipient and the sender have access to the messages.

Step 1: Use Case Discussion


  • Interviewee: What would be the scale of the WhatsApp messaging system? How many daily active users are supposed to be supported?
  • Interviewer: Let's design it for WhatsApp daily user count as of 2020 i.e 500M daily active users. Assume each person sends 30 messages per day.

  • Interviewee: Do we support both 1:1 conversations and group conversions?
  • Interviewer: Yes, let's design for both 1:1 conversations and group conversations.

  • Interviewee: Do we support images and videos in the texts?
  • Interviewer: Yes.

  • Interviewee: What would be the average size of messages?
  • Interviewer: Make your own assumptions.

  • Interviewee: Whatsapp does not support the permanent storage of message data. Should we consider the same feature?
  • Interviewer: Yes. Currently, let’s not support permanent storage. If the message is delivered it must not be stored in our database. If time permits we shall discuss the same.

  • Interviewer: Whatsapp supports end-to-end encryption of messages. Should we also include encryption of messages?
  • Interviewer: Yes.

  • Interviewee: Should we support features like last seen, the message delivered tick, and read blue ticks?
  • Interviewer: Yes.

From the above conversation we note down the required features as follows:

  • Daily active users: 500 M.
  • Messages per day each person: 30 msgs per day.
  • Text messages don't have much data size, so the size of messages can be in kb. But if sharing HD photos is available, then its size may be more than 1 MB. On average let’s assume 50kb of message size.
  • The system must support both one-to-one conversations and group conversations.
  • Media content like images and videos should also be supported.
  • Permanent storage of messages is not supported.
  • End to end encryption of messages.
  • Support sent, delivered and read ticks features.