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

Loading…

Design YouTube: video upload, transcoding, and CDN

YoutubeGuided Mode

The Naive Approach (Why It Breaks)

The simplest design: store video bytes in the database and serve them through the API. This fails at every scale β€” the API becomes an I/O bottleneck and the database can't store gigabytes efficiently.

Request Flow

1

Upload saturates API

Every byte of a 4K video flows through the API server. Uploading a 10 GB video at 200 Mbps keeps one core busy for 7 minutes doing pure network I/O.

2

DB stores raw bytes

Storing video blobs in a relational Database bloats row sizes, slows every scan, consumes expensive SSD storage, and adds ORM overhead. Databases are built for structured queries, not binary streaming.

3

Viewer download fails

Serving a 10 GB video via HTTP means the API Server holds an open connection for minutes. With 1000 concurrent viewers, you need 1000 long-lived connections β€” 100% of server memory.

Why We Need This

Databases and API servers are the wrong tools for binary large object storage and streaming. Separate infrastructure is needed for each concern.

Key Insight

A relational database stores a 1 GB video in a bytea/BLOB column. That single row is now larger than many whole databases. Every table scan, backup, and replication must move those gigabytes.

Step 1 of 9