Reducing Cost and Latency on Amazon Bedrock
This lesson explains the Amazon Bedrock features that cut cost or latency without changing the application much. Generative AI costs scale with tokens, users notice slow responses, and questions ask which feature fits a described workload.
Learning outcomes
After completing this lesson, you will be able to:
- Choose a Bedrock feature, such as prompt caching or batch inference, that fits a workload.
- Identify ways to reduce the number of tokens processed.
Features and when to use them
Bedrock offers several ways to lower cost and latency. The simplest is choosing a smaller model, which is cheaper per token and faster, and is often good enough for simple tasks such as classification and extraction. Prompt caching reuses the processed part of a prompt that repeats across requests, such as a long system prompt or a document queried many times, at a much lower token price and latency. Intelligent prompt routing sends each prompt to a smaller or larger model in a family, depending on how difficult it is predicted to be.
Batch inference processes large sets of prompts asynchronously at a lower price, for jobs that can wait. Model distillation trains a smaller model on a larger model's answers, giving close to large-model quality at small-model cost for high-volume tasks. Cross-Region inference routes requests across Regions within a geography for more throughput during spikes. Provisioned Throughput reserves capacity at a fixed hourly price for steady high volume. The following table summarises the features.
| Feature | What it does | Best for |
|---|---|---|
| Choosing a smaller model | Lower price per token and faster responses | Simple tasks such as classification and extraction |
| Prompt caching | Reuses the processed part of a prompt that repeats across requests, at a much lower token price and latency | Long system prompts or the same document queried many times |
| Intelligent prompt routing | Sends each prompt to a smaller or larger model in a family depending on predicted difficulty | Mixed workloads of easy and hard requests |
| Batch inference | Processes large sets of prompts asynchronously at a lower price than on-demand | Offline jobs such as summarising a document archive |
| Model distillation | Trains a smaller student model on a larger teacher model's answers | High-volume tasks needing near-large-model quality at small-model cost |
| Cross-Region inference | Routes requests across Regions in a geography for higher throughput | Traffic spikes and throttling |
| Provisioned Throughput | Reserved model capacity at a fixed hourly price | Steady high volume, and serving many custom models |
Cutting cost and latency
Also reduce tokens
In addition to the options in the table above, the number of tokens processed can be reduced directly. The following list describes the principal measures.
- Keep prompts concise and remove unnecessary examples.
- Set max tokens to cap output length.
- In RAG, retrieve fewer, more relevant chunks.
- Cache or reuse answers to repeated questions in the application.
Fewer tokens
A legal team uploads a 200-page contract and asks dozens of questions about it in each session. Every request resends the whole contract. How can the company reduce cost and latency with minimal changes?
Enable prompt caching for the contract portion of the prompt, so later questions reuse the cached tokens at a lower price and faster. Batch inference would not suit interactive questions.
What does prompt caching save?
Show answer
Reprocessing a long prompt prefix that repeats, such as a system prompt or a document, which lowers the cost and latency of later requests.
Exam Tips
Remember for the exam
- Smaller models are cheaper and faster for simple tasks.
- Prompt caching cuts cost and latency for repeated prompt prefixes.
- Intelligent prompt routing picks a model size per request.
- Batch inference is cheaper for offline, non-interactive workloads.
- Distillation transfers a large model's quality to a smaller model.
- Provisioned Throughput reserves capacity for steady, high-volume use.