Cost Optimization and Performance Engineering
Cost Optimization and Performance Engineering
This domain treats cost as an engineering metric with unit economics, and performance as a design decision that usually lowers cost. Items ask you to interpret a bill, choose commitment instruments correctly, or explain why a stable workload still costs too much.
Make cost visible before optimizing
- Tag or label everything with owner, environment, cost center, and application. Untagged spend cannot be attributed or defended.
- Export billing data to a warehouse and build unit metrics: cost per request, per tenant, per order. Growth that improves unit cost is healthy; growth that worsens it is a design problem.
- Split production from non-production; sharing a project hides the real drivers.
The levers, in order
- Eliminate: idle instances, orphaned disks, unused load balancers, log retention nobody reads.
- Rightsize: use at least two weeks of utilization data; most instances run well below 40% CPU.
- Commit: savings plans, committed use discounts, or reserved instances for the steady-state baseline, typically 30โ60% below on-demand; spot or preemptible capacity for fault-tolerant batch, often 60โ90% below.
- Architect: autoscaling, serverless for spiky traffic, storage lifecycle rules, caching to cut repeat compute and database reads.
- Network: egress is the hidden line item - keep chatty service-to-service calls in-zone or in-region and use private endpoints.
Worked example
A 24/7 API runs 40 instances at $0.10/hour on-demand: 40 x 730 x 0.10 = $2,920 per month. Utilization shows 60% is steady baseline and the rest is a daily peak. Commit 24 instances for one year at roughly 40% off: 24 x 730 x 0.06 = about $1,051. Run the remaining 16 in an autoscaling group averaging 10 on-demand instances: 10 x 730 x 0.10 = $730. New total about $1,781 - a 39% reduction with no loss of peak capacity.
Traps that cost marks
- Committing to the current footprint before rightsizing, locking in waste for one to three years.
- Optimizing compute while ignoring egress, storage retrieval, and managed-service tiers.
- Removing the redundancy your SLO depends on to hit a savings target.
- Treating caching as free - stale data and cache stampedes become reliability incidents.