Messenger App System Design
Table of content:
- Functional Requirements
 - Non Functional Requirements
 - Capacity Estimation
 - High Level System Design
 - Algorithms
 
Messaging applications such as WhatsApp/Facebook Messengers provide instant messaging services to users.
Functional Requirements
- System should be able to support one-to-one/group messaging
 - Users should be able to see live status
 - System should support file sharing(on receive deletion)
 
Non-Functional Requirements
- System should highly reliable/scalable
 - System should be highly available with eventual consistency
 
Capacity Estimation
Throughput
- DAU : 50M users and each user watch 10 messages/day
 - 500 million messages/day -> 5000 RPS
 - 10% of users upload files-> 50 million files/day
 
Storage
- 50 M X100 = 5GB/day
 
High Level System Design
 
	- User send messages to user/group which is handled by chat server
 - Chat server extracts files (if any) upload into media storage.
 - Event triggered message queue and notification send to user/group via notification server
 - Presence server uses heartbeat protocol to check whether user active/not
 - Communication between chatServer and user happens through WebSocket(Duplex)/ SSE/Long Polling
 
Algorithms
- WebSockets
 - Server Sent Events
 - Long Polling
 - HeartBeat Protocols