System Design
Real-Time Chat Service - WhatsApp
Real-Time Chat Service - WhatsApp
Design a real-time chat service similar to WhatsApp that allows users to communicate with each other in real-time using text messages, voice messages, images, videos, and document files. The system should be able to handle a large number of users and be able to scale as the number of users grows.
Example:
Suppose we need to build a real-time chat service like WhatsApp for a messaging app with 50 million users. Users should be able to send messages to each other in real-time, and the messages should be end-to-end encrypted to ensure user privacy.
Functional Requirements:
- Users should be able to send text messages to other users in real-time.
- Users should be able to send and receive voice messages in real-time.
- Users should be able to send and receive images and videos.
- Users should be able to send and receive document files (such as PDFs and Word documents).
- Users should be able to make voice and video calls.
- Users should be able to create and participate in group chats.
- Users should be able to see when other users are typing a message.
- Users should be able to receive instant notifications when a new message arrives.
- Users should be able to see a list of active chats and switch between them.
- The system should use end-to-end encryption to ensure user privacy.
- The system should be able to handle a large number of users.
Non-functional Requirements:
- The system should be able to handle a large number of concurrent users.
- The system should be able to scale horizontally to handle larger volumes of users.
- The system should be fault-tolerant and able to recover from errors.
- The system should be able to run continuously with minimum downtime.
- The system should be able to handle a high volume of messages without impacting performance.
- The system should be able to deliver messages in real-time, with minimal latency.
Assumptions:
- The system assumes that users are authenticated and authorized to use the service.
- The system assumes that messages are not confidential and can be stored in a database for analysis and auditing.
- The system assumes that users are not sending malicious messages or files.
Estimated Usage:
- The system should be able to handle at least 1 million concurrent users.
- The system should be able to handle at least 100,000 messages per second.