Design YouTube: video upload and streaming

Learn how to design a highly scalable video streaming platform like YouTube, focusing on resumable uploads, distributed transcoding pipelines, and Adaptive Bitrate Streaming (ABR).

intermediate11 min readBy CureBugs EditorialUpdated 5 Nov 2026

Designing a video sharing platform like YouTube is one of the most comprehensive system design interview questions you can face. It forces you to think about massive data storage, heavy asynchronous background processing, and low-latency global content delivery. In this article, we will focus on the core pillars of YouTube: how a user uploads a video, how the system processes it, and how millions of users can stream it smoothly without buffering, regardless of their network connection.

Requirements (functional and non-functional)

Before jumping into architecture, we must define the scope. YouTube is a massive ecosystem including recommendations, comments, live streaming, and ads. For a standard 45-minute interview, we must narrow this down.

Functional Requirements

  • Upload Video: Users can upload videos (often large files, up to several gigabytes).
  • View Video: Users can stream videos smoothly across different devices (mobile, web, TV) and network conditions.
  • Search/Discover: Users can view video metadata (title, description, thumbnails, view counts).
  • Adaptive Streaming: The video quality should automatically adjust based on the user's internet bandwidth.

Non-functional Requirements

  • High Availability: The streaming service must be highly available. Users should always be able to watch videos.
  • High Reliability (No data loss): Uploaded videos must never be lost.
  • Low Latency Streaming: Video playback should start quickly with minimal buffering.
  • Scalability: The system must handle millions of concurrent users and massive amounts of storage.

Capacity estimates

Let's do some back-of-the-envelope math to understand the scale. We will assume a scale similar to a major regional player or a growing global platform, rather than YouTube's actual current 2+ billion DAU, to keep the math grounded but challenging.

Assumptions:

  • Daily Active Users (DAU): 100 Million.
  • Viewing habits: On average, a user watches 5 videos per day.
  • Read/Write Ratio: For every 1 video uploaded, there are 1,000 views.
  • Video Size: The average uploaded video is 5 minutes long and takes up 50 MB in its raw format.

Traffic Estimates:

  • Views per day: 100M users * 5 videos = 500 Million views/day.
  • Uploads per day: 500M views / 1,000 = 500,000 uploads/day.
  • Upload Bandwidth (Ingress): 500,000 * 50 MB = 25 Terabytes (TB) per day.
    • 25 TB / 86400 seconds = ~290 MB/second ingress.
  • Streaming Bandwidth (Egress): 500 Million * 50 MB = 25 Petabytes (PB) per day.
    • 25 PB / 86400 seconds = ~290 GB/second egress.

Storage Estimates:

  • Raw Storage: 25 TB/day.
  • Transcoded Storage: A single video is transcoded into multiple formats (1080p, 720p, 480p, 360p) and codecs (H.264, VP9). This typically multiplies the storage requirement by 3x to 5x. Let's assume 4x.
  • Total Storage per day: 25 TB * 4 = 100 TB/day.
  • Total Storage per year: 100 TB * 365 = ~36.5 Petabytes/year.

API design

We will expose RESTful endpoints for our clients.

1. Upload Video (Initiate)

Because videos are large, we don't send the file in a single standard POST request. We initiate an upload to get a secure, resumable upload URL (like an S3 Pre-signed URL).

POST /v1/videos/upload-url

  • Request Body: {"title": "My Vacation", "description": "...", "size_bytes": 52428800, "format": "mp4"}
  • Response: {"video_id": "v_12345", "upload_url": "https://storage.aws.com/...?signature=xyz"}

2. Get Video Metadata

GET /v1/videos/{video_id}

  • Response:
    json
    {
      "id": "v_12345",
      "title": "My Vacation",
      "uploader_id": "u_987",
      "views": 1500430,
      "likes": 1200,
      "thumbnail_url": "https://cdn.example.com/thumbs/v_12345.jpg",
      "manifest_url": "https://cdn.example.com/streams/v_12345.m3u8"
    }

3. Stream Video

The client doesn't hit our API servers to stream the video bytes. Instead, the metadata endpoint returns a manifest_url. The client uses this URL to fetch the video chunks directly from the Content Delivery Network (CDN).

Data model

We need to store metadata about users, videos, and the relationship between them.

Given the massive read volume and the relational nature of the data (Users have many Videos), a sharded RDBMS (like MySQL or PostgreSQL) or a distributed NoSQL database (like Cassandra) are both viable. For metadata, we need strong consistency on updates (like changing a title) but can tolerate eventual consistency on view counts. Let's assume a sharded PostgreSQL database.

Table: users

  • user_id (UUID, Primary Key)
  • username (VARCHAR)
  • email (VARCHAR)
  • created_at (TIMESTAMP)

Table: videos

  • video_id (UUID, Primary Key)
  • uploader_id (UUID, Foreign Key -> users)
  • title (VARCHAR)
  • description (TEXT)
  • status (ENUM: 'processing', 'ready', 'failed')
  • raw_storage_path (VARCHAR)
  • manifest_path (VARCHAR)
  • created_at (TIMESTAMP)

Table: video_stats (Separated to handle high-frequency updates)

  • video_id (UUID, Primary Key)
  • view_count (BIGINT)
  • like_count (BIGINT)

Object Storage (S3 / GCS)

  • Raw video files.
  • Transcoded video chunks (.ts or .m4s files).
  • Manifest files (.m3u8 or .mpd).
  • Thumbnails.

High-level architecture

Here is the high-level flow of how the components interact.

The Flow Explained:

  1. Upload: The client requests an upload URL from the API Gateway. The Upload Service generates a pre-signed URL to the Raw Object Storage.
  2. Direct Upload: The client uploads the file directly to Object Storage (e.g., AWS S3). This prevents our API servers from being bottlenecked by heavy network I/O.
  3. Event Trigger: Once the upload is complete, the Object Storage triggers an event to a Message Queue (like Kafka).
  4. Transcoding: Transcoding Workers pick up the job from Kafka, pull the raw video, and process it into multiple resolutions and chunks.
  5. Storage & Metadata: The workers save the processed chunks to the Transcoded Storage and notify the Metadata Service to mark the video as 'ready'.
  6. Streaming: When a user wants to watch, they get the manifest URL from the Metadata Service and stream the chunks directly from the CDN.

Deep dives

Let's explore the three most complex parts of this system: the transcoding pipeline, adaptive bitrate streaming, and CDN caching strategies.

1. Video Transcoding Pipeline (DAG)

Raw videos uploaded by users come in hundreds of different formats (mp4, avi, mov), codecs, and frame rates. They are also massive. We cannot stream raw videos directly. We must transcode them.

Transcoding is highly CPU-intensive. If a worker crashes halfway through a 2-hour video, we don't want to start over. Therefore, we use a Directed Acyclic Graph (DAG) workflow, similar to MapReduce.

  1. Inspection: A worker inspects the raw video to extract metadata (duration, audio tracks, resolution).
  2. Chunking: The video is split into smaller segments (e.g., 10-second chunks).
  3. Parallel Processing: Each chunk is sent as an independent message to Kafka. Hundreds of workers can now process different chunks of the same video simultaneously.
  4. Tasks: For each chunk, workers perform:
    • Audio extraction.
    • Video transcoding to 1080p, 720p, 360p.
    • Watermarking (if necessary).
  5. Merging/Manifest Generation: Once all chunks are processed, a final worker generates the Manifest file (which acts as a map of all the chunks) and updates the database.

By chunking the video, we achieve massive parallelism and fault tolerance. If a worker processing chunk #42 at 720p crashes, only that specific tiny task is retried.

2. Adaptive Bitrate Streaming (ABR)

How does YouTube keep playing even when you drive through a tunnel and your internet drops from 5G to 3G? The answer is Adaptive Bitrate Streaming (ABR), implemented via protocols like HLS (HTTP Live Streaming) or MPEG-DASH.

Instead of serving one giant video file, the video is broken into small chunks (e.g., 2 to 5 seconds long). For every chunk, there are multiple versions available at different bitrates (qualities).

The server provides a Manifest File (e.g., .m3u8). This is simply a text file that lists the URLs for all the available chunks at all the available qualities.

The magic happens on the Client-side. The video player (in the browser or app) constantly monitors the user's download speed. Before fetching the next 5-second chunk, it decides which quality to request.

Here is a simplified representation of how a client-side player might choose the best bitrate:

class Profile:
    def __init__(self, resolution, bitrate, url):
        self.resolution = resolution
        self.bitrate = bitrate # in kbps
        self.url = url

def get_best_bitrate(current_bandwidth_kbps, available_profiles):
    # available_profiles is sorted from lowest to highest bitrate
    best_profile = available_profiles[0]
    
    for profile in available_profiles:
        # Leave a 20% buffer to prevent sudden buffering if network drops slightly
        if profile.bitrate <= current_bandwidth_kbps * 0.8:
            best_profile = profile
        else:
            break # Since it's sorted, we can stop checking
            
    return best_profile

Because ABR operates over standard HTTP, it easily passes through firewalls and, most importantly, is perfectly cacheable by CDNs.

3. CDN and Edge Caching

Serving 25 Petabytes of video a day from a central data center in Mumbai to users all over India would result in terrible latency and astronomical bandwidth costs. We must use a Content Delivery Network (CDN).

CDNs are networks of servers distributed geographically closer to users (Edge nodes). When a user in Delhi requests a video chunk, the request goes to the Delhi CDN node. If the node has the chunk (Cache Hit), it serves it immediately. If not (Cache Miss), it fetches it from the Origin Server (our Transcoded Storage), caches it, and serves it.

Handling the Long Tail: Video consumption follows the Pareto principle (80/20 rule) heavily. A small percentage of viral videos generate the vast majority of traffic. The rest are "long tail" videos rarely watched.

StrategyDescriptionBest For
Push CDNWe proactively push video chunks to CDN nodes as soon as the video is uploaded.Highly anticipated releases (e.g., a new movie trailer).
Pull CDNThe CDN pulls the chunk from our origin only when a user requests it.Standard user uploads. Prevents wasting CDN cache on unwatched videos.

To optimize costs, YouTube might only transcode a newly uploaded video into 360p and 720p initially. If the video starts getting popular, the system dynamically triggers background jobs to transcode it into 1080p and 4K, and pushes it to edge caches.

Bottlenecks and trade-offs

Trade-off: Storage vs. Compute Do we transcode every video into 4K immediately?

  • Approach A: Transcode everything upfront. High compute cost, high storage cost, but zero latency if someone requests 4K.
  • Approach B: Transcode on-demand. Save storage and compute for unpopular videos, but the first user requesting 4K experiences a delay.
  • Decision: A hybrid approach. Transcode standard resolutions (up to 1080p) upfront. Delay 4K processing until the video crosses a certain view threshold.

Bottleneck: Database writes for View Counts If a viral video gets 100,000 views per second, running UPDATE video_stats SET view_count = view_count + 1 will instantly lock and crash the database.

  • Solution: We do not update the DB synchronously. We send view events to Kafka. A stream processor (like Flink or Spark) aggregates these views in memory over a time window (e.g., 1 minute) and writes the aggregated sum to the database in a single batch. We can also use Redis for real-time approximations.

Questions an interviewer will ask next

1. How do you handle resumable uploads if a user's network drops? Answer: We use chunked uploads (like S3 Multipart Upload). The client divides the 1GB raw file into 10MB parts. It uploads them sequentially or in parallel. If the network drops on part 5, the client only needs to retry part 5, not the whole file. Once all parts are uploaded, the server merges them.

2. How do you ensure a video doesn't contain copyrighted material? Answer: We integrate a Content ID system into our transcoding DAG. Before or during the chunking phase, we extract audio and video fingerprints and compare them against a database of known copyrighted material. If a match is found, the DAG halts, and the video status is marked as 'blocked'.

3. Why use TCP (HTTP) for streaming instead of UDP? Answer: While UDP is faster and used for real-time communication (like Zoom or WhatsApp calls) where dropping a frame is acceptable, Video on Demand (VOD) like YouTube prioritizes quality. HTTP over TCP guarantees packet delivery, ensuring no visual artifacts or missing chunks. Furthermore, HTTP is universally supported by CDNs for caching, whereas UDP caching is highly complex.

Mock interview

Now design it with an interviewer in the room

Reading a design is the easy part. In the round you have to drive it yourself: ask the right questions, sketch it, and defend each choice when the interviewer pushes back.

  • Starts from this exact problem, on a shared whiteboard
  • Follow-ups on scale, failure and trade-offs
  • A scored report that quotes your answers and says what to fix
Run this as a mock design round Voice or text. Pause whenever you need to.

Applying somewhere? Start with the company filled in

Go deeper elsewhere

The best material we've found on these topics.

Practise this

Reading builds understanding. Practice makes it stick.

Keep reading

All articles
Case studies•intermediate

Design Instagram: photo feed and stories

9 min read
Case studies•intermediateStart here

System design case studies: which to practise, in what order

4 min read
Case studies•intermediate

Design WhatsApp: real-time chat at scale

13 min read
Case studies•intermediate

Design a URL shortener

11 min read