Lesson 5 of 11 · 11 min · Cloud basics

Cloud cost basics

Covers: Concepts; arithmetic examples use illustrative prices, not current list prices. Updated 13 Nov 2026. Part of the DevOps Engineer roadmap.

What you will learn

  • How cloud billing works and the dimensions you are charged for
  • The usual causes of surprise bills
  • Tagging, budgets, alerts and cost visibility
  • Practical savings: right-sizing, scheduling, commitments, Spot, storage and transfer
  • A basic FinOps routine

In simple words

A cloud bill is like an electricity bill with hundreds of meters: each machine, each gigabyte stored, each gigabyte sent out. Small things left running add up quietly. This lesson shows what you are charged for, what causes surprise bills, and the habits that keep costs under control.

Words to know

  • Pay as you go: you are billed for what you use, by the hour, second or gigabyte.
  • Tag: a label on a resource, such as team: payments, so you can see who spent what.
  • Budget alert: a message sent when spending passes a limit that you set.
  • Right-sizing: choosing a machine that fits the real need instead of an oversized one.

How you are billed

The cloud turns infrastructure into metered usage. Every service charges along several dimensions:

Service Typical dimensions
Compute (EC2, Fargate) instance-hours (per second), vCPU and GB-hours
Serverless (Lambda) requests, execution time × memory
Storage (S3) GB-months stored, requests, retrieval, data transfer out
Block storage (EBS) GB-months provisioned (even if empty), IOPS/throughput, snapshots
Database (RDS) instance-hours, storage GB, IOPS, backup storage beyond free, Multi-AZ doubles instance cost
Load balancer hours + capacity units (traffic, connections)
NAT gateway hours + per-GB processed
Network data transfer out to the internet, between regions and often between zones
Monitoring and logs metrics, log ingestion and storage

Two facts shape everything: you pay for what is provisioned, not what is used (a stopped instance still pays for its EBS volume; an idle database costs the same as a busy one), and small unit prices multiply (Rs 0.x per GB across terabytes, or per hour across a month: 730 hours).

Illustrative arithmetic (made-up round numbers, not real prices): an instance at 5 rupees per hour costs 5 × 730 = 3,650 rupees a month if left running; 8 hours a day on weekdays only is about 5 × 8 × 22 = 880 rupees. Scheduling non-production environments off outside working hours saves around three quarters of their compute cost.

The usual suspects behind a high bill

  1. Idle or forgotten resources: instances, databases, load balancers and Elastic IPs nobody uses; unattached EBS volumes; old snapshots; test environments left on. Free-tier accounts are surprised by these first.
  2. Oversized resources: big instances at 5% CPU; Multi-AZ everywhere including dev.
  3. NAT gateway data processing: every gigabyte that private instances send to the internet (including to S3 and ECR if you don't use endpoints) pays a per-GB processing fee on top of the hourly charge. Fix with VPC gateway endpoints for S3/DynamoDB (free) and interface endpoints for other services.
  4. Data transfer: traffic out to the internet, cross-region replication and, often overlooked, cross-AZ traffic (microservices chattering between zones, load balancers sending to targets in other zones). Use a CDN, keep chatty services in the same zone where reasonable, compress.
  5. Logs and metrics: debug logging at high volume into CloudWatch Logs (ingestion is priced per GB) and high-cardinality custom metrics.
  6. Storage that only grows: S3 without lifecycle rules, old versions, snapshots, backups; logs kept forever.
  7. On-demand pricing for steady workloads (commitments save a lot).
  8. Public IPv4 addresses are now billed per hour; release unused ones.
  9. Autoscaling that never scales down, or a runaway loop, or a mining-malware compromise (unusual compute spikes: set alerts).
  10. Data egress from a cloud you want to leave: lock-in has a price.

See your costs: tags and accounts

You cannot manage what you cannot attribute.

  • Tag every resource: Project, Environment, Owner, CostCentre. Activate them as cost allocation tags in billing so reports can group by them. Enforce tagging with policy (Service Control Policies, tag policies, Terraform default_tags, CI checks). Untagged spend is unowned spend.
  • Separate accounts (AWS Organizations) for production, non-production and shared services give hard cost and security boundaries; consolidated billing combines the discounts.
  • Cost Explorer (AWS), Azure Cost Management, Google Cloud Billing reports: group by service, tag and account; look at daily cost, not just the monthly total.
  • Cost and Usage Report (CUR) to S3, queryable with Athena, for deep analysis; third-party tools (Infracost for pull requests, OpenCost/Kubecost for Kubernetes) add detail.

Alerts and guard rails

Set these up before you launch anything on a new account:

  1. Budgets with alerts: a monthly budget with notifications at 50%, 80% and 100% of actual and forecasted spend, to email and chat. (AWS Budgets, Azure Budgets, GCP budgets.)
  2. Anomaly detection: AWS Cost Anomaly Detection flags unusual daily spend.
  3. Billing alarms for free-tier accounts and for students experimenting: a runaway lab can cost real money.
  4. Service quotas and limits so a mistake cannot create 500 instances.
  5. Least privilege: fewer people able to create expensive resources.
  6. Automatic clean-up of sandboxes (tags with an expiry date plus a scheduled job; tools like cloud-nuke for dev accounts).

Saving money

Work in this order: remove waste, right-size, schedule, then commit.

  1. Delete what is unused: find idle resources (Trusted Advisor, Compute Optimizer, Azure Advisor, GCP Recommender), unattached volumes, old snapshots and AMIs, empty load balancers.
  2. Right-size: pick instance sizes from measured CPU/memory (CloudWatch with the agent; Compute Optimizer recommendations). Move to current-generation and Graviton/ARM types (often 20-40% better price/performance). Use gp3 instead of gp2 volumes. Fargate task sizes match real use.
  3. Schedule non-production to stop evenings and weekends; scale dev/test databases to zero or snapshot-and-delete.
  4. Autoscale instead of provisioning for peak all day; use serverless for spiky loads.
  5. Commit for steady usage: Savings Plans (flexible commitment per hour of spend, applies across instance families and Fargate/Lambda) or Reserved Instances for 1-3 years. Cover only the stable baseline (say 60-70% of steady usage), and only after right-sizing.
  6. Use Spot for fault-tolerant workloads (batch, CI, stateless workers) with diversified instance types and interruption handling.
  7. Storage: lifecycle rules to cheaper classes, expire old versions and logs, Intelligent-Tiering for unpredictable access, compress, avoid duplicates.
  8. Network: CDN to cut egress and origin load; VPC endpoints; same-zone traffic for chatty pairs; avoid pulling images through NAT (ECR endpoints).
  9. Reduce observability waste: set log retention (not "never expire"), sample traces, drop debug logs in production.
  10. Architect for cost: managed services often cost more per unit but less in people time; serverless is cheap at low volume and expensive at constant high volume. Consider total cost, not only the cloud bill.

A monthly routine (FinOps in practice)

FinOps is the practice of engineers, finance and product managing cloud spend together. A lightweight routine for a small team:

  1. Review last month's bill by service and tag; explain the top five items.
  2. Check anomalies, untagged spend and forecast versus budget.
  3. Act on the top recommendations (right-size, delete, schedule).
  4. Re-evaluate commitments quarterly.
  5. Show each team its own cost (showback) so ownership is clear, and include cost in design reviews ("what will this cost at 10× traffic?").
  6. Estimate cost in pull requests (Infracost) for infrastructure changes.

Use the provider's pricing calculator before building, and run real load to get actual numbers.

Free tiers and learning safely

AWS offers a free tier (12-month and always-free allowances) and credits for new accounts; Google Cloud and Azure have credits and always-free products; Oracle's always-free VMs are generous. Learning safely: create a budget alert first, use one region, tag everything with Owner=you and an expiry, prefer services you understand, and run terraform destroy (or delete) at the end of every session. Know that some "free" items still bill when you exceed limits or use extras (NAT gateways and public IPv4 addresses are common first-bill surprises).

Common mistakes

  • No budget or alerts until the first shock.
  • Treating the cloud as a fixed-cost data centre (leaving everything on).
  • Untagged resources nobody can attribute.
  • Committing before right-sizing.
  • Ignoring data transfer, NAT and logging costs in designs.
  • Multi-AZ, large instances and high availability in dev.
  • Unbounded retention for logs, snapshots and versions.
  • Optimising a small line item while a big one is ignored.

Try it yourself

  1. Set up a monthly budget with email alerts at 50%, 80% and 100% on a sandbox account.
  2. Tag a few resources and activate the tags in billing; then group Cost Explorer by tag.
  3. Pick one non-production environment and calculate the saving from running it only on working hours.
  4. Find your three largest cost items and write one action for each.

Check yourself

Why can a stopped EC2 instance still cost money?

Its attached EBS volumes (and any Elastic IPs and snapshots) are still provisioned and billed; only the instance compute charge stops.

What often causes unexpectedly high NAT gateway bills?

Large volumes of traffic from private subnets to the internet or to AWS services through the NAT, which charges per GB processed. Use VPC endpoints and caches to avoid it.

What is the correct order for cost optimisation?

Delete waste, right-size, schedule/autoscale, then buy commitments (Savings Plans/Reserved) for the steady baseline; use Spot where interruption is acceptable.

Why are tags important for cost management?

They attribute spend to projects, teams and environments so you can see who owns it and where to optimise; untagged resources can't be allocated.

Interview questions

How would you cut a startup's monthly AWS bill by 30%?

Analyse by service and tag; remove idle resources; right-size instances and databases; schedule non-production off-hours; buy a Savings Plan for the stable baseline; move to Graviton and gp3; add S3 lifecycle rules and log retention; fix NAT/data-transfer hot spots with VPC endpoints and a CDN; set budgets and anomaly detection so it stays down.

What is FinOps?

A practice of collaborative financial accountability for cloud spend, combining engineering, finance and product to make cost visible, optimise continuously and make trade-offs between speed, quality and cost.

Savings Plans versus Spot?

Savings Plans are a commitment for lower prices on steady usage with no interruption; Spot offers the deepest discounts for spare capacity that can be reclaimed with short notice, suited to fault-tolerant workloads.

Summary

  • You pay for provisioned capacity and metered usage; idle resources, NAT/data transfer, logs and unbounded storage are common bill drivers.
  • Tag everything, separate accounts, and set budgets, alerts and anomaly detection before launching.
  • Optimise in order: delete waste, right-size, schedule/autoscale, commit, use Spot where suitable.
  • Make cost a routine: monthly review, showback to teams, estimates in design and pull requests.

Going deeper

See how much of this you can explain

A free mock interview asks you new questions on Cloud platforms and AWS fundamentals for DevOps Engineer and scores every answer, with what to fix.