Home › Cloud services › Operations
guide medium

Cost control

Problem A cloud bill grows from thousands of small meters that nobody watches. This guide covers how to see where the money goes, stop waste and buy capacity more cheaply.

Cloud bills grow from idle resources, egress, cross-zone traffic and on-demand pricing; tagging, budgets, commitments, spot and architecture fixes cut them 30-70 %.

finopssavings-plansspotegressbudgetsrightsizing
Overview

A cloud bill is the sum of thousands of small meters, and nobody watches most of them. Cost control is three loops: see it (tags, per-team cost reports, anomaly alerts), stop waste (idle and oversized resources, forgotten storage, chatty cross-zone traffic), and buy smarter (commitments for the steady base, spot for interruptible work, cheaper providers for bandwidth-heavy parts).

Key facts

Use when

  • Monthly bill passes order of $1-5k, or grows faster than usage.

Avoid when

  • Pre-product-market-fit with credits: spend the time on the product, but set a budget alert anyway.

Deep dive

Where money leaks (check in this order)

LeakTypical fixSaving
Idle dev/test environments 24/7Schedules (stop nights/weekends), ephemeral preview envs~65 % of their cost
Oversized instances (CPU < 20 %)Rightsize one size down, Arm instances20-50 %
Unattached volumes, old snapshots, orphan IPs/LBsWeekly sweep, lifecycle policiesSmall each, adds up
Object storage without lifecycleTiering + incomplete-multipart cleanup30-80 % of storage line
Egress to usersCDN, R2/B2, compressionOften 50-90 % of egress
NAT gateway processingVPC endpoints for S3/DynamoDB/ECR, IPv6 egress-onlyOrder of $0.045/GB avoided
Cross-AZ trafficZone-aware routing, rack-aware Kafka consumersOrder of $0.02/GB round trip
Logs and metrics volumeSampling, retention, drop debug30-70 % of observability
On-demand for the steady baseSavings Plans / CUDs on ~70-80 % of the baseline30-50 %

Decision table

SituationChoiceWhy
Steady baseline for 1+ yearCompute Savings Plan / CUD on the floor of usage, not the peakFlexible across instance types; peaks stay on demand/spot
Stateless, retryable work (CI, batch, render)Spot with diversified instance types60-90 % off; retry is cheap
Bandwidth-heavy productMove the serving path to a CDN or commodity providerEgress dominates; commitments don't discount it much
Many teams, unclear ownersMandatory tags + per-team showback reportPeople cut what they see
GPU trainingSpot/neocloud + checkpointing, idle shutdownGPUs idle at $2-8/h each
Bill > ~$50k/monthNegotiate private pricing / EDP, and price a hybrid moveDiscounts are negotiable at scale

Code

Budget alert with Terraform (AWS):

resource "aws_budgets_budget" "monthly" {
  name         = "total-monthly"
  budget_type  = "COST"
  limit_amount = "5000"
  limit_unit   = "USD"
  time_unit    = "MONTHLY"
  notification {
    comparison_operator        = "GREATER_THAN"
    threshold                  = 80
    threshold_type             = "PERCENTAGE"
    notification_type          = "FORECASTED"
    subscriber_email_addresses = ["ops@example.com"]
  }
}
resource "aws_ce_anomaly_monitor" "svc" {
  name              = "per-service"
  monitor_type      = "DIMENSIONAL"
  monitor_dimension = "SERVICE"
}

Find the top cost drivers by usage type (where egress, NAT and cross-AZ hide):

aws ce get-cost-and-usage --time-period Start=2026-09-01,End=2026-10-01 \
  --granularity MONTHLY --metrics UnblendedCost \
  --group-by Type=DIMENSION,Key=USAGE_TYPE \
  --query 'ResultsByTime[0].Groups[].[Keys[0],Metrics.UnblendedCost.Amount]' --output text \
  | sort -k2 -nr | head -25
# look for: DataTransfer-Out-Bytes, NatGateway-Bytes, DataTransfer-Regional-Bytes (cross-AZ), EBS:SnapshotUsage

Sweep unattached volumes:

aws ec2 describe-volumes --filters Name=status,Values=available \
  --query 'Volumes[].[VolumeId,Size,CreateTime]' --output table

Efficiency

  • Cost: the meters are compute-hours, GB stored, GB sent out, requests, and NAT and cross-zone GB. Savings Plans give up to 72 % off covered compute (AWS Savings Plans User Guide); Spot offers up to 90 % off with a two-minute interruption notice (AWS Spot page, EC2 User Guide); gp3 volumes cost 20 % less per GiB than gp2 (EBS docs). All as of 2026-10. Bound: the largest usage type, found by sorting.
  • Levers:
    • Savings Plan on the usage floor — up to 72 % off covered compute (AWS) — steady baseline
    • Spot with diversified instance types — up to 90 % off (AWS) — retryable work
    • gp2 to gp3 — 20 % lower price per GiB, 3,000 IOPS and 125 MiB/s baseline included (EBS docs) — EBS volumes
    • stop dev and test environments nights and weekends — about two thirds or more of their hours (arithmetic on a 168 h week) — non-production
    • lifecycle rules for multipart uploads, tiering, old versions — storage line (see Object storage) — buckets
  • Naive → standard → state of the art:
    • on demand everywhere, no tags · list price, no owner
    • tags, budgets, Savings Plan on the floor, Spot for batch · up to 72 % and 90 % off the covered usage
    • weekly sort by usage type, unit cost per request or user, architecture fixes for egress and NAT · cost follows usage

Implementation notes

  • Tag at creation through Infrastructure as code default tags (team, service, env); untaggable cost goes to a shared bucket reviewed monthly.
  • Use the cost and usage report (CUR / BigQuery billing export / Azure cost exports) in SQL; the console hides usage types.
  • Unit economics: track cost per request, per user or per GB processed, not just the total.
  • Commit in tranches (e.g. quarterly) so a wrong forecast doesn't lock in waste.
  • Arm instances: order of 20 % cheaper per vCPU; most Go/Rust/Java/Node services port with a rebuild.

Pitfalls

  • Committing to the peak: unused commitment is pure waste and can't be cancelled.
  • Free tiers that silently end after 12 months.
  • Autoscaling with a minimum that equals the old peak.
  • Data transfer between regions for "DR" replicas that nobody tested.
  • Optimizing CPU while egress or logging is the real line item; always sort by usage type first.

Implementations

namelangrepoinstallverdictlicencehealthas_ofnotes
OpenCostGoopencost/opencostn/a (Kubernetes install via Helm, see docs)————cost allocation by namespace, label, workload
InfracostGoinfracost/infracostbrew install infracost————price estimate in pull requests
Cloud CustodianPythoncloud-custodian/cloud-custodianpip install c7n————policy rules to stop idle and untagged resources
KarpenterGoaws/karpenter-provider-awsn/a (Helm chart, see docs)————node provisioning with Spot and consolidation

Sources

  • J.R. Storment and Mike Fuller, Cloud FinOps, 2nd ed., O'Reilly, 2023.
  • AWS, Savings Plans User Guide docs and Cost Explorer API reference docs
  • AWS, Amazon EC2 Spot Instances. page
  • Sarah Wang and Martin Casado, The Cost of Cloud, a Trillion Dollar Paradox, Andreessen Horowitz, 2021. post

Builds on

resource usage accounting · plannedCgroup/procfs/GPU counters sampled into per-workload usage
spot capacity allocation · plannedDiversify across instance pools by price and interruption risk
autoscaling · plannedTarget-tracking scaler with stabilization windows, cooldowns and hysteresis
Rollup aggregationSystems that collect far more timestamped events than anyone reads one by one, such as sensor readings, metrics, clicks or usage records, cannot afford to scan or keep every raw row for dashboards and bills over months.

Used by

Alternatives and related

Cloud providers comparedChoosing where to host a new system, or checking whether the current cloud bill is out of line. This guide answers which kind of provider (hyperscaler, commodity, specialist) fits which workload.VMs and bare metalRunning long-lived services, databases or game servers raises the question of renting elastic cloud VMs or whole dedicated servers. This guide answers which to pick for cost, latency and control.Object storageBackups, media, logs, data lakes and model weights need cheap, durable storage for large files. This guide answers when object storage is the right home and when a database, block storage or cache is needed instead.CDN and edgeUsers far from your servers see slow responses, and traffic spikes or attacks hit the origin directly. This guide answers whether and how to put a CDN or edge compute in front of a service.ObservabilityOperators of a live system need to know when it is broken and why. This guide answers which signals to collect (metrics, logs, traces), how much, and where to store them.Infrastructure as codeTeams that create servers and cloud resources by clicking in a console cannot reproduce environments, review changes or recover quickly from disaster. This guide covers managing infrastructure as reviewed files and its risks.GPU cloudTeams training or serving neural nets find GPU time is the biggest line on the bill and prices vary widely between providers. This guide answers where to rent GPUs and what trade-offs each kind of provider brings.