Problems / Real world, hard
A chat product on launch-week hardware: the GPU prefill and decode pools, the KV cache store, moderation and the chat API are an eighth of the size real traffic needs. 300 chats a second arrive with long prompts. Answers queue for 20 seconds and most 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 300 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.
300 requests a second for 20 seconds: 90% chat (reads), 10% history (reads).
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 Bot management.Volumetric floods are absorbed at the network edge, spread over many locations, before they reach you. | 100000 slots |
| Bot managementBot management | DDoS protection forwards to it.Calls API gateway.Bot managers score clients by behaviour and fingerprint, not by IP address alone. | 100000 slots |
| API gatewayAPI gateway | Bot management forwards to it.Calls Spend governor, History API.Gateways centralise auth, rate limits and routing so each service does not reimplement them. | 50000 slots · 600,000 calls/min |
| Chat APIApp service | Spend governor forwards to it.Calls Auth and sessions, Conversation store, Moderation model, KV cache tier (prefix reuse).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s. | 1 replicas × 500 slots · timeout 30 s |
| Auth and sessionsAuth / identity service | Chat API calls it.Short-lived access tokens plus refresh tokens limit the damage if a token leaks. | 250 slots |
| Conversation storeDocument database | Chat API calls it. History API calls it.Document databases store nested JSON-like records, so one read can fetch a whole aggregate. | 100 slots |
| Moderation modelLLM-as-judge | Chat API calls it.An LLM judge grades outputs at scale, but it is another model call with its own latency, cost and biases. | 75 slots |
| Spend governorSpend governor | API gateway forwards to it for /chat.Calls Chat API.A spend governor enforces budgets per user, task or team before calls go out. | 12500 slots · 7,500 calls/min |
| KV cache tier (prefix reuse)KV cache tier | Chat API calls it.Calls Prefill GPU pool.Reusing the KV cache of a shared prefix (system prompt, chat history) skips most of the prefill work. | 500 slots · 60% hit rate |
| Prefill GPU poolPrefill GPU pool | KV cache tier (prefix reuse) calls it.Calls Decode GPU pool.Splitting prefill (reading the prompt) from decode (writing the answer) onto separate GPUs stops long prompts from stalling everyone else’s output. | 50 slots |
| Decode GPU poolDecode GPU pool | Prefill GPU pool calls it.Decoding is memory-bound: each request holds its KV cache in GPU memory for as long as it generates. | 300 slots |
| History APIApp service | API gateway forwards to it for /history.Calls Conversation store.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 |