Sub topic 12
How cloud services are billed
This chapter assumes you know the three service models (IaaS, PaaS, SaaS) and the idea of measured service from earlier chapters. It covers how a provider turns metered usage into a bill, and where bills tend to surprise people.
Metering and pay-as-you-go
Providers measure what you use and charge for it. This is the "measured service" characteristic in practice. The meter depends on the resource:
- Compute is charged per second or per hour that a machine runs.
- Storage is charged per gigabyte stored per month.
- Network is charged per gigabyte that leaves the provider's network. Inbound traffic is often free.
- Managed services are charged per request, per query, or per provisioned unit of capacity.
You pay for what you provision, not for what you actually use. A virtual machine at 2% CPU costs the same as one at 90%.
Pricing models
| Model | How it works | Best for | Main risk |
|---|---|---|---|
| On-demand | Pay the list rate with no commitment | Unpredictable or short-lived work | Highest unit price |
| Committed or reserved | Promise 1 to 3 years of usage for a discount | Steady, long-running workloads | Paying for capacity you stop using |
| Spot or preemptible | Use spare capacity at a deep discount | Fault-tolerant batch jobs | The provider can reclaim the capacity at short notice |
| Subscription | Fixed fee per user or per plan | SaaS products | Paying for unused seats |
| Free tier | Limited free usage, often time-limited | Learning and prototypes | Quietly rolling over into paid usage |
How billing differs by service model
The billing unit moves up the stack along with the layers you manage.
With IaaS you assemble the bill from many small meters. With SaaS you usually see one predictable line, but you pay for every seat whether it is used or not.
A worked estimate
This script estimates one month of a small IaaS workload. The rates are made-up placeholders, so replace them with current prices from your provider's pricing page.
HOURS_PER_MONTH = 730
# Placeholder rates in USD. They are not real prices.
rate_instance_hour = 0.0104
rate_storage_gb_month = 0.08
rate_egress_gb = 0.09
instances = 2
storage_gb = 100
egress_gb = 250
compute = instances * HOURS_PER_MONTH * rate_instance_hour
storage = storage_gb * rate_storage_gb_month
network = egress_gb * rate_egress_gb
total = compute + storage + network
print(f"Compute: ${compute:.2f}")
print(f"Storage: ${storage:.2f}")
print(f"Network: ${network:.2f}")
print(f"Total: ${total:.2f}")Compute comes to about $15.18, storage to $8.00, and network to $22.50. The data leaving the network costs more than the servers, which is a common surprise.
Common errors
- Leaving resources running. Stopped virtual machines may still bill for their attached disks, and unattached disks and idle load balancers keep billing.
- Ignoring data transfer. Moving data between regions or out to the internet is metered separately from compute.
- Overcommitting. A three-year commitment saves money only if the workload lasts that long.
- Skipping budgets and alerts. Billing data arrives with a delay, so set a budget alert before you start experimenting.
Exercise
A team runs a web server around the clock for three years at a steady load. A second team runs a nightly batch job that can safely restart if interrupted. Which pricing model suits each team, and why?
Show answer
The steady web server suits a committed or reserved price. The load is predictable, so the long-term discount pays off. The nightly batch job suits spot capacity. It tolerates interruption, so it can take the deep discount without risk.