teacher
Sign in

Serving and Cost

Understand where LLM latency and money go (prefill, decode, KV cache, batching) and the levers that cut both, with back-of-the-envelope maths.

40 min5 interactive

Two numbers to track

For every request there are two costs: time and money. Both come from tokens (the pieces of text a model reads and writes; see the tokenization lesson).

MetricMeaningWho feels it
TTFTTime to first token: delay before the answer starts appearingEvery user, in chat
Tokens per secondSpeed of the stream after it startsUsers reading as it types
Total latencyRequest start to last tokenBatch jobs, tool calls
Cost per requestInput tokens x input price + output tokens x output priceYour budget
1 of 8