Topic 208 / Core
Cost optimization and FinOps
Chapter 12.7 · Cost as an Engineering Quantity
What and why
Every mechanism this book has covered for scaling and reliability — more instances, more replicas, more redundancy — costs money, and that cost doesn't manage itself. This topic treats cost as a non-functional requirement, on equal footing with availability or latency, with its own measured indicators and its own set of levers: rightsizing, autoscaling, spot/preemptible capacity, storage tiering, and egress awareness. FinOps is the practice of making that cost visible and attributable, not just paid. Builds on: → 95 (auto scaling — the main mechanism this topic turns into a deliberate cost lever).
Diagram
| Lever | Mechanism | Trade-off |
|---|---|---|
| Rightsizing | match provisioned capacity to measured load (→ 102) | risk of under-provisioning if load grows |
| Autoscaling (→ 95) | shrink idle capacity automatically | reaction lag at a sudden spike |
| Spot / preemptible capacity | cheaper, interruptible instances for batch/async work | the workload must tolerate being killed mid-run |
| Storage tiering and retention (→ 81) | move cold data to cheaper storage, delete what's past its retention | retrieval cost/latency if "cold" was wrong |
| Egress awareness | account for network-transfer cost explicitly | often invisible until the bill arrives |
How it works
- Make cost visible per team and per service through tagging — cost nobody can attribute to an owner is cost nobody is incentivized to fix.
- Compute unit economics: cost per request, cost per user — a falling total bill on rising traffic can still mean unit cost is getting worse, and the reverse.
- Rightsize provisioned capacity to measured load (→ 102), not to the worst peak that's ever happened once.
- Pair rightsizing with autoscaling (→ 95) so idle capacity actually shrinks automatically during low-traffic periods instead of sitting paid-for and unused.
- Move interruptible, resumable work (batch jobs, async processing) onto spot or preemptible capacity, priced lower in exchange for the provider being able to reclaim it.
- Tier and retain storage (→ 81) by real access pattern — hot data on fast, expensive storage; cold, rarely-read data on cheaper tiers; delete what's past its retention policy entirely.
- Track egress (data leaving the network) explicitly — it's billed separately from compute and storage and is easy to miss until it's already large.
- Make the performance-versus-cost trade-off an explicit, written decision — this is method step 21 in every project's design process, not an afterthought once the bill arrives.
Practical example
(exact arithmetic, illustrative unit cost). A service runs 10 instances at $1/instance-hour, sized for a peak that occurs 2 hours/day; the rest of the day it runs at roughly 20% of peak load. Fixed provisioning: 10 instances × 24 hours = 240 instance-hours/day → $240/day. Rightsized with autoscaling — 2 instances for the 22 off-peak hours, 10 instances for the 2 peak hours: (2 × 22) + (10 × 2) = 44 + 20 = 64 instance-hours/day → $64/day. Savings = (240 − 64) ÷ 240 ≈ 73.3% — $176/day removed from the bill with no change to peak capacity or user-facing performance.
When to use it
- Use continuous cost review once a system carries real, sustained traffic and a real bill — tagging, unit economics, and the levers above all pay for themselves at that point.
- Avoid chasing micro-savings on an early-stage system still being figured out — engineering time is the scarcer resource there, and premature rightsizing can slow iteration for a bill that's still small in absolute terms.
- Failure scenarios: rightsizing based on average load alone, ignoring the real burst pattern (→ 102), causing throttling at the very next spike; moving a latency-sensitive, user-facing workload onto spot/preemptible capacity and getting preempted mid-request; storage tiered to "cold" that's actually read often enough that retrieval costs exceed whatever the tiering saved; no per-team cost visibility, so an obviously wasteful job keeps running because nobody is accountable for its bill.
- Simpler alternative: for a small system with a small, easily-reviewed bill, a monthly manual review of the top cost line items may be the entire FinOps practice needed — automated tagging and unit-economics dashboards earn their cost once the bill is large or the team is large enough that nobody can eyeball it anymore.
Practice
(process kind — compute unit cost, then recompute after one change; 20 min). A service runs 10 instances at $1/instance-hour, all day, every day, and serves 2,000,000 requests/day. Compute its current cost per request. Then, using the practical example's rightsizing-plus-autoscaling numbers (64 instance-hours/day instead of 240), recompute the new cost per request at the same request volume, and state the percentage drop. Done when both unit-cost figures are computed exactly, not estimated, and the percentage drop matches the instance-hour savings percentage.
Key takeaway
Cost is a non-functional requirement with its own measured indicator — cost per request — and rightsizing plus autoscaling, spot capacity, storage tiering, and egress awareness are the standard levers for moving it, always weighed explicitly against performance. Done when you can: compute a service's cost per request, apply one lever, and recompute the new figure and its percentage improvement. Used next in → 211 (multi-tenant architecture: tenant isolation models, quotas, noisy neighbors — the same cost-attribution problem at the granularity of one tenant).
References
AWS Well-Architected Framework — see references.md.