Sub topic 1
How cloud pricing works
Prerequisites
This chapter assumes you know the basics of a major cloud provider's compute, storage and networking services. You should be comfortable running commands in a terminal and reading simple JSON. Examples use AWS, and the ideas carry over to other providers.
The working model: you pay for what you use
Cloud providers bill by usage. Each service has one or more meters, and your bill is the sum of meter readings multiplied by unit prices. You pay no upfront purchase, and you pay nothing for a resource once you stop using it.
Every charge has the same shape:
- A dimension is the thing being measured, such as instance hours, GB-months of storage or GB transferred out.
- A rate is the price per unit of that dimension. Rates vary by region, size and storage class.
- A quantity is how much you used in the billing period.
Cost for a line item equals rate times quantity. Controlling cost means changing the rate, the quantity, or both.
Common meters
Different services meter different things. Knowing the meter tells you what drives the cost.
| Service type | Typical meter | What raises the cost |
|---|---|---|
| Virtual machines | Instance-seconds or hours | Larger sizes, more instances, longer runtime |
| Block storage | GB-months provisioned | Volumes left allocated, even if unattached |
| Object storage | GB-months stored, plus requests | More data, hotter storage classes |
| Data transfer | GB transferred | Traffic leaving the region or the provider |
| Serverless functions | Requests and execution time | More invocations, more memory, longer runs |
Block storage is billed on what you provision, not on what you fill. A 500 GB volume that holds 10 GB costs the same as a full one.
Purchase options for the same resource
The same instance can be bought in several ways. The resource is identical, but the rate and the commitment differ.
| Option | Rate | Commitment | Trade-off |
|---|---|---|---|
| On-demand | Highest | None | Full flexibility, highest price |
| Committed use | Lower | Fixed spend or capacity for 1 or 3 years | You pay even if you use less |
| Spot | Lowest | None | The provider can reclaim capacity on short notice |
Later chapters cover commitments and spot in detail. For now, remember that choosing an option is a pricing decision separate from choosing a size.
Pricing details that surprise people
- Free tiers are limited. They cover small amounts or a limited period, and heavy use is billed at standard rates.
- Region changes the rate. The same instance can cost noticeably more in one region than another.
- Tiered pricing lowers the rate as volume grows. Data transfer and storage often get cheaper per GB at higher volumes.
- Inbound transfer is usually free. Outbound transfer to the internet and cross-region transfer are usually billed.
- Stopped is not always free. A stopped instance stops its compute charge, but its attached volumes and reserved IP addresses keep billing.
Checking a rate yourself
You can query list prices with the AWS Price List API instead of reading a web page. This command returns the product entries for one instance type in one region.
aws pricing get-products \
--region us-east-1 \
--service-code AmazonEC2 \
--filters \
Type=TERM_MATCH,Field=instanceType,Value=m5.large \
Type=TERM_MATCH,Field=regionCode,Value=us-east-1 \
Type=TERM_MATCH,Field=operatingSystem,Value=Linux \
Type=TERM_MATCH,Field=tenancy,Value=Shared \
Type=TERM_MATCH,Field=preInstalledSw,Value=NA \
Type=TERM_MATCH,Field=capacitystatus,Value=Used \
--max-items 1The response is JSON with an on-demand price per hour. The filters matter, because without them one instance type matches many products with different operating systems and tenancy.
Exercise
A team provisions a 200 GB volume, stores 20 GB on it, then stops the instance it was attached to. Which of these still produce charges: the instance compute, the volume, or both? Explain using the idea of meters.
Show answer
Only the volume. The compute meter counts running time, so it stops when the instance stops. The block storage meter counts provisioned GB-months, so the full 200 GB keeps billing whether or not it is attached or full.