System Design ( Day - 29 )

Manoj KumarManoj Kumar
3 min read

System Design of Youtube

Requirements
1. Authentication
2. Upload Videos
3. Subscribe to other channels and get their feeds
4. Watch any Videos
5. LiveStreaming
6. Search
7. Recommendation

Non Functional Requirements
1. High Availability
2. Low Latency
3. Reliable

Capacity Estimation
Currently there is 1.5 Billion daily active users, on an average each user watches 10 videos per day that means 15 billion video watch per Day, The upload ratio would be 1 : 100 that means daily 15 million videos would be uploaded. each video would be around 1 gb in size.

Uploading a Video
This may require a authentication of the user, Title of the Video, description and actual video etc…
Whenever there is a Upload request from the user, the user needs to pass the above things, first it will goes from the authenticator through the load Balancer, to a Upload service, and we’ll validate the video and then pass it to the Splitter service to split that video into chunks, through the splitter service and we’ll send that chunks to for processing Queue that would be kafka or RabitMQ it could be anything, after that it goes to encoding and we can store that encoded video which is in different formats and resolution in the Database and file storage.
For storing the video, meta data and the user details, for user details we could go for Sql and for meta data which contains likes comments and thumbnails, and the video url, and comments also, for that we could go for the NoSql Db, and for storing the Videos we could go for S3 or GCS, after storing the video into that we can have the url for that video, i which it could be stored in the user details and in meta data also.

Watching a video or Livestream.
for watching we are going to have a watch service which uses TCP protocol to deliver the video to the user, we can use UDP also, but while using UDP the quality of the video will get decreased like audio and video are not in sync with each other, because the UPD is not a reliable protocol of the files but TCP is a reliable file transfer protocol to use it, it could be a recorded video or the liveStream, we can use TCP like HTTP to transfer the Video chunks to the user. each chunks would load 4-5 seconds video through the CDN, and through the Adaptive Bitrate Streaming it will send the users bandwidth according to that the video resolution will be sent, like if the use has more bandwidth then the 1080p video chunk will be loaded, if slightly lower then high which is high 720p video chunk will be loaded, if its less than medium then 480p or 360p video chunk will be loaded, if the bandwidth is low then 144p video chunk will be loaded.

0
Subscribe to my newsletter

Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manoj Kumar
Manoj Kumar