AlgoMaster Logo

Design YouTube

Ashish

Ashish Pratap Singh

15 min read

In this chapter, we’ll explore the system design of a large-scale video streaming service like YouTube that can accommodate hundreds of millions of daily users and billions of views, all while maintaining low latency and high availability.

Let’s start by clarifying the requirements.

1. Requirements Gathering

Before diving into the design, lets outline the functional and non-functional requirements.

Functional Requirements

  • Users should be able to upload video files.
  • Uploaded videos must be transcoded into multiple resolutions (e.g., 240p, 360p, 720p, 1080p) to support different network conditions and devices.
  • Users should be able to stream videos in real-time with adaptive bitrate streaming to adjust quality based on network conditions.
  • Users can search for videos by title, tags, or description.
  • Users can like and comment on videos.
  • Users should be able to create and subscribe to channels.

Non-Functional Requirements:

  1. Scalability: The system should support millions of concurrent users and thousands of video uploads per minute.
  2. High Availability: Core features like video upload, playback, and search should have minimal downtime.
  3. Low Latency: Fast video streaming with minimal buffering and near-instantaneous search results.
  4. Durability: Video files must be stored reliably, with redundancy mechanisms to prevent data loss due to hardware failures.
  5. Cost Efficiency: Optimize storage and bandwidth costs.

2. Capacity Estimation

Storage Estimation:

  • Daily Storage for Videos: 100,000 videos / day * 500 MB / video = 50 TB / day
  • Daily Video Metadata Storage: 100,000 * 1KB = 100MB / day

Network Bandwidth Estimation:

  • Daily Video Consumption: 10 million users × 5 videos/user = 50 million views/day
  • Daily Bandwidth Requirements (without compression & caching) : 50 million views * 500 MB / day = 25 PB / day

Given the high storage and bandwidth requirements, leveraging cloud-based services is the most practical approach:

  1. Content Delivery Network (CDN): To cache frequently accessed videos closer to users and reduce latency.
  2. Blob Storage (e.g., AWS S3): To store video files reliably with redundancy.

3. High Level Architecture

Premium Content

This content is for premium members only.