The two latencies that matter

Lesson 2 of 28 · Follow the request · 3 min · Free Watch this lesson free

Maya opens her dashboard to look into Dan's complaint, and it says the assistant averages four seconds a request. That's fine, isn't it? Dan, though, wrote that the chat froze for ages and then started typing like nothing had happened.

Another customer says something else: the words showed up quickly, then crawled. So who's right? They both are, because that one average of four seconds is hiding two very different waits.

The first wait

Dan hit the first one, the time to first token. It's the pause between pressing send and seeing the first word, and it's where he sat staring at a blank chat box.

The request may wait in a queue behind other people's questions, and then the model has to read the whole prompt before it can write a word. A long prompt or a busy server stretches both.

Maya checks Dan's chat. It carried a long history, so there was a lot to read, and the server was busy that minute. That's his blank box, and it has nothing to do with how fast the words come out.

The gap between words

The other customer hit the second one, the gap between one word and the next. It sets how fast the answer streams, and it mostly depends on how many other chats are sharing the GPU right then.

Add them up

Add the two up and you get the whole wait: the first pause, plus the number of tokens in the answer times the gap between them. A long answer on a crowded GPU is slow even when the first word shows up fast.

Measure it

So how does Maya see both? Her model server, vLLM, publishes each wait as a histogram, which is just a count of requests by how long they took. There's one for time to first token and another for the whole request.

And she reads a percentile, never the average, because a few slow chats are exactly what Dan remembers. The average buried his ten seconds inside thousands of quick answers.

Here's the query for the ninety fifth percentile of time to first token over five minutes. It asks how long the slowest chat in twenty waited, and you'd put it on a graph before you change anything.

Two targets

So Maya sets two targets, not one. For a chat assistant the first word matters most, so when that wait climbs she knows she's short of capacity or the prompts have grown. A batch job that summarises overnight barely cares about it.

Next time someone says the assistant feels broken, ask which wait they mean: the blank box at the start, or the crawl after it. And next, we'll open up the stack and see where each wait comes from.

This is the narration of a video lesson from Run AI in production on Kubernetes. In the video it is animated, and you can pause it to ask a question.