Sub topic 14
Measuring unit costs
This chapter assumes you can read Cost Explorer output, that your resources carry cost allocation tags (covered in the tagging chapter), and that you can run AWS CLI commands and read JSON.
Why total spend misleads
A bill that rises from 40,000 USD to 50,000 USD looks bad. If the number of orders processed tripled in the same month, the business became cheaper to run per order. If orders stayed flat, you have a real problem. Total spend can't tell these cases apart.
A unit cost is cloud spend divided by a measure of business output. Common units are cost per order, cost per active user, cost per 1,000 API requests, and cost per gigabyte processed.
The working model
Every unit cost has two parts:
- Numerator: cost for one product, team or environment. You get it from tagged spend in Cost Explorer.
- Denominator: a business metric from your own systems, such as a request counter or order count.
The two must cover the same scope and the same time period. If the numerator is the checkout service and the denominator is all orders, the ratio is wrong.
Step 1: get the numerator
Use the tag that identifies the product. This command groups October 2026 cost by a product tag. The tag must be activated as a cost allocation tag first.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=TAG,Key=productEach group key appears as product$checkout. Resources without the tag appear under product$ with an empty value. That group is your untagged remainder, and it must be explained or allocated before the unit cost is trustworthy.
Step 2: get the denominator
Take the metric from your application or data warehouse for the same dates. Suppose the checkout service handled 2,500,000 orders in October.
Step 3: divide
The following script divides a cost by an order count. Replace the numbers with your own values.
cost_usd = 18750.00
orders = 2_500_000
cost_per_order = cost_usd / orders
cost_per_1000_orders = cost_per_order * 1000
print(f"Cost per order: ${cost_per_order:.4f}")
print(f"Cost per 1,000 orders: ${cost_per_1000_orders:.2f}")This prints a cost of 0.0075 USD per order, or 7.50 USD per 1,000 orders. Quote the figure per 1,000 when per-unit values are tiny fractions of a cent.
Reading the trend
A single unit cost means little. Compare it month over month.
| Month | Spend (USD) | Orders | Cost per 1,000 orders (USD) |
|---|---|---|---|
| August | 15,000 | 2,000,000 | 7.50 |
| September | 17,000 | 2,300,000 | 7.39 |
| October | 18,750 | 2,500,000 | 7.50 |
Spend rose 25 percent, but unit cost stayed flat. Growth is paying for itself. If the unit cost climbed while traffic stayed flat, look for waste: idle resources, oversized instances, or a missed lifecycle policy.
Common errors
- Mismatched scope or period. Cost for one service divided by a metric for the whole company.
- Ignoring shared costs. Networking, logging and support often have no product tag. Decide an allocation rule, such as splitting by proportion of direct spend, and apply it consistently.
- Using the wrong metric. Pick a unit that drives cost. Cost per user fails if a few heavy users cause most of the load.
- Mixing cost types. Compare unblended to unblended. Switching to amortized cost midway, for example after buying commitments, changes the trend for reasons unrelated to efficiency.
- Treating the number as a target to minimize. A lower unit cost isn't always better if reliability suffers. Treat it as a signal that prompts questions.
Exercise
Last month the search service cost 9,000 USD and handled 30,000,000 requests. This month it cost 11,000 USD and handled 50,000,000 requests. Compute the cost per 1,000 requests for each month and say whether efficiency improved.
Show answer
Last month: 9,000 / 30,000 = 0.30 USD per 1,000 requests. This month: 11,000 / 50,000 = 0.22 USD per 1,000 requests. Total spend rose 22 percent, but unit cost fell about 27 percent, so efficiency improved.
Exercise
Your cost per order rose 20 percent while order volume stayed flat. Name two checks you would make first.
Show answer
Check for untagged or newly created resources in the grouped Cost Explorer output, and look for idle or oversized resources such as unattached EBS volumes. Also confirm that the cost type and the allocation rule did not change between months.