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 abstract design workflow is as follows:
The user uploads a video to the server.
The server saves metadata and user data to the database and simultaneously sends the video to the encoder.
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).
Popular videos are forwarded to the CDN for caching.
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.
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?
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
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 |
| This is the user that is uploading the video. |
| This is the video file that the user wants to upload. |
| This refers to the category a video belongs to. Typical categories can be “Entertainment,” “Engineering,” “Science,” and so on. |
| This is the title of the video. |
| This is the description of the video. |
| This refers to the specific topics the content of the video covers. The |
| This is the default language a page will show to the user when the video is streamed. |
| 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)