LOAD-BEARINGfree
High-level designTier 11 · unit 1 of 5 · 14 min read

Inference serving: the GPU as scarce capacity

Every tier so far has assumed compute you can add. Stateless servers scale out in seconds (Tier 4), capacity planning is arithmetic over headroom (9.07), and the cost lever is how many instances you run (14.02). Model inference breaks all three assumptions at once, and the reasons are worth understanding rather than working around.

Two phases, and they behave nothing alike

A single inference request runs in two distinct modes:

  • Prefill — read the entire prompt and build the internal state. Every token is processed in parallel, so this phase saturates the arithmetic units. It is compute-bound, and its cost scales with how long the prompt is.
  • Decode — produce output one token at a time, each one depending on the one before it. No parallelism is available across the sequence, so the hardware spends most of its time moving weights from memory rather than computing. It is memory-bandwidth-bound.

That second line is the one with consequences. During decode, a very expensive processor is largely idle, waiting on memory. Which gives the central economic fact of inference serving:

Serving one request at a time wastes most of the hardware. Batching is not an optimisation — it is the business model.

Because the weights have to be read either way, running many sequences through the same read is nearly free. The technique that makes this practical is continuous batching: rather than assembling a batch, running it to completion, and starting the next, the server adds arriving requests to the running batch and evicts finished ones as they complete. Tier 9's utilisation thinking, on a much sharper curve — the difference between a batch of 1 and a batch of 32 is not a percentage.

The resource that actually runs out is memory

Each active sequence holds intermediate attention state in accelerator memory — the KV cache — and it grows with that sequence's context length. Model weights take a fixed slice; whatever is left is divided among concurrent requests.

So concurrency is bounded by memory, not by compute, and the bound moves with your workload:

memory available = total − weights
concurrent requests ≈ memory available / (KV per token × context length)

Double your average context length and you roughly halve how many users one accelerator serves. That is the number to capacity-plan on, and it is why "we support long context" is a statement about your cost structure, not just your feature list.

Two latency numbers, and a knob between them

Tier 9 taught you to watch a percentile. Here one number hides the thing users feel:

  • Time to first token — queueing plus prefill. This is "did it start", and it is what a waiting user experiences as slowness.
  • Inter-token latency — the decode rate. This is "is it fast", and once output is streaming it matters more than the total.

Batch size trades between them explicitly: larger batches raise throughput and worsen inter-token latency, because each step now serves more sequences. That is a dial you set deliberately against your product, not a tuning accident — an interactive assistant and an overnight document pipeline want opposite ends of it.

Reusing prefill: caching a computation, not a value

When many requests share a long opening — a system prompt, a policy document, a conversation history — the prefill work over that shared region can be computed once and reused, along with its KV cache. On a workload with a large fixed preamble this is one of the biggest wins available, and a cache read costs roughly an order of magnitude less than recomputing the same tokens.

The discipline it demands is Tier 4's, sharpened. It is a prefix match: reuse holds only up to the first byte that differs, and everything after that point is recomputed. So the ordering of a prompt becomes an architecture decision — stable content first, volatile content last. A timestamp interpolated near the top of an otherwise fixed preamble silently converts every request into a full recomputation, and nothing in your metrics says "cache miss" unless you go looking for it.

You cannot autoscale out of a spike

Loading a large model's weights onto an accelerator takes minutes. A traffic spike lasting thirty seconds is over before a new instance is ready, which removes the reflex every other tier taught you. What is left:

  • Queue, with admission control. 9.03's rate limiting, now protecting a resource that genuinely cannot be conjured. Reject early and clearly rather than accepting work that will time out.
  • Priority classes. Interactive requests jump; bulk work waits. Without this, one large batch job starves every user on the same pool.
  • Separate the offline pool. Batch work belongs on its own capacity where it can soak up spare cycles at low priority — one of the clearest cases in this course where the queue is the architecture.

And cost per request is a function you can actually compute: input tokens through prefill plus output tokens through decode. Output tokens dominate, because decode is serialised and slow. A design consequence falls straight out — asking a model to summarise a document is cheap; asking it to rewrite one is not, and the difference is a product decision with a bill attached.

The trap

Treating an inference endpoint like a stateless HTTP service: autoscaling on CPU, alerting on request rate, sizing on requests per second. Every signal is wrong. The constraint is accelerator memory, the load indicator is queue depth and KV cache occupancy, the scale-up time is minutes rather than seconds, and the meaningful capacity unit is tokens per second, not requests. A dashboard inherited from Tier 9 will look healthy while users wait ninety seconds for a first token.

The nuance

“Inference latency is dominated by the model.”

True for a large model on a busy GPU, and misleading at small scale, where queueing, tokenisation, network round trips and cold weights routinely dominate the forward pass. Profile the whole path before optimising the model — the answer is frequently that the GPU is idle and the queue is not.