Sub topic 1
How cloud pricing works
Prerequisites
This chapter assumes you have the following:
- Basic familiarity with a major cloud provider's compute, storage and networking services. For example, you know what a virtual machine, an object store and a virtual network are.
- Comfort running commands in a terminal.
- A basic understanding of JSON.
Examples use AWS. The same ideas apply to Azure and Google Cloud, although product names and exact rules differ.
Why pricing is the first topic
Every later technique in this tutorial depends on one fact: you pay for what you use, and you pay in many small pieces. Rightsizing, budgets, tagging and commitment discounts all make sense only when you know what is being metered and how each meter is priced. This chapter builds that working model and lists the common errors that surprise teams on their first large bill.
The usage-based model
In traditional data centers, you buy hardware up front. That is a capital expense. The cost is fixed, whether the servers are busy or idle.
Public cloud turns this into an operating expense. The provider measures consumption and bills you for it. Each service has one or more meters, and each meter has a unit price.
The monthly charge for one line item is:
charge = quantity consumed x unit priceA whole bill is the sum of thousands of such lines. Examples of meters:
| Service | Typical meter | Unit |
|---|---|---|
| Virtual machines (EC2) | Instance running time | Per second (60-second minimum) or per hour, depending on OS and instance |
| Block storage (EBS) | Provisioned capacity | GB-month |
| Object storage (S3) | Stored data, requests, retrieval | GB-month, per 1,000 requests, per GB retrieved |
| Managed databases (RDS) | Instance time, storage, backup storage | Per hour, GB-month |
| Serverless functions (Lambda) | Invocations and execution time | Per million requests, GB-second |
| Network | Data leaving a region or the provider | Per GB |
Two consequences follow from this table.
- A single resource often produces several charges. A database has instance, storage, backup, and possibly data transfer charges.
- Some meters run whether or not the resource does useful work. An idle virtual machine and a busy one cost the same per hour. A volume is billed for its provisioned size, not for how full it is.
Provisioned versus consumed pricing
One of the most useful distinctions is between paying for capacity and paying for consumption.
- Provisioned pricing charges for the capacity you reserve, even if you do not use it. EC2 instances, EBS volumes, and provisioned database instances work this way.
- Consumed pricing charges for what you actually use. Lambda invocations, S3 requests, and DynamoDB on-demand reads work this way.
Provisioned resources are cheaper per unit of work when they are kept busy. Consumed pricing is cheaper when demand is low or spiky. Waste hides mostly in provisioned resources, which is why the idle-resource and rightsizing chapters focus on them.
Purchasing options for the same resource
The same compute can be bought in several ways. The hardware is identical. The price and the commitment differ.
| Option | How you pay | Typical discount vs on-demand | Main trade-off |
|---|---|---|---|
| On-demand | Per second or hour, no commitment | None (baseline) | Highest unit price, full flexibility |
| Commitment (Savings Plans, Reserved Instances) | A fixed hourly spend or instance commitment for 1 or 3 years | Often 20 to 70 percent, depending on term and type | You pay even if you use less |
| Spot | Unused capacity at a variable price | Often up to 90 percent | Capacity can be reclaimed with short notice |
Discount levels vary by instance family, region, term and payment option. Treat the percentages as rough ranges and check the current price list for exact figures.
Later chapters cover commitments and spot capacity in detail. For now, remember that "what does it cost?" has no single answer. The answer depends on how you buy it.
Prices depend on more than the service
Several dimensions change the unit price of the same service.
- Region. The same instance type can cost noticeably more in one region than another. Regions such as us-east-1 are often cheaper than regions in South America or parts of Asia.
- Instance family and size. Price scales roughly linearly with size inside a family. Doubling the size roughly doubles the hourly price.
- Operating system and licensing. Windows and some commercial database engines add license fees to the hourly rate.
- Architecture. Arm-based instances (Graviton on AWS) often cost less than comparable x86 instances for the same work.
- Storage class or volume type. S3 Standard, Standard-IA and Glacier classes differ in price per GB and in retrieval charges. EBS gp3 and io2 differ in cost and performance.
- Tier. Many services have volume tiers. The per-GB price drops as monthly usage increases.
Free tiers and tiered pricing
Some meters have a free allowance. AWS offers an always-free allowance for some services and time-limited trials for others. These are useful for learning, but they are small, and production workloads usually exceed them quickly. Do not build a cost forecast that assumes the free tier will cover real usage.
Tiered pricing works like income tax brackets. Only the usage inside each band is charged at that band's rate. A bill for 60 TB of data transfer is not 60 TB at the lowest rate. It is the first band at the highest rate, then the next band at a lower rate, and so on.
Following one request through the meters
A simple web application shows how several meters combine. Suppose a user downloads a 2 MB image from a site hosted on EC2 and stored in S3.
A single click touches at least four meters. No one meter is large per request. The totals become large because of volume, and because some meters, such as the instance hours, accrue regardless of requests.
A worked estimate
Estimating cost before you build is a core skill. Use illustrative numbers, then replace them with current prices from the AWS pricing pages or the AWS Pricing Calculator.
Assume a small service with these inputs:
- One instance at 0.10 USD per hour, running all month. A month is about 730 hours.
- 500 GB of EBS storage at 0.08 USD per GB-month.
- 2,000 GB of data transferred out to the internet at 0.09 USD per GB.
The calculation:
HOURS_PER_MONTH = 730
compute = 0.10 * HOURS_PER_MONTH # instance hours
storage = 0.08 * 500 # provisioned GB-month
transfer = 0.09 * 2000 # GB out to the internet
total = compute + storage + transfer
print(f"compute : {compute:8.2f} USD")
print(f"storage : {storage:8.2f} USD")
print(f"transfer : {transfer:8.2f} USD")
print(f"total : {total:8.2f} USD")The output is:
compute : 73.00 USD
storage : 40.00 USD
transfer : 180.00 USD
total : 293.00 USDThe instance, the item most people think about first, is only about a quarter of the bill. Data transfer is the largest line. These prices are examples, but the pattern is realistic: the biggest cost is often not the one you were watching.
Reading the real numbers
Estimates are a starting point. Your actual bill is the authority. You can see it from the terminal with the Cost Explorer API. The next command returns October 2026 unblended cost, grouped by service.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICENote that the End date is exclusive. To cover all of October, you set End to 1 November. A later chapter covers this tool and its options in depth. Here, the point is that every line in the result corresponds to a meter you can reason about.
The word "unblended" matters. Unblended cost is the rate charged for each usage line as it happened. Other metrics, such as blended or amortized cost, spread discounts and upfront payments differently. Pick one metric and use it consistently, or your reports will disagree.
Common errors and misconceptions
These mistakes cause most surprise bills.
- Assuming stopped means free. Stopping an EC2 instance ends the instance-hour charge. Its attached EBS volumes, snapshots and any Elastic IP addresses still bill.
- Paying for provisioned, not used. A 1 TB volume that holds 50 GB is billed for 1 TB.
- Ignoring data transfer. Inbound traffic is usually free. Traffic out to the internet, between regions, and often between Availability Zones is billed.
- Forgetting per-request and retrieval fees. Cheap storage classes such as S3 Glacier have low storage prices but charge to retrieve data, and some have minimum storage durations. Moving frequently accessed data to a cold class can raise the bill.
- Using stale prices. Prices change, new instance generations are often cheaper per unit of work, and discount programs are updated. Re-check them.
- Comparing prices across regions without checking data transfer. A cheaper region can lose its advantage if your users or data live elsewhere.
- Treating a commitment as free money. A commitment lowers the unit price but creates a fixed obligation. If your usage falls below it, you still pay.
- Mixing cost metrics. Comparing an unblended figure from one report with an amortized figure from another produces differences that are not real.
Decision criteria for the pricing model
When you choose how to pay for a workload, ask these questions in order.
- Is the workload steady or variable? Steady baseline load suits commitments. Variable load suits on-demand or autoscaling.
- Can it tolerate interruption? Batch jobs, CI workers and stateless processing can use spot. A single primary database should not.
- How certain are you about the next 1 to 3 years? Uncertainty argues for shorter terms or flexible commitments.
- Is the resource provisioned or consumed? Provisioned resources need rightsizing. Consumed resources need volume control.
- Which meters dominate? Optimize the largest line first. A 10 percent saving on a 70 percent line beats a 50 percent saving on a 2 percent line.
How this connects to the rest of the tutorial
The next chapter groups cost into compute, storage and data transfer and shows where each tends to grow. After that, you learn to see costs, attribute them with tags and set budgets. Optimization techniques come later, because you cannot safely optimize what you cannot measure.
Exercise
A team runs one instance at 0.20 USD per hour for a 730-hour month, keeps 200 GB on EBS at 0.10 USD per GB-month, and sends 1,000 GB to the internet at 0.09 USD per GB. They stop the instance for the entire next month but leave the volume attached. Assuming nothing else changes and no data leaves the system, what is the estimated cost for that next month, and why is it not zero?
Show answer
Compute drops to zero because stopped instances do not accrue instance-hour charges. Transfer is zero because no data leaves. The EBS volume is still billed for its provisioned size: 200 GB x 0.10 USD = 20.00 USD. The estimated cost is 20 USD, because storage is a provisioned meter that bills whether or not the instance runs. (For comparison, the original month was 146.00 + 20.00 + 90.00 = 256.00 USD.)
Exercise
Why can moving 5 TB of frequently read data from S3 Standard to a cold archive class increase the monthly bill even though the per-GB storage price is lower?
Show answer
Cold classes charge retrieval fees per GB and may impose minimum storage durations and per-request costs. If the data is read often, retrieval charges can exceed the storage savings. Cold classes suit rarely accessed data.