Design Twitch from an empty canvas: take in broadcasters’ live streams, transcode them, deliver them to viewers through a CDN and run real-time chat, at 2,000 requests a second.
Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
What it must do
Broadcasters push live video; each 2-second segment is transcoded into several qualities within a second or two and stored.
Viewers fetch the live playlist and segments through a CDN.
Chat: a message reaches everyone watching the channel within a second, over long-lived WebSocket connections.
Keep spam bots out of chat.
Scale
2,000 requests a second: 1,500 viewer playlist and segment fetches, 400 chat messages and 100 segment pushes from broadcasters.
About 200 channels are live, each pushing a 2-second segment at 6 Mbps; about 3,000 viewers each fetch a segment every 2 s.
The CDN serves about 85% of viewer fetches: most people watch the same few channels.
Request types to route: watch (75%, read), chat (20%, write), ingest (5%, write). Budget: $15,000 a month.
Estimate first
Segments being transcoded at once (segments)
Ingest bandwidth from broadcasters (Gbps)
Viewer bandwidth at 3 Mbps a viewer (Gbps)
Monthly cloud cost of your design (USD)
The test cases
You start from an empty canvas. When you run the tests, each one simulates your design with its own traffic and failures:
Test
What it does
Passes when
Normal day
The normal day: the traffic in the brief, nothing broken.