What you'll learn: By the end of this lesson you will be able to turn "make it faster" into a target with a price, show with a small piece of arithmetic how the utilization you run at trades cost against tail latency, compare the common levers (headroom, caching, pricing models, storage tiers, redundancy, hedging) by who pays for each, choose the cheapest option that meets a stated target, and verify that a saving did not quietly spend your resilience.
A courier company can promise next-hour or next-day delivery. Next-hour means riders waiting idle between jobs; next-day lets one rider chain many stops with no slack. Neither is wrong. They are two points on one curve, and a good manager knows which point each customer is paying for.
Back-end systems sit on the same curve. Every millisecond you shave and every nine you add is bought with servers, memory, engineering time or risk. This lesson reads that curve with numbers instead of instinct. It builds on the trade-off analysis lesson, which says cost is a quality like any other, and on the capacity and cost lesson, which gives the forecasting method. The capacity planning, cost optimisation and tail latency lessons in the same module go deeper and are not repeated here.
Verified on 2026-12-02 against the Google SRE book, the AWS Well-Architected cost pillar, the Amazon DynamoDB and S3 documentation and the Kubernetes documentation. Every price and quantity in the examples is an illustrative cost unit. No code was run for this page.
The core idea
Performance is not a property you maximise. It is a target you buy, and the price rises faster than the benefit. The useful question is never "how fast can it be?" but "what does the next increment cost, who pays, and what does it earn?" The Google SRE book states the same shape for reliability: an incremental improvement "may cost 100x more than the previous increment", so a service should be "reliable enough, but no more reliable than it needs to be". The AWS cost pillar's goal is "the best ratio between cost and business value", not the lowest bill.
Three illustrations run through the lesson, each labelled:
- Minimal example: the same traffic served at three utilization levels, with cost and p99 side by side.
- Realistic example: ShopStream's browse path before a promotion, with a cache that cuts the bill.
- Failure example: the cache disappears and the saving turns into an outage.
Cost is a curve with three payers
A speed-up is paid for in at least three currencies, and a proposal that only counts one of them is incomplete.
- The infrastructure bill: more instances, memory, replicas, commitments and data transfer.
- The team: invalidation rules, runbooks, a new component to upgrade and be paged for.
- Risk: less headroom, more coupling, a failure mode that did not exist before.
The AWS cost pillar warns about "data transfer costs that are easy to miss until they show up on the bill". The SRE book names opportunity cost, the cost of allocating engineering resources to risk reduction instead of user-facing features. The third payer is the subject of the failure example below.
percentile, rate, window"] --> B["Measure the cost of one
unit of work today"] B --> C["List levers that could
meet the target"] C --> D["Price each lever on the bill,
the team and the risk"] D --> E["Choose the cheapest lever
that meets the target with margin"] E --> F["Verify on the metric and on the bill"] F --> G{"Demand or price changed?"} G -->|yes| B G -->|no| H["Keep the choice, review on a schedule"]
Figure 1. Pricing a performance target. How to read this: start from a target written as a number, not a feeling. The loop closes at the bottom because both demand and prices drift, so a choice that was cheapest last quarter has to be re-checked.
Utilization: the lever that moves both curves
The biggest single dial is how busy you let your servers get. Idle capacity is waste, and capacity that is never idle has nowhere to put a burst. The latency and throughput lesson shows why latency climbs as a server fills up; here is the same effect priced.
Minimal example (all numbers illustrative). ShopStream's browse path must serve 2,300 requests per second at peak (the shared peak figure for the running project). One instance can do 200 requests per second at full load, and one instance costs 1 cost unit per hour. For a 20 ms job, the simple one-queue model from the latency lesson gives a mean time in the system of 20 ms / (1 - utilization) and a p99 of about 4.6 times that. It is a shape, not a prediction.
| Target utilization at peak | Instances needed | Cost per hour | Model mean | Model p99 |
|---|---|---|---|---|
| 40 percent | 2,300 / (200 x 0.4) = 28.75, so 29 | 29 | about 33 ms | about 150 ms |
| 60 percent | 2,300 / (200 x 0.6) = 19.2, so 20 | 20 | 50 ms | about 230 ms |
| 80 percent | 2,300 / (200 x 0.8) = 14.4, so 15 | 15 | 100 ms | about 460 ms |
Going from 40 to 80 percent cuts the bill by 14 of 29 units, about 48 percent. It also triples the model's p99. If the target is a p99 under 300 ms (illustrative), the cheapest row that meets it is 60 percent, at 20 units. The 80 percent row saves 5 units an hour and misses the target by a wide margin. Whether 5 units an hour are worth the miss is now a business question with numbers behind it.
The row you choose is also a risk statement. At 80 percent a 25 percent traffic jump reaches full capacity; at 60 percent it lands at 75 percent. The Little's law and tail latency lessons in this module go deeper on the curve.
The Tail at Scale authors close by saying that tail-tolerant techniques "make it possible to achieve higher system utilization without sacrificing service responsiveness", which is why the tail latency lesson matters to this one: every technique that shortens the tail moves the utilization row you can afford.
Kubernetes shows where the dial lives in practice. The scheduler uses a container's resource request to decide which node to place it on, and a CPU limit is enforced by throttling, so a limit set tight to save money can add latency without adding any error. Both are cost settings that behave as performance settings.
The levers and what each one really costs
Most "make it faster" proposals are one of a handful of levers.
| Lever | Buys | Bill | Team | Risk |
|---|---|---|---|---|
| Headroom (lower utilization) | Lower tail latency, burst absorption | Linear in instances | Almost none | Low |
| A cache | Fewer expensive requests per user request | Memory, a cluster | Invalidation, stale data rules | A cold or failed cache moves all load to the origin |
| More replicas and redundancy | Availability, read capacity | Each copy costs as much as the first | Failover runbooks | Correlated failures if copies share a cause |
| A different pricing model | Lower unit price for a known pattern | Commitment or capacity decisions | Forecasting | Paying for capacity you do not use |
| A storage tier | Lower price per stored gigabyte | Retrieval fees, minimum durations | Lifecycle rules | Slow or fee-heavy access to the data you did need |
| Hedged calls | A shorter tail | A few percent more calls | Idempotency rules | Extra load when a dependency is already slow |
Three of these have official documentation that makes the trade explicit.
Pricing models. DynamoDB offers on-demand and provisioned throughput. On-demand is "pay-per-request" and removes capacity planning; in provisioned mode you are "charged based on the hourly read and write capacity you have provisioned, not how much of that provisioned capacity you actually consumed", and the documentation recommends it for "steady workloads with predictable growth". The trade: predictability if you forecast well, idle paid capacity if you forecast badly.
Storage tiers. S3's infrequent-access classes keep millisecond access but charge a per-gigabyte retrieval fee and, for Standard-IA, a 30-day minimum storage duration; the Glacier Flexible Retrieval and Deep Archive classes are "not available for real-time access", with retrieval times of minutes to hours. S3 One Zone-IA is cheaper than Standard-IA because it keeps data in one Availability Zone, which makes it "less available and less resilient". The cheapest tier for rarely read data is the dearest one for data you suddenly need.
Hedging. A hedged request sends a second copy of a slow call and keeps the first answer. In the Tail at Scale paper, hedging after the 95th percentile "limits the additional load to approximately 5%" while "substantially shortening the latency tail". gRPC exposes it with a maxAttempts capped at 5 and a token throttle that cancels hedges when too many calls fail. The cost is real extra traffic, and it only works when slowness is not tied to the request itself.
and its failure mode"] Q2 -->|no| Q3{"Steady, forecastable load?"} Q3 -->|yes| R2["Price a commitment
or provisioned capacity"] Q3 -->|no| Q4{"Slow tail from a
fan-out of calls?"} Q4 -->|yes| R3["Price hedging
or a call deadline"] Q4 -->|no| R4["Add headroom:
the simplest lever"]
Figure 2. A first-pass lever choice. How to read this: ask the questions in order and price whatever you land on, including its failure mode. The tree gives candidates; the arithmetic decides.
Redundancy is a cost with diminishing returns
Availability is the lever with the steepest price. Each extra copy costs what the first did, and the SRE book lists "the cost of redundant machine/compute resources" among the costs of reliability. Its worked example: at one million dollars of revenue, moving from 99.9 to 99.99 percent is worth about 900 dollars, so spending more than that on the extra nine loses money. Put a number on what an extra nine saves before you buy it. See the availability, reliability and durability lesson for what the nines mean.
The other side of this topic
The front-end track asks the same question from the visitor's side: who pays for a faster page (your bill, your team, or the visitor's phone). It is covered in performance and cost trade-offs in front-end systems. The two ledgers meet at the edge: a response cached at the CDN costs you less to serve and costs the visitor less waiting.
In practice: ShopStream's browse path before a promotion
This is the realistic example, an educational scenario on the course's running example ShopStream; nothing in it describes a real company. Every number is illustrative.
This is a realistic scenario, not a case history.
The situation
A cost review asks the browse team to cut fleet cost by about a quarter. Peak traffic is 2,300 requests per second; the fleet runs 20 instances at 60 percent target utilization, a model p99 near 230 ms against a 300 ms target. A promotion starts in three weeks.
Starting architecture
Figure 3. The option under test: a cache in front of the catalogue. How to read this: the browse service reads the cache first and goes to the store only on a miss. The instance count in the figure is the proposal, not the current state of 20.
Options considered
| Option | Fleet | Cost per hour | Model p99 | Main risk |
|---|---|---|---|---|
| A. Raise target utilization to 80 percent | 15 instances | 15 | about 460 ms, misses the target | Almost no headroom for a promotion burst |
| B. Keep 60 percent, add a catalogue cache | 10 instances plus 3 cache nodes | 13 | about 230 ms, unchanged | Cache failure and stale data |
| C. Do nothing | 20 instances | 20 | about 230 ms | The review target is not met |
The arithmetic for B: assume a hit costs one fifth of a miss and the hit ratio is 60 percent. Average work per request is 0.6 x 0.2 + 0.4 x 1 = 0.52 of a miss, so an instance can do 200 / 0.52, about 385 requests per second. At 60 percent utilization 2,300 / (385 x 0.6) = 9.97, so 10 instances; plus 3 cache nodes at 1 unit each gives 13 units, a 35 percent saving against 20.
The decision
Option B, with the staleness rule written down: catalogue price and stock may be up to a stated age behind (the cache invalidation lesson covers how), and checkout always reads the source of truth. A is rejected because it buys the saving by spending the headroom the promotion needs.
Rollout and verification
Ramp the cache over a few days and watch both ledgers: hit ratio, utilization at peak, p99 and cost per thousand requests. Before the promotion, load-test with the cache cold and with it switched off; the next section shows why.
The 2 a.m. failure
The page reads: browse p99 is climbing and instance CPU is near saturation. One cache node has crashed and its replacement started empty, so the hit ratio fell towards zero. The fleet is sized for 60 percent hits. With no hits each instance carries full cost: 2,300 requests per second over 10 instances at 200 each is 115 percent of capacity.
Figure 4. How the saving fails. How to read this: the cache did not make the system slower, it made the system's capacity depend on the cache. Retries then add load to a service that is already over capacity.
First checks: hit ratio per node, instance utilization and the age of the new cache node. Mitigation: shed load with fast errors and cap retries (see load shedding and retry storms), then warm the cache gradually. The lasting fix: treat a cache as a performance feature, not capacity, unless the fleet and origin are tested without it, and add stampede protection so the refill does not hammer the store.
Trade-offs: choosing and stopping
| Choice | You gain | You pay | Wrong when |
|---|---|---|---|
| High utilization | A small bill | Tail latency and burst risk | The target is a tight p99 or load is spiky |
| Low utilization | Latency margin | A larger bill | Load is steady and the target is loose |
| Cache for cost | Fewer expensive requests | Invalidation, a new failure mode | The fleet cannot survive without it |
| Commitment or provisioned capacity | A lower unit price | Paying for unused capacity | Demand is uncertain |
| Cold storage tier | Cheap storage | Retrieval fees, delay | Access is frequent or urgent |
| One more nine | Fewer outage minutes | Redundancy, opportunity cost | The extra minutes cost the business less than the nine |
The stopping rule. Stop when the next increment costs more than the loss it removes. Write the target, the percentile and what missing it costs in the design note. If nobody can say what a missed p99 costs, the target is a preference, not a requirement.
Architect's notes
- Write the target with a percentile and a rate. "p99 under 300 ms at 2,300 requests per second" can be priced. "Fast" cannot.
- Price the failure mode, not only the happy path. A lever's cost includes what happens when it stops working.
- Cost per unit of work beats total cost. Total spend rises as the business grows; cost per thousand requests shows whether you are getting more efficient.
Common mistakes
- Optimising the mean. It hides the tail and the peak. Size for the peak and the percentile you promised.
- Cutting headroom to hit a savings target. The risk stays invisible until a burst.
- Treating a cache as free capacity. Your capacity plan now depends on it.
- Buying cold storage for data that is read. Retrieval fees and minimum durations can cost more than they save.
- Buying a nine nobody asked for. The SRE book's warning is that past a point more reliability is worse for the service and its users.
Key takeaways
- A performance target has a price, and the price rises faster than the benefit.
- Utilization is the biggest dial: it trades the bill against tail latency and burst safety, and the model above shows the trade in numbers.
- Every lever has three payers: the bill, the team and risk.
- Pricing models and storage tiers are forecasts: they save money only if the forecast is right.
- A saving that depends on a cache or a replica must be tested with that component off.
- Stop when the next increment costs more than the loss it removes.
Practice exercises
- Re-run the table (15 minutes). Using the same 2,300 requests per second and 200 per instance, compute instances and cost per hour at 50 and 70 percent utilization. At what utilization does the model p99 first exceed 300 ms for a 20 ms job?
- Price a cache (20 minutes). Change the hit ratio to 40 and 80 percent with the same hit cost of one fifth. How many instances are needed at 60 percent utilization, and what happens to the saving if the cache needs 5 nodes instead of 3?
- Cold-cache drill (20 minutes). For option B, how many instances survive a complete cache loss without shedding? Is that worth paying for, or is shedding with a fast error the better plan?
Related reading
- Trade-off analysis for backend systems
- Capacity planning and cost for system design
- Latency versus throughput
- Cache invalidation and cache stampede and hot keys
- Frontend view: performance and cost trade-offs