High-Level Design (HLD) of WhatsApp
Introduction to High-Level System Design
System Design Fundamentals
- Functional vs. Non-Functional Requirements
- Scalability, Availability, and Reliability
- Latency and Throughput Considerations
- Load Balancing Strategies
Architectural Patterns
- Monolithic vs. Microservices Architecture
- Layered Architecture
- Event-Driven Architecture
- Serverless Architecture
- Model-View-Controller (MVC) Pattern
- CQRS (Command Query Responsibility Segregation)
Scaling Strategies
- Vertical Scaling vs. Horizontal Scaling
- Sharding and Partitioning
- Data Replication and Consistency Models
- Load Balancing Strategies
- CDN and Edge Computing
Database Design in HLD
- SQL vs. NoSQL Databases
- CAP Theorem and its Impact on System Design
- Database Indexing and Query Optimization
- Database Sharding and Partitioning
- Replication Strategies
API Design and Communication
Caching Strategies
- Types of Caching
- Cache Invalidation Strategies
- Redis vs. Memcached
- Cache-Aside, Write-Through, and Write-Behind Strategies
Message Queues and Event-Driven Systems
- Kafka vs. RabbitMQ vs. SQS
- Pub-Sub vs. Point-to-Point Messaging
- Handling Asynchronous Workloads
- Eventual Consistency in Distributed Systems
Security in System Design
Observability and Monitoring
- Logging Strategies (ELK Stack, Prometheus, Grafana)
- API Security Best Practices
- Secure Data Storage and Access Control
- DDoS Protection and Rate Limiting
Real-World System Design Case Studies
- Distributed locking (Locking and its Types)
- Memory leaks and Out of memory issues
- HLD of YouTube
- HLD of WhatsApp
1. About the System
WhatsApp is a global messaging platform that facilitates real-time communication through text, images, videos, voice notes, and calls. It is designed to be:
- Highly Scalable: Supports billions of users.
- Real-Time: Messages delivered instantly.
- Highly Available: Minimal downtime.
- Secure: End-to-end encryption ensures privacy.

2. Requirements & Goals
Functional Requirements
- User Management: Signup, login, profile updates, and contact management.
- Messaging: Send/receive text, images, videos, and files.
- Real-time Communication: Implemented using WebSockets.
- Group Chats: Users can create and participate in group conversations.
- Voice/Video Calls: Supports one-on-one and group calls.
- Status Updates: Users can post text, images, and videos.
- Notifications: Push and in-app notifications.
- Security: End-to-end encryption for messages and calls.

Non-Functional Requirements
- Scalability: Supports billions of messages daily.
- Low Latency: Instant message delivery.
- High Availability: 24/7 uptime.
- Data Consistency: Message ordering must be maintained.
- Efficient Storage: Optimized storage for messages and media.

3. Capacity Estimations and Constraints
Assumptions
- Daily Active Users (DAU): 50 million
- Messages per User per Day: 20
- Total Messages per Day: 50M × 20 = 1B
- Media Messages: 5% of total messages (50M)
- Average Message Size: 100 bytes for text, 100 KB for media
- Storage Needs:
- Text: 950M × 100B = ~95GB/day
- Media: 50M × 100KB = ~5TB/day
- Total Storage per Day: ~5.1TB
- 5-Year Projection: ~9.3PB
- Bandwidth: ~120 MB/sec
- Requests per Second (RPS): ~24K

4. System APIs
Authentication
- POST /api/login: Authenticate user and return session token.
- POST /api/logout: Logout user.
Messaging
- POST /api/messages: Send a message.
- GET /api/messages: Retrieve messages for a user.
Group Chats
- POST /api/groups: Create a group.
- POST /api/groups/add: Add user to a group.
- POST /api/groups/messages: Send a group message.
Voice/Video Calls
- POST /api/calls/start: Start a call.
- POST /api/calls/end: End a call.
Status Updates
- POST /api/status: Post status update.
- GET /api/status: Retrieve status updates.
Notifications
- POST /api/notifications: Send push notifications.

5. Data Model Design
Tables
- Users: Stores user information.
- Messages: Stores messages with type, content, and timestamps.
- Chats: Represents private chats between users.
- Users_Chats: Maps users and chats (N:M relationship).
- Groups: Stores group details.
- Users_Groups: Maps users and groups (N:M relationship).
Database Choice
- Relational Databases (PostgreSQL): For structured data (users, chats, groups).
- NoSQL (Cassandra, DynamoDB): For messages to ensure scalability.

6. API Design
Get All Chats or Groups
getAll(userID: UUID): Chat[] | Group[]
Get Messages
getMessages(userID: UUID, channelID: UUID): Message[]
Send Message
sendMessage(userID: UUID, channelID: UUID, message: Message): boolean
Join/Leave Group
joinGroup(userID: UUID, channelID: UUID): boolean
leaveGroup(userID: UUID, channelID: UUID): boolean

7. High-Level Architecture
Microservices-Based Architecture
Core Services:
- User Service: Manages user authentication and profile information.
- Chat Service: Handles real-time messaging via WebSockets.
- Notification Service: Sends push notifications.
- Presence Service: Tracks online status.
- Media Service: Handles media uploads and storage.
Inter-Service Communication
- REST API & gRPC for synchronous calls.
- Message Queue (Kafka/RabbitMQ) for asynchronous processing.

8. Scaling and Optimization Strategies
Horizontal Scaling
- Load Balancers (NGINX, HAProxy) distribute traffic.
- Multiple database shards to handle storage efficiently.
Caching
- Redis/Memcached for frequently accessed data (user profiles, messages).
Data Storage Strategy
- Cold Storage: Older messages archived to reduce database load.
- CDN: Distributes media content for reduced latency.

9. Security Considerations
- End-to-End Encryption (E2EE): Ensures message confidentiality.
- OAuth & Token-Based Authentication: Secures API access.
- Rate Limiting & Throttling: Prevents spam attacks.

10. Conclusion
This HLD provides a structured approach to designing WhatsApp’s architecture, ensuring scalability, high availability, and robust security measures.

DSA, High & Low Level System Designs
- 85+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 400+ DSA Practice Questions
- Comprehensive Notes
- HackerRank Tests & Quizzes
- Topic-wise Quizzes
- Case Studies
- Access to Global Peer Community
Buy for 60% OFF
₹25,000.00 ₹9,999.00
Accelerate your Path to a Product based Career
Boost your career or get hired at top product-based companies by joining our expertly crafted courses. Gain practical skills and real-world knowledge to help you succeed.

Essentials of Machine Learning and Artificial Intelligence
- 65+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 22+ Hands-on Live Projects & Deployments
- Comprehensive Notes
- Topic-wise Quizzes
- Case Studies
- Access to Global Peer Community
- Interview Prep Material
Buy for 65% OFF
₹20,000.00 ₹6,999.00

Fast-Track to Full Spectrum Software Engineering
- 120+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 400+ DSA Practice Questions
- Comprehensive Notes
- HackerRank Tests & Quizzes
- 12+ live Projects & Deployments
- Case Studies
- Access to Global Peer Community
Buy for 57% OFF
₹35,000.00 ₹14,999.00

DSA, High & Low Level System Designs
- 85+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 400+ DSA Practice Questions
- Comprehensive Notes
- HackerRank Tests & Quizzes
- Topic-wise Quizzes
- Case Studies
- Access to Global Peer Community
Buy for 60% OFF
₹25,000.00 ₹9,999.00

Low & High Level System Design
- 20+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 400+ DSA Practice Questions
- Comprehensive Notes
- HackerRank Tests
- Topic-wise Quizzes
- Access to Global Peer Community
- Interview Prep Material
Buy for 65% OFF
₹20,000.00 ₹6,999.00

Mastering Mern Stack (WEB DEVELOPMENT)
- 65+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 12+ Hands-on Live Projects & Deployments
- Comprehensive Notes & Quizzes
- Real-world Tools & Technologies
- Access to Global Peer Community
- Interview Prep Material
- Placement Assistance
Buy for 60% OFF
₹15,000.00 ₹5,999.00

Mastering Data Structures & Algorithms
- 65+ Live Classes & Recordings
- 24*7 Live Doubt Support
- 400+ DSA Practice Questions
- Comprehensive Notes
- HackerRank Tests
- Access to Global Peer Community
- Topic-wise Quizzes
- Interview Prep Material
Buy for 50% OFF
₹9,999.00 ₹4,999.00
Reach Out Now
If you have any queries, please fill out this form. We will surely reach out to you.
Contact Email
Reach us at the following email address.
arun@getsdeready.com
Phone Number
You can reach us by phone as well.
+91-97737 28034
Our Location
Rohini, Sector-3, Delhi-110085