Video coming soon. Start with the reading below.
Figure 14-4 shows the high-level design for the video uploading.

It consists of the following components:
- User: A user watches YouTube on devices such as a computer, mobile phone, or smart TV.
- Load balancer: A load balancer evenly distributes requests among API servers.
- API servers: All user requests go through API servers except video streaming.
- Metadata DB: Video metadata are stored in Metadata DB. It is sharded and replicated to meet performance and high availability requirements.
- Metadata cache: For better performance, video metadata and user objects are cached.
- Original storage: A blob storage system is used to store original videos. A quotation in Wikipedia regarding blob storage shows that: “A Binary Large Object (BLOB) is a collection of binary data stored as a single entity in a database management system” [6].
- Transcoding servers: Video transcoding is also called video encoding. It is the process of converting a video format to other formats (MPEG, HLS, etc), which provide the best video streams possible for different devices and bandwidth capabilities.
- Transcoded storage: It is a blob storage that stores transcoded video files.
- CDN: Videos are cached in CDN. When you click the play button, a video is streamed from the CDN.
- Completion queue: It is a message queue that stores information about video transcoding completion events.
- Completion handler: This consists of a list of workers that pull event data from the completion queue and update metadata cache and database.
Now that we understand each component individually, let us examine how the video uploading flow works. The flow is broken down into two processes running in parallel.
a. Upload the actual video. b. Update video metadata. Metadata contains information about video URL, size, resolution, format, user info, etc.
Flow a: upload the actual video

Figure 14-5 shows how to upload the actual video. The explanation is shown below:
- Videos are uploaded to the original storage.
- Transcoding servers fetch videos from the original storage and start transcoding.
- Once transcoding is complete, the following two steps are executed in parallel: 3a. Transcoded videos are sent to transcoded storage. 3b. Transcoding completion events are queued in the completion queue. 3a.1. Transcoded videos are distributed to CDN. 3b.1. Completion handler contains a bunch of workers that continuously pull event data from the queue.
3b.1.a. and 3b.1.b. Completion handler updates the metadata database and cache when video transcoding is complete. 4. API servers inform the client that the video is successfully uploaded and is ready for streaming.
Flow b: update the metadata While a file is being uploaded to the original storage, the client in parallel sends a request to update the video metadata as shown in Figure 14-6. The request contains video metadata, including file name, size, format, etc. API servers update the metadata cache and database.
