Production AI Architecture
Advanced 13 min read Production AI Architecture

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.

capacity planningthroughputGPU memoryconcurrency
Prerequisites: GPU Inference
Before we start

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
Introduction

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.

Motivation

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.
Think about it

Mental model

Imagine

Capacity

Think of

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.

Mechanics

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.

Load
Fit
Run
Overflow
Real world

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.
Guidelines

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.
Watch out

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.
When things break

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.
Interviews

Interview checkpoint

Practice

Hands-on lab

Estimate Serving Capacity
35 min · advanced
In progress
Objectives
  • 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

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

The dominant memory constraint for concurrency is?

2

Throttling feels better to users than silent 500s.

Go deeper

Official documentation