Prefill queues: service-time variation matters before saturation
Use a scoped M/G/1 calculation to separate mean utilization, service-time variance, and latency-aware admission in a real prefill pool.
On this page
The question for today
What you’ll understand
- Calculate utilization and mean waiting under explicit M/G/1 assumptions.
- Explain why equal mean prompt service can produce different queue delays.
- Separate queue-model evidence from batched, chunked, and downstream-constrained admission.
A prefill pool can have moderate average utilization and still expose long first-token delays when large prompts block smaller ones or arrive in bursts. Request count alone hides service-time variation, while a stage-local throughput target can overproduce caches for the decoder. We derive one stationary single-server FCFS queue with Poisson arrivals and independent identically distributed service times. Actual batching, chunking, priorities, cache reuse, and downstream reservations change those assumptions; they must be measured rather than silently inherited from the equation.
Model work and the relevant server explicitly
Choose whether a modeled server is one device, one tensor-parallel instance, or a scheduler-owned execution lane. Its service time must match that definition and the workload being admitted. A prompt’s token length is a useful feature but not a universal linear cost because attention shape, cache reuse, batching, and kernel saturation matter. Record service-time distributions by request class and configuration. Arrival rate and service rate expressed in different units, such as requests per second versus prompt tokens per second, cannot be compared without the corresponding workload conversion.
For the illustrative M/G/1 model, utilization is arrival rate times mean service time and must be below one for the stated stationary regime. This necessary mean margin does not imply that a particular tail deadline will be met. Service-time variance changes residual work seen by arriving requests, and the second moment appears in mean queue waiting. An occasional very long prompt can therefore matter even when the mean service time is unchanged. A bursty or correlated arrival process needs another model or trace-based analysis.
Admission must include downstream and deadline obligations
A prompt can be short enough for local admission but lack a reserved compatible decode destination. Include outstanding cache bytes, destination reservations, transfer pressure, and request deadline when defining the accepted work path. Rejecting or deferring before expensive prefill can avoid stranded state, but the policy should record the affected workload classes. A finite queue or token budget is a resource control, not evidence that every accepted request completes within its first-token objective. Define cancellation and expiry so reserved capacity is released without letting stale attempts reuse it.
Chunking a long prompt can reduce one blocking interval, but it adds scheduler decisions and can change repeated cache access, transfer scheduling, and the service-time model. Priority scheduling also changes which requests wait and which fairness claim applies. Once a pool uses batching, preemption, or multiple heterogeneous servers, the simple single-server FCFS formula is no longer a literal predictor. Preserve it as a diagnostic baseline and compare with measured arrival and completion traces. Do not infer p99 delay from a mean waiting value without a justified distributional calculation.
Validate overload and cleanup in the full stage path
Sweep offered load with a generator that preserves the intended arrival process, and report accepted, rejected, canceled, timed-out, and completed requests. Track prompt length, reuse, per-class queue time, cache bytes retained, and destination reservation age. A completed-only chart can improve when overloaded requests disappear from the sample. Test a decoder slowdown as well as a prefill slowdown, because downstream backpressure can retain source caches and invalidate a local capacity estimate. Verify recovery and reservation cleanup after the load returns to normal.
The queue lab is a different, smaller model. Reset, explicitly set arrival two and service three, predict its displayed M/M/1 mean residence of one second, then Play or Step. Compare a fresh Reset with arrival 2.5 and service three explicitly set, giving two seconds. Those residence values assume Poisson arrivals and exponential service; the animation itself is deterministic fluid backlog from four items. Neither is the M/G/1 variance experiment above, and the instrument has no prompt lengths, batching, destination reservation, or finite-capacity admission.
Work it through
Doubling the second moment doubles this mean wait
Assume the stated stationary M/G/1 model with arrival two requests per second, mean service 0.2 seconds, and service second moment 0.08 seconds squared. Compare with deterministic service of the same mean, whose second moment is 0.04.
Utilization is 2×0.2=0.4 for both cases. The mean service is unchanged, so the difference comes from the second moment rather than a different average rate.
With second moment 0.08, mean queue wait is (2×0.08)/(2×0.6)=0.133333… seconds. Mean residence is about 0.333333 seconds after adding 0.2 service.
With deterministic service, waiting is (2×0.04)/(2×0.6)=0.066666… seconds and residence about 0.266667. The mean wait halves, but neither mean specifies a tail latency or a real batched prefill pool’s outcome.
The same mean utilization can coexist with different mean queueing delay. Preserve the model assumptions before using that explanation for a measured pool.
The living notebook
Explore the model
Interactive lab · queue
The lab’s M/M/1 residence is separate from its fluid animation
For independent runs use Reset → explicitly set BOTH rates → predict → Play/Step with (2,3) and (2.5,3). Displayed M/M/1 mean residences are one and two seconds under Poisson/exponential assumptions; the animated backlog is max(0,4+(λ−μ)t). No M/G/1 variance control or prefill scheduler is implemented.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forQueue-model assumptions and measured stage boundaries determine what a numerical latency statement means.
Pause & reason
Check your understanding
Your turn
Try it yourself
Use the stated M/G/1 assumptions with arrival one request/s, mean service 0.4 s, and second moment 0.2 s². Calculate utilization, mean queue wait, and mean stage residence. May that residence be reported as complete client TTFT?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Keep the queue and service boundary consistent, then identify the omitted stages.
Compare with the solution
Utilization is 0.4. Mean queue wait is 0.2/(2×0.6)=1/6 s, about 0.1667 s. Mean stage residence is about 0.5667 s. This excludes any upstream admission, transfer, destination queue, or output delivery outside the modeled service, so it is not automatically client TTFT. The formula also does not describe a batched or priority-based pool without rechecking assumptions, nor provide a tail deadline guarantee.
Keep the idea
Take it with you
- Choose matching arrival, work, and server definitions.
- Service-time variance affects queue delay under explicit assumptions.
- Validate downstream pressure, tail outcomes, and cleanup beyond a mean queue model.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.