AI Dojo Open on the typewriterThe typewriter

An exercise to try

Diagnose a slow answer

20 minutes
Assumes: you know what time to first token measures, as in Time to first token.
First published 19 November 2026. Last edited 19 November 2026.

“It's slow” can mean a long queue, a long prompt or a slow stream, and each needs a different fix. A few timestamps per request are enough to tell them apart.

Time
20 minutes
What you need
This page and a place to write. A calculator helps. No chatbot or code is needed.

Illustration. The requests, timings and stop reasons here are invented teaching material, not measurements of a real service.

Words used here

  • Time to first token. The wait from sending a request until the first piece of the reply arrives.
  • Prefill. The model reading the whole prompt before it can write anything.
  • Decode. The model writing the reply one token, a small piece of text, at a time.
  • Time per output token. The average gap between tokens once the reply has started.
  • Output cap. The most new tokens a request allows the model to write.
  • Reasoning model. A model that writes hidden reasoning tokens before its visible answer; they are billed as output.

The log

One assistant served these six requests, picked from a busy hour, so other requests ran in between. Times are seconds after 10:00 on the server's clock. “Started” is when the server began work on the request; before that it waited in a queue. Stop “end” means the model finished its answer; “length” means it reached the output cap set for that request. vLLM's metrics split a request into the same queue, prefill and decode intervals, and NVIDIA's guide notes that longer prompts raise time to first token.

RequestArrivedStartedFirst token
R112.012.112.5
R240.040.140.5
R375.079.079.4
R4110.0110.1113.1
R5150.0150.1150.5
R6190.0190.1190.5
RequestLast tokenOutput tokensStop
R118.5301end
R242.48100length
R385.4301end
R4119.1301end
R5162.5301end
R6192.5101end

Step 1. Split each wait into three

For each request, work out the queue (started minus arrived), prefill (first token minus started) and decode (last token minus first token). Add them for the end-to-end time.

Check your split
  • R1: queue 0.1, prefill 0.4, decode 6.0, end to end 6.5 seconds.
  • R2: queue 0.1, prefill 0.4, decode 1.98, end to end 2.48 seconds.
  • R3: queue 4.0, prefill 0.4, decode 6.0, end to end 10.4 seconds.
  • R4: queue 0.1, prefill 3.0, decode 6.0, end to end 9.1 seconds.
  • R5: queue 0.1, prefill 0.4, decode 12.0, end to end 12.5 seconds.
  • R6: queue 0.1, prefill 0.4, decode 2.0, end to end 2.5 seconds.

The prefill figure here also includes producing the first token, which is how vLLM's prefill interval is defined.

Step 2. Time the stream

Work out the time per output token: decode divided by (output tokens minus 1), because the first token belongs to the start.

Check your times

R1, R2, R3, R4 and R6: 0.02 seconds, or 20 milliseconds, per token. For example, R1 is 6.0 ÷ 300 and R2 is 1.98 ÷ 99. R5: 12.0 ÷ 300 is 0.04 seconds, 40 milliseconds per token, twice as slow.

Step 3. Name the problems

Find the request that was fast only because it was cut off, the two that started slowly for different reasons, and the one that streamed slowly.

Check your diagnosis
  • R2 was cut off. Its stop reason is “length” at 100 tokens. It looks as quick as R6, 2.48 seconds against 2.5, but only R6 finished its answer.
  • R3 started slowly because it queued. It waited 4.0 seconds before any model work, and its prefill and stream were normal. The model was not slow; the server was full.
  • R4 started slowly because of prefill: 3.0 seconds against 0.4 for the others, with no queue. A much longer prompt is the usual cause.
  • R5 streamed slowly: it started on time, then took 40 milliseconds per token.

The common wrong answer ranks R2 as the best request because its end-to-end time is the shortest. A cut-off answer is a failure until shown otherwise. The second trap is blaming the model for R3, whose model work was as fast as R1's.

Step 4. Choose one change for each

For R2, R3, R4 and R5, name one change to try, and say which interval it should shrink. Naming the right interval matters more than naming the perfect fix.

Check your changes
  • R2: raise its output cap, or ask for a shorter answer, and count it as a failure until the answer is complete.
  • R3: add capacity, such as a second copy of the model so two requests can be served at once, or spread the load. This shrinks the queue; changing the model would not.
  • R4: shorten the prompt, or put its repeated beginning first so the engine's prefix caching can reuse it (prompt caching at a hosted provider). This shrinks prefill.
  • R5: requests that decode at the same time share the GPU, so each stream slows. Check how many were decoding alongside R5, and cap that number if it was high, accepting that more requests may then queue; or try a faster decoding method such as speculative decoding, then re-check quality. This shrinks decode.

Any change aimed at the wrong interval is the mistake to avoid: prefix caching does nothing for R5, which started on time.

Try a different case

A reasoning model logs R7: arrived 230.0, started 230.1, first token 230.5, first visible word 246.5, last token 252.5, 1,101 output tokens of which the first 800 were hidden reasoning, stop “end”. How long did the user wait to see anything, which interval caused it, how does the server's time to first token mislead here, and what share of the billed output did the user never see?

Check this one too
  • The user saw nothing for 16.5 seconds, from 230.0 to 246.5. Queue (0.1) and prefill (0.4) were normal, so the server's time to first token is 0.5 seconds and looks healthy.
  • The wait is decode: 800 hidden tokens at the usual 20 milliseconds each take 16.0 seconds before the first visible word. The stream was not slow; 22.0 seconds for the 1,100 tokens after the first is 20 milliseconds per token.
  • All 1,101 tokens are billed as output, and 800 of them, about 73 percent, were reasoning the user never saw.

One change to try: ask the model for a short visible preamble before it reasons, which OpenAI suggests for a faster first visible token, or use less reasoning where the task allows. Time the first visible word, not only the first token.

Where this sits: the measures come from Time to first token and the long read's Before and after the first token.