Posts

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...

NETFLIX HIGH-LEVEL SYSTEM DESIGN

Image
  STEP - 1 Functional Req   User Registration + login + profiles Search Recommendations Activity tracking Recommendation generation Dashboard Payment Content Ingestion and Delivery Rights + Licences Categorization Notifications Trend Movies Watch History Endorsement Design Constraints Number of users: 100 million Daily active user: %10 Content Upload / sec: Minimal Content Streamed / sec: Need scaling  How many videos let’s say 20000 Averaga per video 10 GB : 3gb HD + 1gb sd = 4 gb.  Avg per video 2,5 hours = 10 GB Content Size: the average size of the video data User activity tracking: High Content streaming latency STEP - 2  Define Microservices We can bucketize functional requirements into Microservices.   The system is a huge system so should be a lot of teams to handle these requirements.  Multiple Microservices - Breadth Oriented System. High Priority Microservices  Microservices  Technology Type User activity tracking MS Simple ti...