Reducing Time to First Token and Total Latency
This lesson covers the main latency techniques for generative AI applications, whose latency users perceive in two parts, how long until the first words appear and how long until the answer is complete, each with different causes and remedies.
Learning outcomes
After completing this lesson, you will be able to:
- Measure time to first token, output speed and total latency.
- Reduce latency through model and serving choices.
- Apply architectural techniques such as pre-computation and streaming.
Measuring latency correctly
Latency in generative AI applications has three components, and improving the wrong one wastes effort. Time to first token (TTFT) is the delay before the first token of the response arrives; it depends on queueing, on the time to process the input, which grows with prompt length, and on network hops. Output speed, measured in tokens per second, depends on the model and the infrastructure serving it. Total latency is roughly TTFT plus the number of output tokens divided by the output speed.
For chat interfaces with streaming, TTFT determines how responsive the application feels; for forms and back-end processing, total latency matters. Performance benchmarking measures all three with representative prompts at realistic percentiles, such as p50, p90 and p99, before and after every change, because averages hide the slowest requests, which are the ones users complain about.
The following diagram shows the parts of one request's latency.

Breaking down latency
Model and infrastructure choices
The choice of model and serving option has the largest effect on latency. Smaller models generate tokens faster and process prompts more quickly. Latency-optimized inference in Amazon Bedrock, enabled for supported models and Regions by setting performanceConfig to optimized, runs requests on infrastructure tuned for lower latency at a higher price, which suits time-sensitive applications such as real-time agents and voice assistants.
Other options address specific causes. The Priority service tier gives requests preferential processing during busy periods, which reduces queueing delays. Prompt caching reduces TTFT when long prompt prefixes, such as instructions or reference documents, repeat across requests. Deploying the application in a Region close to its users reduces network latency. The following example enables latency-optimized inference.
r = brt.converse(
modelId="us.amazon.nova-pro-v1:0",
messages=messages,
performanceConfig={"latency": "optimized"}, # supported models and Regions only
)Latency options
Architectural techniques
Pre-computation generates answers to predictable requests in advance (product summaries, daily briefings, FAQ answers) with batch inference and serves them from storage instantly. Parallel requests run independent sub-tasks concurrently, for example retrieving from two knowledge bases at once or analysing sections of a document in a Step Functions Parallel or Map state, so latency equals the slowest branch. Streaming cuts perceived latency to TTFT. Shorter outputs reduce total time because output tokens are generated sequentially. Avoiding unnecessary sequential calls, such as a separate rewriting step for simple queries, also helps. The following table summarises the trade-offs.
| Technique | Improves | Trade-off |
|---|---|---|
| Smaller model | TTFT and output speed | Possible quality loss |
| Latency-optimized inference | Speed on supported models | Higher price; limited availability |
| Priority tier | Consistency under load | Premium price |
| Pre-computation | Instant answers for predictable queries | Storage; staleness |
| Parallel calls | Total time of multi-part tasks | Concurrency and quota use |
| Streaming | Perceived latency | Client complexity |
| Shorter outputs | Total time and cost | Less detail |
The following diagram compares when a voice assistant starts speaking before and after changes to cut its latency.

Latency techniques
A voice assistant
A voice assistant must start speaking within one second. It currently waits for a full response from a large model, which takes four seconds.
Streaming the response into text-to-speech as tokens arrive, enabling latency-optimized inference for a supported model (or choosing a smaller model), keeping answers short for voice, and caching the long system prompt bring the time to first audio under one second. Benchmarks at p90 confirm the target.
Which latency measures should be tracked, and at which percentiles?
Show answer
Time to first token, output speed and total latency, at p90 and p99.
Exam Tips
Remember for the exam
- Measure TTFT, output speed and total latency at p90 and p99.
- Time-sensitive apps on supported models: latency-optimized inference.
- Predictable queries: pre-compute with batch inference.
- Independent sub-tasks: run in parallel; stream to cut perceived latency.