Search⌘ K
AI Features

Design WhatsApp -15 Minute Sprint

Explore the design of WhatsApp by analyzing its functional and non-functional requirements. Understand how components like WebSocket servers, message services, and media handling work together. Learn how this system handles consistency, availability, latency, security, and scalability while managing billions of messages daily, preparing you for advanced system design interviews.

Overview

In today’s technological world, WhatsApp is an important messaging application that connects billions of people around the globe. Many users start their day by reading or sending WhatsApp messages to their friends and family. According to July 2021 estimates, WhatsApp has two billion active users worldwide. Furthermore, an average WhatsApp user spends approximately 19.4 hours per month on the application.

In December 2020, the WhatsApp CEO tweeted that WhatsApp users share more than 100 billion messages per day, an increase of approximately 54% since 2018. The increase in messages sent globally per day is depicted in the following chart:

Number of WhatsApp messages sent per day

Requirements

Our design of the WhatsApp messenger should meet the following requirements.

Functional requirements

  • Conversation: The system should support one-on-one and group conversations between users.

  • Acknowledgment: The system should support message delivery acknowledgment, such as sent, delivered, and read.

  • Sharing: The system should support sharing media files like images, videos, and audio.

  • Chat storage: The system must support the persistent storage of chat messages when a user is offline until the successful delivery of messages.

  • Push notifications: The system should be able to notify offline users of new messages once their status becomes online.

Non-functional requirements

  • Low latency: Users should be able to receive messages with low latency.

  • Consistency: Messages should be delivered in the order they were sent. Moreover, users must see the same chat history on all of their devices.

  • Availability: The system should be highly available. However, the availability can be compromised in the interest of consistency.

  • Security: The system must be secure via end-to-end encryption. End-to-end encryption ensures that only the two communicating parties can see the content of messages. Nobody in between, not even WhatsApp, should have access.

  • Scalability: The system should be highly scalable to support an ever-increasing number of users and messages per day.

The non-functional requirements of the WhatsApp system
The non-functional requirements of the WhatsApp system

Building blocks we will use

The design of WhatsApp utilizes the following building blocks:

The building blocks required to design WhatsApp
The building blocks required to design WhatsApp
  • Databases are required to store users’ and groups’ metadata.
  • Blob storage is used to store multimedia content shared in messages.
  • A CDN is used to effectively deliver multimedia content that’s frequently shared.
  • A load balancer distributes incoming requests among the pool of available servers.
  • Caches are required to keep frequently accessed data used by various services.
  • A messaging queue is used to temporarily keep messages in a queue on a database when a user is
...
AI Powered
Saved
Reset
Design WhatsApp system using the building blocks and components discussed above.

Evaluate your abilities in designing WhatsApp. Beyond the mentioned building blocks, additional components contribute to creating a comprehensive design. These include:

  • Message service
  • Group message service
  • Websocket manager
  • Mnesia database
  • Redis cluster

Provide your solution considering the following details:

  • Which entity will process the messages of the two users intending to communicate with each other?
  • How are the group messages handled?
  • Where are the messages stored when a user is offline?
  • Where will the media files be kept for frequent access?
  • What protocol(s) is(are) required to transmit messages with low latency?
  • How will different services be decoupled?
...

At an abstract level, the ...