Cost Fundamentals & Cloud Billing
You pay for what you burn — know the meter
How cloud bills actually work: pay-per-use, usage tiers, type-specific pricing (compute-seconds, GB-months, egress), and the billing consoles that make it legible. The three pillars of the practice: attribution (tags), forecasting (budgets), and levers (this module covers all).
What you will learn
- Read the billing model: usage units, types, and tiers
- Attribute spend with tags and consolidated billing
- Set budgets and alerts that catch drift early
Cloud billing = usage (seconds × CPU/GB, storage GB-month, data egress) × unit price, with discounts (reserved/commit, tiered rates). Tags attribute cost to teams/workloads; consoles (Cost Explorer/Azure Cost Mgmt/GCP Billing) visualize it; budgets + alerts flag anomalies the invoice would hide.
What is this?
Usage units: compute (per-second VM/instance, FaaS per-invocation), storage (GB per month by tier), data transfer (ingress free-ish, egress charged; cross-AZ/region adds), DB (size + IOPS + backup), network (LB hours, NAT). Pricing constructs: on-demand (pay per burn), reserved/committed (stable = discount), tiered (volume scale). Billing tools: AWS Cost Explorer + Budgets + Cost Anomaly, Azure Cost Management + budgets + advisor, GCP billing reports + budget alerts. Tagging: labels applied at creation (env/team/cost-center), enforced via policy; consolidated billing across accounts/orgs gives one ledger. Cost discipline: monthly review of top cost items vs. line of business value.
Why do you need it?
- You can't optimize what you can't see — attribution is the prerequisite for every lever.
- Egress and tier assumptions quietly multiply bills; knowing the meter prevents surprises.
- Budgets catch a runaway autoscaler or a stuck replica before the invoice lands.
- Cost is a system property: like observability, it degrades if nobody has the instrument installed.
Mental model
A kitchen with hidden fees (per-pressure cook, per-pan-second, per-gallon of gas) vs. your bank's itemized statement
Cloud billing is the itemized statement
You only notice the gas when the bill lands; the statement (console + tags) tells you which pan ate the gas. Instruments before regrets.
How it works
- Resources emit usage events (CPU-seconds, bytes stored, data out).
- Billing aggregates usage × price into accounts, regions, services, tags.
- Consoles roll it into queries/dashboards; budgets watch totals and alert thresholds.
- Anomaly/forecasting models flag drift pre-invoice.
- You act with levers: commit, rightsize, retire, or re-architect.
Billing pipeline.
Examples
Tag your compute
# Every resource tagged at creation (IaC/Org policy):# env, team, cost-center, workload# A budget per cost-center + env, e.g.:# budget: "prod-platform" capped 18k/mo# alerts at 50/80/90/100%# Budget Plus: anomaly detection above +20% day-over-day.# Monthly: cost review = top-5 items per tag, action per item.Both the statement and the alarm are cheap to set — and they convert the invoice into a management report.
In production
- Org-wide tag policy enforced at IaC creation (no untagged resources).
- Budget teams: budgets per team/feature, alert thresholds wired to Slack/owners.
- Monthly FinOps review with top-5 cost drivers per workload.
Best practices
- Attribute before you optimize: every resource has env/team/owner tags from day one.
- Budgets + alerts for every cost center; anomalies monitored, not manual dives.
- Consolidated billing for one ledger; separate dev/test from prod costs.
- Review monthly with a value lens: cost per outcome, not just 'bill is up'.
- Keep an open inventory of 'top 5 levers' you haven't pulled yet.
Common mistakes
- No tagging → invoice arrives and nobody knows what ate the month.
- Budgets only per-account, not per-workload — spikes hide in the aggregate.
- Acting on a bill spike without correlating prod deploys/config changes.
- Treating egress as free — it's one of the most common modern bill surprises.
Debugging tips
- Spike in a week → Cost Explorer 'top services' diff vs last week, then correlate deploys/config.
- Egress surprise → cross-region replication or big batch jobs; check transfer type per service.
- A floating cost with no tag → the tag policy silently allows untagged; enforce at IaC.
- Overages in a tier → lifecycle/storage tier (hot vs cold) choice is the fix, not the commute.
Interview checkpoint
Hands-on lab
- Enforce tag schema on deployments (IaC)
- Create a budget with threshold alerts
- Trigger and read an alert (or simulate)
Tag a Stack and Stand a Budget
30 min · beginner
Quick quiz
The prerequisite for any cost optimization:
A bill item that surprises teams most, hidden by cost types: