System design · 16 of 16
Mid
Senior
- Monitoring and alerting for 100 servicesSRE · Platform · DevOps
- Secrets management platformDevOps · Platform · SRE
- Multi-region active-active serviceSRE · Platform
- Distributed job scheduler (cron at scale)SRE · Platform
- Internal developer platform (IDP)Platform
- Multi-tenant Kubernetes platformPlatform · DevOps · SRE
- GitOps for a fleet of 100 clustersPlatform · DevOps
- ML training platform and feature storeMLOps · Platform
- LLM inference platformMLOps · Platform · SRE
SENIOR · 14 MIN · MLOPS · PLATFORM · SRE
LLM inference platform
An AI gateway, per-model queues, GPU servers with continuous batching, caching, autoscaling on tokens and smart routing between models.
- Peak load
- 2,000 tokens/s per replica
- Availability target
- 99.9%
- RTO: back up within
- 10 min
- RPO: data you can lose
- n/a (stateless)
← Swipe sideways to see the whole diagram →
The question
"Design a platform that serves several large language models to many internal apps with good latency and reasonable GPU cost."
Requirements
- An OpenAI-style API for apps, with authentication, quotas and usage per team.
- Low time-to-first-token for chat; high throughput for batch jobs.
- Use expensive GPUs efficiently and scale with demand.
- Survive a GPU node or a whole model pool failing.
Quick numbers
| Item | Assumption | Result |
|---|---|---|
| Model | 70B parameters, 16-bit | ~140 GB of weights: needs at least 2 x 80 GB GPUs |
| Same model, 4-bit quantized | ~35 GB | fits on one 80 GB GPU with room for KV cache |
| One replica | ~2,000 output tokens/s with batching | 50 concurrent chats at ~40 tokens/s each |
How it works
- Apps call the AI gateway: it checks keys, enforces quotas, logs usage per team and routes to a model.
- Repeated prompts can be answered from a response cache (exact match, or semantic match for some use cases).
- Requests wait in per-model priority queues (chat before batch).
- Inference servers (vLLM, TensorRT-LLM or TGI) use continuous batching and a paged KV cache to serve many requests on one GPU at once.
- Model weights load from object storage onto fast local NVMe; warm replicas stay loaded because cold starts take minutes.
- The autoscaler adds or removes replicas based on queue depth and tokens per second, not CPU.
Key decisions
| Decision | Choice | Why |
|---|---|---|
| Batching | continuous batching | much higher GPU use than one request at a time |
| Model size | route easy tasks to small models | big cost savings with little quality loss |
| Quantization | 8-bit or 4-bit where quality allows | fewer GPUs per replica |
| Scaling signal | queue depth, tokens/s, time to first token | matches what users feel |
| Fairness | per-team quotas and priorities | one batch job can't starve chat |
What breaks and how it heals
- GPU node fails: the gateway retries on another replica; keep N+1 replicas for critical models.
- Traffic spike: queue with timeouts, shed batch traffic first, scale out (slowly, because weights are large).
- Model update goes wrong: canary new model versions with quality and latency checks.
High availability and disaster recovery
| Target | Number | How it is met |
|---|---|---|
| Availability | 99.9% | at least N+1 replicas per model across 2 zones |
| GPU node fails | requests retried | the gateway retries on another replica |
| Cold start | ~5 minutes for 140 GB of weights at ~500 MB/s | keep warm replicas; cache weights on local NVMe |
| Lost GPU capacity in a region | RTO 10 minutes | fall back to a smaller model or a second region; reserved GPU capacity for critical models |
| Data | RPO not applicable | servers are stateless; chat history lives in its own database with backups |
What interviewers listen for
- GPU memory math (weights + KV cache) and batching.
- Latency metrics specific to LLMs: time to first token, tokens per second.
- Cost control: routing, quantization, caching and autoscaling on the right signal.