21/30
Part 6 of 7 · The worked exampleLearn
The design, in the order you present it
4. The design. Present it in the order a request travels, then the loop that sizes the pools.
- A gateway checks the API key and applies per-customer limits on requests and on tokens, so one customer can't take the fleet.
- A router picks a GPU for each request. It routes by model, and by prompt prefix where it can, so requests that share a system prompt land where its cache already sits.
- Each GPU runs continuous batching from the batch-inference lesson, admits a new request only while its cache has room, and prefills long prompts in chunks.
- Tokens stream back to the client over server-sent events as each step produces them.
- An autoscaler reads requests waiting and cache in use from every GPU, and adds capacity ahead of the daily peak.