Search⌘ K
AI Features

Design of YouTube

The high-level design of YouTube encompasses a workflow where users upload videos, which are then processed by encoders and stored in blob storage. The system utilizes REST APIs for functionalities like video uploads, streaming, and searching. A detailed design addresses challenges such as component integration, thumbnail generation, and database structure, ensuring scalability and low latency. Key components include load balancers, web servers, application servers, and specialized storage solutions like Bigtable for metadata. Additionally, a robust search engine processes video data to enhance user experience through relevant results and conversational discovery features.

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

  • Ask about 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.

Stream video

Use the GET method for the /streamVideo ...

streamVideo(user_id, video_id, screen_resolution, user_bitrate, device_chipset)
...