Cloud Cost Engineering: Unit Economics, Pricing Models and the Hidden Bills


System Design Phase 14: Infrastructure & Delivery
Applied Lesson 82 of 86 17 min read Updated Nov 30, 2026

The finance team forwards a chart: the AWS bill went from 78,000 USD to 125,000 USD in four months while traffic grew 15%. Nobody launched anything big. The engineering leads each say their service is “about the same”. When someone finally groups the bill by usage type, the top new line items are not instances at all: 9,000 USD of NAT gateway data processing, 6,000 USD of cross-AZ transfer and 20,000 USD of log ingestion, from a debug flag that was turned on during an incident and never turned off.

That is the typical shape of cloud overspend. It is rarely one big mistake. It is many architectural decisions that each looked free, multiplied by traffic, billed per GB, and visible only if someone owns the number.

Cost engineering treats money as a design constraint like latency or availability: you measure it per unit of work, you know which mechanisms drive it, and you change architecture, not just discounts, to move it.

What it is

Cloud cost engineering is the practice of designing, operating and reviewing systems so that cost per unit of business value stays under control as the system grows. FinOps is the organisational side: shared visibility, ownership and decision-making about cloud spend between engineering, finance and product.

The central metric is unit cost: dollars per request, per active user, per tenant, per GB stored, per order processed. Total spend going up is fine if revenue and usage go up faster. Unit cost going up is the signal that something in the design has stopped scaling efficiently.

cost per 1M requests = monthly cost of the service / (monthly requests / 1,000,000)
cost per tenant      = direct tagged cost + share of shared platform cost by usage
gross margin impact  = unit cost / revenue per unit

How it works

Where the money goes

A typical web product’s bill breaks down roughly like this. Your split will differ, which is exactly why you measure it.

pie showData
title Illustrative monthly bill in thousand USD
"Compute (VMs, containers)" : 55
"Managed databases" : 15
"Internet egress" : 11
"NAT and cross-AZ transfer" : 15
"Object storage" : 9
"Logs and metrics" : 20

The big drivers, and the mechanism behind each:

  • Compute: billed per instance-hour or per vCPU and GB-second. Waste comes from idle capacity: oversized instances, fleets sized for peak running 24 hours a day, dev environments left on at night.
  • Storage: billed per GB-month, plus per request and per retrieval. Waste comes from data nobody reads kept in the hottest tier, orphaned snapshots and volumes, and unbounded retention.
  • Data transfer: billed per GB when bytes leave the cloud (internet egress), cross regions, or cross availability zones, and per GB through NAT gateways and some load balancers. Transfer is the line item architects most often forget, because it does not show up on a diagram.
  • Managed service premiums: a managed database, queue or search cluster costs more than the raw instances underneath. That premium is usually worth it for operations, but it compounds when the service is oversized or used as a cache.
  • Observability: logs billed per GB ingested and stored, metrics per time series, traces per span. Bills grow with traffic times verbosity times cardinality, and nobody’s service owns them by default.

Pricing models

Model Discount vs on-demand Commitment Best for
On-demand None None Spiky, new or short-lived workloads
Savings Plans (AWS) Up to about 66% (Compute) or 72% (EC2 Instance) 1 or 3 years of USD per hour spend Steady baseline compute, flexible across instance families
Reserved Instances, committed use discounts Similar range 1 or 3 years for a specific resource or spend Databases, steady specific capacity
Spot, preemptible, Spot VMs Up to about 90% None, can be reclaimed Stateless, fault-tolerant, batch, CI

AWS also added Database Savings Plans in December 2025, covering Aurora, RDS, DynamoDB, ElastiCache and other database services, with smaller discounts than compute plans. Discounts and terms change; check the current pricing pages before committing.

The commitment rule of thumb: commit to the floor, not the average. Look at the lowest sustained hourly usage over the last few months, commit to about 70 to 80% of that, and let on-demand and Spot cover the rest. Over-committing turns a discount into a bill for capacity you do not use.

Spot needs interruption handling. On AWS you get a two-minute interruption notice, often preceded by a rebalance recommendation. Design for it: diversify across many instance types and AZs, checkpoint long jobs, drain connections on the notice, keep a stateful or latency-critical baseline on on-demand or committed capacity, and use capacity-rebalancing features in your autoscaler or Karpenter-style provisioner. Containers and Kubernetes make this much easier because pods move between nodes freely.

Rightsizing and ARM

Rightsizing means matching instance size to measured demand. Look at p95 CPU and memory over two to four weeks, not averages, and leave headroom. The headroom matters because latency rises sharply as utilisation approaches 100%: drag the slider and watch the wait time.

Why busy servers get slow

Push utilisation from 70% to 90%, then to 99%, and watch the latency multiplier.

M/M/1 model: random (Poisson) arrivals, exponential service times, one server. Mean time in system T = S / (1 − ρ). Real traffic with burstier arrivals degrades even faster.

A fleet averaging 15% CPU can usually drop one instance size (half the cost) and run at 30 to 40%, still well left of the knee. Pushing to 85% saves a bit more and costs you your p99. Memory-bound services are different: rightsize on memory, and consider memory-optimised families instead of buying CPU you do not need.

ARM instances (AWS Graviton, Google Axion, Azure Cobalt) typically list 10 to 20% cheaper per hour than comparable x86 instances, and AWS claims up to 40% better price performance for Graviton on suitable workloads. Most interpreted and JVM languages, Go and Rust move with a rebuild of the container image for arm64. Native dependencies and vendor agents are the usual blockers. Measure on your own workload before migrating the fleet.

Autoscaling to cut idle

Traffic with a daily cycle that peaks at 3x the trough wastes about half its compute if the fleet is sized for peak all day. Autoscaling on a load signal (requests per target, queue depth, CPU) tracks the curve. Add scheduled scale-down for non-production environments: turning dev and staging off for 12 hours on weekdays and all weekend removes about 64% of their hours (108 of 168 hours off). Serverless and scale-to-zero platforms remove idle cost entirely for low-traffic services, at a higher price per unit of work; see serverless trade-offs for where the crossover sits.

Storage tiering and lifecycle

Object stores offer tiers that trade storage price for access price and latency. Approximate AWS S3 list prices in us-east-1 per GB-month: Standard about 0.023 USD, Standard-IA about 0.0125, Glacier Instant Retrieval about 0.004, Deep Archive about 0.001. Colder tiers add retrieval fees, minimum storage durations (30 to 180 days) and per-object minimum billable sizes, so tiering millions of tiny objects can cost more than it saves. Intelligent-Tiering moves objects automatically for a small per-object monitoring fee. Lifecycle rules should also expire old versions, abort incomplete multipart uploads and delete temporary data. Block storage has its own hygiene: delete unattached volumes and old snapshots, and move to newer volume types that decouple IOPS from size. Storage types are covered in object vs block storage.

Egress architecture

Bytes are where architecture shows up on the bill. Approximate AWS list prices: internet egress starts around 0.09 USD per GB and drops with volume; cross-AZ traffic is about 0.01 USD per GB in each direction; inter-region about 0.02 USD per GB; NAT gateway processing about 0.045 USD per GB on top of any transfer charge.

flowchart LR
APP["App in private subnet"] -->|"0.045 USD per GB processed"| NAT["NAT gateway"]
NAT --> S3A["S3 / DynamoDB"]
NAT --> EXT["Third-party APIs"]
APP -->|"free"| GW["Gateway endpoint"]
GW --> S3B["S3 / DynamoDB"]
APP -->|"cheaper per GB than NAT"| IE["Interface endpoint"]
IE --> AWS["Other AWS APIs<br/>ECR, STS, SQS"]
style NAT fill:#FCEBEB,stroke:#A32D2D,color:#791F1F
style GW fill:#E1F5EE,stroke:#0F6E56,color:#085041
style IE fill:#FAEEDA,stroke:#854F0B,color:#633806

The levers:

  • VPC endpoints. Gateway endpoints for S3 and DynamoDB are free and take that traffic off the NAT gateway. Interface endpoints (PrivateLink) have an hourly and per-GB charge but are usually far cheaper than NAT for heavy flows like container image pulls from ECR.
  • Same-AZ traffic. Chatty microservices spread across three AZs pay cross-AZ transfer on most calls. Use zone-aware routing (Kubernetes topology-aware routing, service mesh locality load balancing) so calls prefer the local zone, while keeping failover to other zones. Replication between AZs for durability is worth paying for; random cross-AZ RPC is not.
  • CDN offload. Serve static and cacheable content from a CDN. On AWS, transfer from origin to CloudFront is not charged, cache hits avoid origin compute, and committed CDN pricing is often lower than raw egress. Raise the hit ratio before negotiating price.
  • Compression and payload design. Brotli or gzip on JSON typically cuts bytes by 60 to 80%. Pagination, field selection and avoiding over-fetching cut it further.
  • Region placement. Keep heavy data and the compute that reads it in the same region. Cross-region replication is a deliberate cost (see multi-region architecture), not a default.

Log and metric cost control

Observability often reaches 10 to 30% of a cloud bill once it is not managed. The controls, in order of impact:

  • Do not log success at full volume. Keep errors and slow requests at 100%, sample successful request logs (1 to 10%), and drop debug logs in production unless a dynamic flag turns them on with an expiry.
  • Tiered retention. Hot searchable logs for 7 to 14 days, then archive to object storage (cheap, queryable on demand) for compliance windows.
  • Cardinality budgets. A metric with labels for user ID or request ID creates one time series per value. A metric with 5 endpoints, 4 status classes and 50,000 user IDs is 1,000,000 series. Remove unbounded labels; put that detail in traces or logs.
  • Trace sampling. Head sampling at a low rate plus tail sampling that keeps errors and slow traces gives most of the debugging value at a fraction of the span volume. Details in logs, metrics and traces.
  • Use the OpenTelemetry Collector as a control point to filter, sample and route data before it reaches a vendor that bills per GB.

Worked example: cutting a monthly bill

Where it breaks

Optimising the wrong thing. Saving 2% on compute while a log pipeline grows 10% a month. Always sort by line item and by growth rate first.

Commitments as a trap. A 3-year commitment bought before a migration to containers, ARM or a different region strands spend. Prefer flexible plans, shorter terms while the architecture is moving, and layered purchases (buy a slice every quarter) over one large purchase.

Spot used for the wrong workload. A single-replica stateful service on Spot will be interrupted at the worst time. Spot is for capacity you can lose without user impact.

Cutting reliability to save money. Removing the standby region, dropping replicas to one AZ, or shortening backup retention looks like savings until the incident. Price the risk explicitly, using the RTO and RPO from backups and disaster recovery, and make it a business decision.

Cold tiers with hot access. Moving data to an archive tier and then reading it often produces retrieval fees larger than the storage saved. Tier on measured access patterns.

Untagged and shared costs. If 40% of spend is “shared platform” with no allocation, nobody owns it and nobody optimises it. Kubernetes clusters are the classic case: the bill shows nodes, not teams.

Hidden per-request pricing. Managed services billed per request (API gateways, serverless functions, queues, key management calls, object store GETs) can dwarf compute when a hot loop calls them millions of times. Batch and cache.

Real-world systems

  • Cost visibility tools: AWS Cost Explorer, Cost and Usage Reports and Data Exports, AWS Budgets and Cost Anomaly Detection, AWS Compute Optimizer for rightsizing; Google Cloud billing export to BigQuery and recommenders; Azure Cost Management and Advisor.
  • FOCUS (FinOps Open Cost and Usage Specification): an open schema for billing data maintained under the FinOps Foundation, with exports available from the major clouds, so cost data from several providers and SaaS vendors can be joined in one model.
  • Kubernetes cost allocation: OpenCost (a CNCF project) and Kubecost split node costs to namespaces, workloads and labels.
  • Provisioning for cost: Karpenter provisions right-sized nodes and mixes Spot and on-demand with consolidation of under-used nodes.
  • Public write-ups: several companies have published detailed accounts of large savings from moving workloads off or between clouds; the generalisable lesson is the method (measure, attribute, change architecture), not any specific number.

How to apply it

Run cost like reliability: instrument, own, set targets, review.

  1. Tag everything with at least team, service, environment and, for SaaS, tenant where feasible. Enforce tags in IaC and with policy, because untagged resources cannot be allocated.
  2. Showback, then chargeback. Give every team a monthly view of its cost and unit cost. Showback (visibility) changes behaviour; chargeback (actually billing teams) needs mature allocation first.
  3. Budgets and anomaly detection. Per-team budgets with alerts at 80% and 100%, plus anomaly detection on daily spend by service, catch the forgotten debug flag in days instead of at month end.
  4. Unit cost dashboards. Cost per 1M requests, per active user, per tenant, plotted beside traffic. Review in the same meeting as latency and error SLOs (SLOs).
  5. Design review questions: What is the cost per unit at 10x traffic? Which line items scale with bytes rather than requests? What crosses an AZ, region or NAT? What is the retention and cardinality of new telemetry?
  6. A standing order of operations: delete waste, rightsize, architect (egress, tiering, sampling), then commit.

Interview angle

Cost rarely gets its own question, but strong candidates bring it into every design: “this fan-out writes 50 KB per follower, at our scale that is X TB a month of storage and cross-AZ replication, so I would store IDs not payloads”. Weak candidates ignore it or say “we can just use Spot”.

Interview questions

Q1: Your service’s NAT gateway bill is 15,000 USD a month. What do you investigate and change?

Model answer: At about 0.045 USD per GB processed that is roughly 330 TB a month, so find out what the traffic is. Enable VPC flow logs or use the cost and usage data to break it down by destination. Typical culprits are S3 and DynamoDB traffic (fix with free gateway endpoints), container image pulls and other AWS API calls (interface endpoints, image caching on nodes, smaller images), and third-party APIs or telemetry vendors (batch, compress, or use the vendor’s private connectivity if offered). Also check that each AZ has its own NAT gateway so instances do not pay cross-AZ transfer to reach a NAT in another zone. Re-measure after each change.

Q2: When would you buy a 3-year Savings Plan versus using Spot?

Model answer: They cover different parts of the demand curve. A commitment fits the floor of steady usage you are confident will exist for the term, after rightsizing, and a flexible plan is safer if instance families or regions may change. Spot fits interruptible work: stateless web tiers with enough spare capacity across diverse instance types, batch jobs with checkpoints, CI runners. It does not fit single-instance stateful services or anything that cannot absorb a two-minute notice. Most fleets combine all three: committed baseline, on-demand for the predictable daily peak margin, Spot for elastic and batch capacity. If the architecture is about to change, shorter terms or no commitment are cheaper than stranded spend.

Q3: Logging costs are growing faster than traffic. How do you get them under control without losing debuggability?

Model answer: Measure first: top log sources by volume and their growth. Then reduce at the source: drop debug in production unless dynamically enabled with an expiry, sample successful request logs while keeping every error and slow request, and structure logs so one wide event per request replaces many lines. Route through a collector that can filter and sample before data reaches a per-GB vendor. Use tiered retention, a short hot window and cheap archive storage for compliance. For metrics, enforce cardinality limits and remove unbounded labels like user IDs; move that detail to traces with tail sampling that keeps errors. Track log cost per million requests as a metric owned by each team.

✅ Key takeaways

  • Measure unit cost (per request, user or tenant), not just total spend. Rising unit cost is the design smell.
  • Data transfer, NAT processing, managed service premiums and observability are the bills architects forget. They scale with bytes and verbosity, not with instances.
  • Order matters: delete waste, rightsize, fix architecture, then commit to the remaining floor. Spot only for capacity you can lose.
  • Egress architecture is cost architecture: gateway endpoints, zone-aware routing, CDN offload and compression often beat any discount.
  • Control telemetry with sampling, retention tiers and cardinality budgets at a collector, before the vendor bills you.
  • FinOps makes it stick: tagging, showback, budgets, anomaly detection and FOCUS-format billing data reviewed alongside SLOs.

🧠 Check your understanding

0 / 4
  1. 1Your fleet averages 15% CPU and you plan to buy a 1-year Savings Plan. What should you do first?

  2. 2Private-subnet services read 100 TB a month from S3 in the same region through a NAT gateway. What is the cheapest fix?

  3. 3A metric has labels endpoint (20 values), status (5 values) and customer_id (40,000 values). Why is the bill high?

  4. 4Which workload is the worst fit for Spot capacity?

Where to go next

Finished this lesson?

Mark it complete to track your progress across the roadmap.