🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Design a Video Streaming Platform

System Design ProblemsVideo InfrastructuređŸŸĸ Free Lesson

Advertisement

System Design Problems

Design a Video Streaming Platform

A video streaming platform enables users to upload, transcode, and watch videos with adaptive bitrate streaming. YouTube serves over 1 billion hours of video daily, requiring sophisticated transcoding pipelines and CDN infrastructure.

  • Upload Pipeline — Accept large video files and process them asynchronously
  • Transcoding — Convert videos to multiple resolutions and formats
  • Adaptive Streaming — Serve the best quality based on network conditions

Video is the most bandwidth-intensive content on the internet. A single 4K video can be 100 GB before transcoding. The system must handle upload, processing, storage, and delivery efficiently.

Requirements

Functional Requirements

  • Users can upload videos (up to 4 hours, 4K resolution)
  • Transcode videos into multiple resolutions (240p to 4K)
  • Adaptive bitrate streaming (HLS/DASH)
  • Video playback with buffering and seeking
  • Video metadata (title, description, tags)
  • Like, comment, and subscribe features
  • Content moderation and copyright detection

Non-Functional Requirements

  • Upload: Support 500 hours of video uploaded per minute
  • Playback: Start playing within 2 seconds
  • Availability: 99.99% for video playback
  • Latency: First frame < 2 seconds
  • Scale: 1 billion hours of video watched daily

Back-of-the-Envelope Estimation

High-Level Architecture

UploadAPI Gateway+ AuthUpload ServiceChunked UploadResumableRaw Storage(S3)Transcoding240p → 4K (10 variants)Transcoded Storage(S3 + CDN Origin)ViewerCDN Edge(HLS Segments)Origin Server(S3/CloudFront)Video Streaming Architecture

Detailed Design

Video Upload Pipeline

  1. Client requests upload URL from API
  2. API returns pre-signed S3 URL for each chunk
  3. Client uploads chunks in parallel to S3
  4. Upload service tracks chunk completion
  5. On completion, trigger transcoding pipeline

Transcoding Pipeline

Raw VideoTranscoder2160p (4K)1440p (2K)1080p (FHD)720p → 240pHLS/DASHSegment into10s chunksCDNTranscoding and segmentation pipeline

Adaptive Bitrate Streaming (HLS)

Architecture Diagram
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
stream_360p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2000000,RESOLUTION=1280x720
stream_720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
stream_1080p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=15000000,RESOLUTION=3840x2160
stream_4k.m3u8

Video Metadata

CREATE TABLE videos (
    id          UUID PRIMARY KEY,
    user_id     BIGINT NOT NULL,
    title       VARCHAR(500),
    description TEXT,
    duration    INT,           -- seconds
    status      VARCHAR(20),   -- processing, ready, failed
    created_at  TIMESTAMP,
    view_count  BIGINT DEFAULT 0
);

CREATE TABLE video_variants (
    video_id    UUID REFERENCES videos(id),
    resolution  VARCHAR(10),   -- "1080p"
    bitrate     INT,           -- bps
    codec       VARCHAR(10),   -- "h264", "h265"
    file_path   TEXT,
    file_size   BIGINT,
    PRIMARY KEY (video_id, resolution)
);

Practice Exercises

  1. Design: How would you implement a video seeking feature that allows jumping to any point in a 4-hour video within 500ms? What caching and indexing strategies are needed?

  2. Scale: If YouTube uploads 500 hours of video per minute, estimate the transcoding cluster size needed assuming each machine can transcode 1 hour of video in 2 hours.

  3. Optimization: How would you implement a video deduplication system that detects re-uploads of the same video with different encodings? What fingerprinting algorithm would you use?

  4. Cost: Design a tiered storage system that moves old videos from hot (SSD) to warm (HDD) to cold (Glacier) storage based on access patterns.


What to Learn Next

-> CDNs Edge caching and global video delivery.

-> Design Object Storage Storing large video files with high durability.

-> Message Queues Async transcoding pipeline with Kafka.

-> Load Balancing Distributing transcoding work across machines.

-> Caching Strategies Caching popular video segments at CDN edges.

-> Design Realtime Analytics Real-time video viewing analytics and metrics.

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement