Problems / Real world, hard
Live streaming as first built: no manifest cache in front of the live streams catalog, and the playback and chat APIs, chat fan-out, live ingest and transcoders at an eighth of their real size. Real viewers arrive, watching and chatting, and three in four requests fail.
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.
Grow it into the real architecture: every goal must hold at 8,000 requests a second. You may add components, connect them and resize anything.
Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 6; 2 of them are hidden until then.
8,000 requests a second for 20 seconds: 85% watch (reads), 14% chat (writes), 1% ingest (writes).
What each component does in this design, and what calls it. The simulator mimics each one from these settings.
| Component | Its job here | Settings |
|---|---|---|
| DDoS protectionDDoS protection | Traffic enters here.Calls API gateway.Volumetric floods are absorbed at the network edge, spread over many locations, before they reach you. | 100000 slots |
| API gatewayAPI gateway | DDoS protection forwards to it.Calls Playback API, Chat API, Live ingest (RTMP).Gateways centralise auth, rate limits and routing so each service does not reimplement them. | 50000 slots · 2,000,000 calls/min |
| Playback APIApp service | API gateway forwards to it for /watch.Calls Live streams catalog.Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Live streams catalogDocument database | Playback API calls it for reads.Document databases store nested JSON-like records, so one read can fetch a whole aggregate. | 100 slots |
| Chat APIApp service | API gateway forwards to it for /chat.Calls Chat messages (Kafka) (publishes).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 100 slots · timeout 1.0 s |
| Chat messages (Kafka)Event stream | Chat API publishes to it.Calls Chat fan-out.Kafka keeps order only within a partition, so the partition key decides what stays in sequence. | 8 partitions · retention 600 s |
| Chat fan-outWorker | Chat messages (Kafka) consumes from it.Calls Chat room pub/sub (to edge servers).Queues deliver at least once, so a worker can see the same message twice. | 32 concurrent jobs |
| Chat room pub/sub (to edge servers)Pub/sub topic | Chat fan-out calls it.Pub/sub delivers each message to every subscriber, so producers never know who listens. | 2500 slots |
| Live ingest (RTMP)Live stream ingest | API gateway forwards to it for /ingest.Calls Live transcoders, Segment storage.Broadcasters push RTMP or SRT to an ingest point near them; from there the stream is transcoded into renditions and packaged into segments. | 250 slots |
| Live transcodersVideo transcoder | Live ingest (RTMP) calls it.Transcoding turns one video into several resolutions for adaptive streaming. | 50 slots |
| Segment storageObject storage | Live ingest (RTMP) calls it.Object stores like S3 keep copies across devices and facilities for very high durability. | 625 slots · 250,000 calls/min |