Latency Dynamics / Visual 01

AI Product
Latency Map

One streamed chat turn, followed from the browser to the GPU and back. Follow the work before the first token, then watch the answer stream back one token at a time.

GrowthVectorIllustrative simulation

On smaller screens, scroll the diagram horizontally. Pause or scrub to inspect any point in the journey.

Animated round trip of one LLM request A request leaves the browser, crosses the network, passes the gateway and the retrieval step, waits in the inference queue, is prefilled, then decoded token by token. Tokens stream back to the browser. Two rulers show where the time goes. SIMULATED CLOCK 0 ms Request leaves the browser TOKENS ON SCREEN 0 / 400 FIRST TOKEN SEEN — 1 Browser 2 Network 3 Gateway 4 App · RAG 5 Inference server request → user prompt renders each chunk Edge · WAF TLS already warm Illustrative network delay Sydney → US-West ≈ 80 ms each way Auth · quota input guardrail 60 ms Orchestrator builds the prompt Embed Vectors Rerank 80 40 150 ms Each agent step repeats this loop and the trip to 5 Queue 80 ms Prefill · 6,000 tokens parallel prompt processing 1 column ≈ 500 input tokens 400 ms 1 pass Decode bandwidth-bound 16.7 ms / token KV cache 0 tokens Compute speed sets prefill · memory bandwidth sets decode output guardrail 6 Return path · tokens stream back over SSE, ≈ 80 ms to the browser query TO FIRST TOKEN · 0–970 ms WHOLE REQUEST · 0–7.7 s
Illustrative, not measured: a Sydney browser calling a US-hosted model, a warm connection, retrieval before generation, 6,000 input tokens with no cache hit, 400 output tokens at 60 tokens/s. Playback is slowed about 7× before the first token and sped up during decode; the clock shows simulated time. The final 80 ms represents stream finalisation after the last token arrives.
Three clocks

Each factor slows one of three things

Time to first token970 ms

How long the screen stays empty. Everything up to and including prefill, plus the trip back.

Time per output token16.7 ms

Streaming speed once text appears. Set by memory bandwidth and the bytes read per token.

End to end7.7 s

Total request time. In this example decode is about 86% of it, so output length is the biggest lever.

E2E = network + gateway + retrieval + queue + prefill + (Nout − 1) × time per token + return path + finalisation
Factors by hop

What adds time, and where

1

Browser

Connection reuse TTFT
A new client per request pays DNS, TCP and TLS every time. Keep-alive pools and HTTP/2 remove that.
Streaming on or off TTFT
Without streaming, the first visible output may arrive only after the full response is ready. The model still has its own time to first token.
Render cost PER TOKEN
Re-parsing the whole markdown buffer on every chunk slows long answers.
2

Network

Distance TTFTE2E
Light in fibre covers about 200 km per ms. Each round trip from Sydney to a US region costs well over 100 ms before any compute.
Handshakes TTFT
A cold TCP + TLS 1.3 connection costs 2 round trips; resumption or QUIC brings that to 0–1.
Proxies and WAFs E2E
Each inspection hop adds time, and some buffer the stream.
3

Gateway

Auth and quotas TTFT
Small, unless the token or quota store sits in another region.
Input guardrails TTFT
A moderation or PII model runs in series, adding a second model call before the real one.
Rate-limit retries E2E
Backoff after a 429 response dominates tail latency.
4

App · RAG

Retrieval chain TTFT
Embed, search and rerank all finish before the prompt exists. Rerankers are often the slowest step.
Agent steps E2E
Every tool call is another full trip through hop 5. Run independent calls in parallel.
Prompt size TTFT
Retrieved chunks and history all become input tokens that prefill must read.
Format retries E2E
Re-asking after invalid JSON doubles the request. Constrained output avoids it.
5

Inference server

Queue TTFT
Wait for a batch slot. Varies with load, time of day and service tier.
Prefill TTFT
Compute-bound; grows with input length. A prefix-cache hit skips most of it.
Decode PER TOKEN
Each token reads the active weights from memory: speed ≈ bandwidth ÷ bytes per token. Model size, MoE active parameters and quantization set it.
Batching and KV cache PER TOKEN
Bigger batches raise server throughput and cut each user's speed. A growing KV cache adds reads every step.
Reasoning and output length E2E
Hidden thinking tokens and long answers are all decode time.

Local hardware example: Strix Halo with gpt-oss-120b, prefill 524 tokens/s and decode 33 tokens/s. Results depend on the model configuration and workload.

6

Return path

Proxy buffering TTFT
A proxy or serverless runtime that buffers the response turns the stream into one late block.
Output guardrails PER TOKEN
Holding back a window of tokens for checks adds a fixed delay and makes delivery bursty.
Chunk size PER TOKEN
Per-token events cost framing; large chunks look jerky.
Levers

What to change first, by typical payoff

  1. Generate fewer tokensShorter outputs, max_tokens, lower reasoning effort. Cuts end-to-end time linearly.
  2. Cache the prefixStable system prompt, tools and documents first; changing content last.
  3. Remove serial round tripsParallel tool calls, merged LLM calls, retrieval while the user types.
  4. Right-size each modelA small model for routing and classification; fewer bytes per token decode faster.
  5. Move compute closerAn in-region endpoint removes distance from every hop.
  6. Check the stream end to endNo proxy buffering, warm connections, incremental rendering.
Sources
Pope et al., Efficiently Scaling Transformer Inference, arXiv, 2022-11-09 Kwon et al., PagedAttention / vLLM, arXiv, 2023-09-12 Agrawal et al., Sarathi-Serve, arXiv, 2024-03-04 Zhong et al., DistServe, arXiv, 2024-01-18 Leviathan et al., Speculative Decoding, arXiv, 2022-11-30 OpenAI, gpt-oss-120b & gpt-oss-20b Model Card, arXiv, 2025-08 Anthropic, Prompt caching documentation