YouTube API Design Decisions

Learn about the technical considerations that direct the design of the YouTube API.

The API design for a streaming service is an intricate operation due to the complex nature of the system. It involves significant technical aspects—for example, the API architecture style to use between different interacting entities and the protocols adopted for transferring streaming data. In the following section, we’ll decide on the primary design considerations that we’ll stick to in designing an API for the YouTube streaming service.

Design overview

The following illustrations show a bird's eye view of YouTube's primary services, which consist of streaming, uploading, searching, commenting, and rating (liking or disliking) services. The upload service is used to upload the video contents to the blob storage and relevant metadata to the metadata database. The search service efficiently finds relevant videos from the vast database of videos. Similarly, the comment service enables users to post comments on a video, and these can be rated via the rating service.

Press + to interact
The various functionalities of the YouTube system
The various functionalities of the YouTube system

Since we have covered the other services in our foundational design problems, we’ll focus on streaming services, and other services relevant to streaming, in the figure below. All streaming requests coming from the clients are passed via the API gateway and directed to the relevant service, which, in turn, retrieves the relevant data from the persistent layer. For example, the ad service is responsible for handling any requests related to embedding ads in videos. Typical responsibilities of this service include communicating with other services to find optimal ads to serve specific users, choosing the number of ads to be served, and serving ads during playback.

Press + to interact
The YouTube streaming system
The YouTube streaming system

The following table describes some of the essential components that are involved in the design of a streaming system.

Components and Services Details

Component or Service

Details

Streaming service

  • Provides video streaming service
  • Provides videos in a multi-protocol format based on the client's devices and requirements


Advertisements service

  • Updates the manifest file to decide which advertisement is suitable to be played against a video
  • Decides the interval and number of advertisements to be shown to a user
  • Directs the advertisement requests to the respective servers

Encoding service

  • Performs encoding, transcoding, and segmentation of videos after upload

User data service

  • Provides user data to other services to improve user experience


API gateway

  • Fanout requests to the appropriate services
  • Performs the identity and access management (IAM) operations
  • Throttles requests and caches frequent API responses

Databases

  • Stores users’ data, video metadata, and so on

Blob storage

  • Stores audios and videos, preferably in segments/chunks

Point to Ponder

1.

Is the manifest file generated statically during video processing or dynamically depending on the requests of individual users?

Show Answer
Q1 / Q1
Did you find this helpful?
...