Capacity Planning for Inference
Tokens per second, on purpose
Inference capacity is about tokens per second from concurrency, batch size and hardware — plus the provider mix that absorbs spikes. Compute CUDA-visible batch throughput estimates, plan headroom and prepare throttling and overflow paths before the spike, not during it.
What you will learn
- Estimate serving throughput from concurrency and batch
- Size memory and GPU count for a workload
- Design overflow, throttle and fallback for spikes
What is this?
Capacity planning sizes the inference tier to serve expected tokens/sec with headroom. It combines KV-cache memory limits (what fits on the GPU), batch-fill rates, model latency, and a safety plan — throttling, overflow to providers, queueing — for the spikes that exceed it.
Why do you need it?
- Under-provisioning = queueing or 503s at peak; over-provisioning = idle GPUs billed all month.
- KV cache, not just model weights, decides how many concurrent users a GPU handles.
- Spike response is a design decision now: throttle politely vs fail loudly.
Mental model
Capacity
Designing a bridge
You size it for worst realistic weekday traffic, not the Monday-morning record — and you build the ramp restrictions (throttling) so an occasional overload bends the bridge instead of breaking it.
How it works
- Find max concurrent sessions per GPU: KV-cache memory + batch slices per model.
- Measure batch-fill: bigger batches raise tokens/sec but add TTFT jitter.
- Project from usage: peak tokens/sec = sessions x tokens per request x burst factor.
- Add overflow: queue + provider fallback or graceful degradation (cached answers, smaller model).
Capacity math loop.
In production
- A serving team predicts 3 requests/sec x 2K tokens → sizes N GPUs at 60% fill before a launch.
- A chat provider rate-limits per tenant and spills overflow to a batch API at 5x traffic.
- An autoscaler scales on active sessions and p99 TTFT, not CPU.
Best practices
- Measure batch-fill vs TTFT trade for your model, don't guess.
- Plan overflow behavior explicitly: queue depth caps, throttling responses, cached fallbacks.
- Track tokens/sec per GPU and per provider as the real capacity metric.
- Stress-test the overflow path before the launch spike, every quarter.
Common mistakes
- Sizing GPUs by raw model weight only — KV cache is the real constraint.
- Autoscaling on request count while batch fills stay flat (mismatch with tokens).
- No degradation plan: the spike either times out silently or 500s.
Debugging tips
- TTFT rockets at peak → batch too large at high fill; cap batch or split across shards.
- GPU not at memory limit but slow → bandwidth/KV pressure; check tokens/sec per unit.
- Spike 503s → overflow path misconfigured; verify queue and provider failover actually engage.
Interview checkpoint
Hands-on lab
- Find the KV-cache bound on concurrency
- Convert sessions into tokens per second
- Compute GPU count for a workload
Estimate Serving Capacity
35 min · advanced
Quick quiz
The dominant memory constraint for concurrency is?
Throttling feels better to users than silent 500s.