Coconote
AI notes
AI voice & video notes
Try for free
Designing WhatsApp - Key Points from Lecture
Jul 7, 2024
Designing WhatsApp - Key Points from Lecture
Key Features of WhatsApp
Group messaging
Read receipts (Sent, Delivered, and Read ticks)
Important Features to Discuss in System Design Interviews
Group messaging
: Limited to 200 people per group.
Image/Video sharing
: Commonly required.
Read receipts
: Sent, Delivered, and Read statuses.
Additional Features
Online status
: Indicating if a user is online or last seen time.
Temporary/Permanent chats
: Privacy and storage concerns.
Prior Work on Image Sharing
Reference Tinder video for storing and retrieving images.
Feature Breakdown
1. One-to-One Messaging
Connect to gateway
:
Gateway handles external protocol communication.
Internally uses efficient protocols without extensive headers.
Message Routing
:
TCP connections with minimal state (dumb connections).
Sessions microservice maintains user-to-box mapping.
WebSockets for real-time communication.
Message tracking
:
Sent receipt once message is stored and acknowledged by the server.
Delivery receipt upon actual delivery.
Read receipt upon message being read by the recipient.
Mechanisms used
:
HTTP for message polling (less efficient).
WebSockets preferred for real-time chat.
2. Online Status and Last Seen
Tracking
:
Server maintains last activity timestamp for users.
Differentiates between user activities and app-generated activities.
Service Logic
:
Last Seen microservice updates timestamps based on user activities.
B queries server for A’s last seen status.
Online indication
:
Shows “online” if activity occurred within a recent threshold.
Otherwise shows last seen timestamp.
Key Components and Concepts
Load Balancing
: Ensure efficient distribution of messages.
Service Discovery
: Identifies available microservices.
Heartbeat Mechanism
: Maintains active connection status.
Authentication
: Separate service for validating user identity.
3. Group Messaging
Session Service
:
Stores user-to-connection mapping.
Group Service
:
Manages group membership details.
Session service queries group service to get user details.
Message Routing
:
Limits group size to reduce system load (e.g., 200 users).
Uses consistent hashing for efficient routing.
Reducing Gateway Load
:
Offloading parsing tasks to a dedicated parser microservice.
Ensuring Delivery
:
Message queuing for retries.
Immediate acknowledgment for message receipt.
Optimization in High Load
:
Deprioritizing non-essential features (e.g., last seen, delivery receipts) during high load times.
Performance Tips and Techniques
Graceful degradation
: Prioritize important messages under heavy load.
Consistent Hashing
: Efficiently distributes data across servers.
Message Queuing
: Ensures reliable message delivery even on retries.
WebSockets
: Necessary for real-time communication.
Recap
Focused on four key features: One-to-One messaging, Read receipts, Online status, and Group messaging.
Emphasized scalability, efficiency, and real-time performance.
Conclusion
This architecture ensures a resilient, efficient, and scalable chat application.
Future topics: Load balancing, service discovery, heartbeat maintenance, and authentication.
Thank you for watching!
📄
Full transcript