AI Infra Interviews logo
Interactive explainer · Serving

How one server serves many people at once

Batching, continuous batching and the paged KV cache, run on a scheduler you can watch pass by pass. Every timing comes from a real model measured at each batch size and context length.

01

Many people, one model

A serving engine rarely runs one request at a time. People send prompts whenever they like, with prompts and answers of every length, and the engine has to fit all of them onto the same weights in the same GPU memory.

Each request needs two kinds of work: its prompt processed once (prefill), then one pass per output token (decode). Everything on this page is about deciding which requests share each pass, and what that choice costs in time and memory.

The requests below arrive as people really do: independently, at random moments, with a set average rate. Their prompt and answer lengths vary within the ranges shown.

Requests as they arrive
Requests
24about 3 per second on average
Mean prompt
97 tokens16 to 160
Mean answer
67 tokens16 to 128
Each row is one request, in arrival order. Its dot marks when it arrives; its bar is the prompt (purple) then the answer (blue), drawn to scale. The same requests are scheduled in every later stage.
02

One pass can serve many

A decode pass reads every weight to produce one token. If eight people are waiting for their next token, the same pass can read the weights once and produce all eight. The extra cost is only the arithmetic for the extra tokens and the reads of each person's own cache.

The chart uses real measurements of the model from the first explainer, timed at each batch size and cache length. Move the sliders: the time per pass grows slowly with the batch at first, so the total tokens per second climbs steeply, while each person's own tokens arrive more slowly. Once every person's cache is long, the cache reads take over and a bigger batch stops paying.

That trade, total throughput against each person's speed, is the decision behind every setting on this page.

Try it. Find the batch size where adding people stops raising total tokens per second, at a short and at a long context.

Further reading: Continuous batching (free account), Bandwidth-bound decode throughput (Premium).

One decode pass for a whole batch
batch 1total tokens per secondbatch 32
One pass
63 ms2.6× the time of batch 1
Each person
15.8 tokens/s39% of batch 1's speed
Everyone together
126 tokens/s3.1× batch 1
Most total throughput
batch 32181 tokens/s at this cache length
Measured 2026-10-12 on AMD Ryzen 7 9700X 8-Core Processor, one thread. Solid bars are measured batch sizes; the rest are interpolated between them, within the measured range of 32 people and 1,024 cached tokens.
03Premium

Static batching waits for the slowest

Watch a batch start together and finish together: requests that are done keep their slot as padding until the longest one ends, and newcomers wait outside. The simulator shows how many slots sit idle and what that does to waiting time.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • the same requests run as a static batch, pass by pass
  • how many batch slots sit idle, and how long newcomers wait
See Premium
04Premium

Continuous batching refills every pass

The same requests, scheduled again before every pass: finished requests leave at once and waiting ones take their slot. Compare throughput and time to first token with static batching on the identical workload.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • the requests rescheduled before every pass
  • throughput and time to first token compared with static batching
See Premium
05Premium

Paged memory decides how many fit

Watch the KV cache fill block by block. Compare reserving room for the longest possible answer with allocating 16-token blocks as each answer grows, and see how many more people fit.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • the KV cache as 16-token blocks at any moment
  • paging compared with reserving room for the longest answer
See Premium
06Premium

When memory runs out

Shrink the cache and watch the scheduler evict a request and recompute it later, as vLLM does by default. See what preemption costs the evicted request and everyone else.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • a cache you can shrink until requests are evicted
  • what recomputing an evicted request costs
See Premium
07Premium

Tuning the scheduler

Change the batch limit, the per-pass token budget and the arrival rate. Track time to first token, time per token, throughput and the share of requests that meet a latency target.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • batch limit and per-pass token budget settings
  • latency, throughput and a latency target as load rises
See Premium
08Premium

At production scale

Carry the same scheduling arithmetic onto a 70-billion-weight model on and GPUs: how much cache each conversation needs, how many fit, and the throughput a batch can reach at a given latency.

Run this stage with Premium

This stage is an interactive simulation with the same measured pass times. Premium members see:

  • decode floors for 8B and 70B models on H100 and B200
  • how many conversations fit, and the batch where cache reads take over
See Premium