Search⌘ K
AI Features

Design of YouTube

Define the high-level and detailed System Design for YouTube, outlining the data flow from video ingestion to content delivery via CDNs. Explore the necessary REST API design and component integration, including specialized storage solutions like Bigtable for massive scalability.

High-level design

The high-level design connects the components identified in the previous lesson. This solution supports the defined functional and non-functional requirements.

The high-level design of YouTube
The high-level design of YouTube

The abstract design workflow is as follows:

  1. The user uploads a video to the server.

  2. The server saves metadata and user data to the database and simultaneously sends the video to the encoder.

  3. The encoder and transcoder compress the video and generate multiple resolutions (e.g., 2160p, 1440p, 1080p). Resulting files are stored in blob storage (similar to GFS or S3).

  4. Popular videos are forwarded to the CDN for caching.

  5. The CDN serves the video to the user with low latency. However, CDN is not the only infrastructure for serving videos to the end user, which we will see in the detailed design.

1.

Why don’t we upload the video directly to the encoder instead of to the server? Doesn’t the current strategy introduce an additional delay?

Show Answer
Did you find this helpful?

API design

We will use REST APIs to expose the system’s functionality. The client interacts with the backend through the following endpoints:

  • Upload videos

  • Stream videos

  • Search videos

  • View thumbnails

  • Like or dislike videos

  • Comment on videos

API design overview
API design overview

Upload video

Use the POST method to upload a video via the /uploadVideo API:

uploadVideo(user_id, video_file, category_id, title, description, tags, default_language, privacy_settings)

The parameters are described below:

Parameter

Description

user_id

This is the user that is uploading the video.

video_file

This is the video file that the user wants to upload.

category_id

This refers to the category a video belongs to. Typical categories can be “Entertainment,” “Engineering,” “Science,” and so on.

title

This is the title of the video.

description

This is the description of the video.

tags

This refers to the specific topics the content of the video covers. The tags can improve search results.

default_language

This is the default language a page will show to the user when the video is streamed.

privacy_settings

This refers to the privacy of the video. Generally, videos can be a public asset or private to the uploader.

...