πŸ’¬
βœ‰οΈ
πŸ“Έ
▢️

Loading…

Design YouTube: video upload, transcoding, and CDN

YoutubeGuided Mode

Separate Binary Storage with Blob Storage

Move video bytes out of the database and into a dedicated S3 Storage. The database now stores only metadata (title, URL, duration) β€” never file bytes.

Request Flow

1

API uploads to S3

Uploader POSTs to the API, which streams bytes to S3 Storage. Better than the database, but the API still handles every byte.

2

DB stores metadata only

The Database stores a lightweight row: title, s3_key, duration, uploader_id, status. No binary blobs β€” rows are tiny and queries are fast.

3

Viewer fetches from S3

GET /watch returns the S3 URL. The viewer's browser or player fetches bytes directly from S3 Storage. Better β€” but the API still mediates uploads.

Why We Need This

S3 stores petabytes at $0.023/GB/month with 99.999999999% durability. A relational DB costs 100Γ— more per GB and wasn't designed for streaming binary data.

Key Insight

The database should only store the S3 key (a string like 'videos/abc123.mp4'), never the bytes. Separating metadata from binary data is the foundation of every scalable media system.

Step 2 of 9