Medium · 13 steps · ~75 min
Design a video platform
Upload once, stream to millions at every quality.
Viewers stream videos far more than creators upload them. Streams need to be fast everywhere; uploads need heavy processing but can happen in the background.
Same problem as YouTubeVimeoTwitch
How it works
- Watch: a nearby edge cache serves video chunks, falling back to the origin.
- Upload: the file is stored, then workers convert it to several qualities.
What you'll build
- The API and the data behind it
- A system that answers 300 requests a second
- A CDN, cache and replicas for tens of thousands
- An upload pipeline with a queue, workers and transcoders
- Designs that survive a cold cache, a lost server and a lost primary
Steps
- 1Design the API
- 2Design the data model
- 3Handle 300 requests/sec
- 4Handle 5,000 requests/sec for $1,000 a month
- 5Add an upload pipeline
- 6Handle 40,000 requests/sec
- 7Keep p99 latency under 150 ms
- 8Handle 150,000 requests/sec
- 9Survive a CDN and cache restart
- 10Lose an API server
- 11Lose the primary database
- 12A video that never finishes processing
- 13Deep dive: why several qualities?