Posts

Showing posts with the label Facebook messenger system design

Designing Facebook Messenger

Image
  Functional Req One to one or groups chatting Receipts / Statuses Online/Offline Sent Delivered Read Multimedia Sharing Security Capacity Estimation  500M daily active users, average each user sends 40 messages daily = 20B daily messages Storage :  A message ~100 bytes * 20B = 2TB/day.  in 5 years : 2TB * 365 days * 5  year = 3.6PB We need to scale.  Bandwidth : 2TB everyday data per second : 2 TB /  86400 sec ~= 25 MB/s High throughput we can scale. High-Level System Design Logic Flow Heartbeating   UserA goes to load balancer.  LB will pick one the host behind based on load average or number of connections.  LB picks N1 - App server. Web socket connections bi-directional nature both server and the client can initiate a request.  At this point, while the UserA is not sending any data. They are just heart beating between them.  Why do we need to constantly heartbeat? Because the server knows that User A is still there and als...