Introduction
We can do a lot more on YouTube than watching a video. So, we must narrow down the scope.
...
5 million daily active users (DAU)
5 videos per day.
10% of users upload 1 video per day.
Average video size = 300 MB.
Total daily storage = 5 million * 10% * 300 MB = 150 TB.
CDN cost :
CDN serves video, we are charges charged for data transferred out of CDN.
Average cost per GB is 0.02$ for USA.
5 million * 5 videos * 0.03GB * 0.02$ = $150000 per day.
Step 2 - High-level design
...
System Optimization
Speed Optimization
→ Parallelize video uploading from client
...
→ Parallelize video encoding : Introduction of Message Queue
...
Safety Optimization (Pre-signed upload URL & protect videos)
...
Scale the API tier : because API servers are stateless, it’s easy to scale horizontally.
Scale the DB : DB replications and Sharding.
Live streaming : requires uploading, encoding & streaming.
Videos takedowns : videos that violate copyrights,… shall be removes.