Sub topic 5
Turning workload usage into inputs
This chapter assumes you know the core AWS services (EC2, S3, RDS), understand AWS Regions, and can read a monthly cost breakdown. You have already seen the pricing dimensions and how to configure a service's Region, size, and options. Here you turn a description of a workload into the numbers the calculator asks for.
Why usage inputs decide the estimate
Configuration tells the calculator what you run. Usage tells it how much of it you consume. A t3.large instance is the same product whether it runs for 40 hours or 730 hours a month, but the bill differs by a factor of almost 18. Most estimate errors come from usage inputs, not from picking the wrong instance.
A usage input is a number that multiplies a unit price. The calculator asks for these in the unit the service charges in. Your job is to convert what you know about the workload (users, requests per second, data retained) into those units.
The conversion workflow
Work through the same steps for every service in the estimate.
- List the pricing dimensions of the service. For S3 these include storage in GB-months, requests, and data retrieval. For Lambda they are requests, duration, and memory.
- Find the workload measure that drives each dimension. Requests per second, objects stored, and hours of operation are typical.
- Convert the measure into the unit the calculator uses, and into a monthly figure.
- Enter the value, then check the line item's monthly cost against a hand calculation.
- Record the source of each number so a reviewer can challenge it.
Time-based inputs
Compute services such as EC2 charge for time. The calculator offers two common ways to express it: a count of instances with a utilization value, or a fixed number of hours. Utilization is the share of the month the instance runs. An instance that runs only during business hours, about 10 hours on 22 weekdays, runs roughly 220 of 730 hours, which is a utilization near 30 percent.
The following function reproduces the calculation so you can sanity-check a line item. The calculator uses 730 hours as the average month, which is 8,760 hours in a year divided by 12.
HOURS_PER_MONTH = 730 # average hours in a month, a common basis for monthly estimates
def monthly_compute_cost(hourly_rate, instance_count, utilization=1.0):
"""Estimate monthly On-Demand compute cost.
utilization is the fraction of the month the instances run (0 to 1).
"""
return hourly_rate * HOURS_PER_MONTH * utilization * instance_count
# hourly_rate is an illustrative placeholder, not a current AWS price.
example_rate = 0.02
print(round(monthly_compute_cost(example_rate, instance_count=3, utilization=0.5), 2))With the placeholder rate of 0.02, three instances at half-month utilization give 0.02 × 730 × 0.5 × 3 = 21.90. If the calculator shows a very different figure for the same inputs, check the unit selected for utilization (percent of month versus hours per day or week) before suspecting the price.
Volume-based inputs
Storage and data services charge for volume. Pay attention to the time basis.
- S3 storage is billed in GB-months. If you store 500 GB for the whole month, the input is 500 GB. If the data grows from 0 to 1,000 GB linearly over the month, the average is 500 GB, and that average is what you enter.
- EBS volumes are billed for provisioned size, not for how full they are. A 1 TB volume that holds 100 GB is still 1 TB in the estimate.
- RDS storage is also billed on allocated size. Backup storage beyond the allocated amount is a separate input.
- Data volumes may use GB, TB, or even TiB depending on the service. Confirm the unit label next to each field.
The common error here is entering end-of-month size for a growing data set. That overstates the first months and understates nothing. A better approach is to estimate several months separately, or to enter the average and note the growth assumption.
Request-based inputs
Services such as S3, API Gateway, DynamoDB, SQS, and Lambda charge per request or per request unit. You usually know a rate (requests per second) and the calculator wants a monthly count, or the reverse. Convert carefully.
SECONDS_PER_MONTH = 730 * 3600 # 2,628,000
def monthly_requests(avg_requests_per_second):
return avg_requests_per_second * SECONDS_PER_MONTH
def peak_to_average(peak_rps, peak_hours_per_day, base_rps):
"""Blend a daily peak and a base load into an average rate."""
peak_share = peak_hours_per_day / 24
return peak_rps * peak_share + base_rps * (1 - peak_share)
avg = peak_to_average(peak_rps=200, peak_hours_per_day=4, base_rps=20)
print(round(avg, 1))
print(f"{monthly_requests(avg):,.0f} requests per month")The blended rate is about 50 requests per second, so roughly 131 million requests a month. Entering the peak rate for the whole month would give about 526 million, four times too high. Use the average for services billed per request, and use the peak only for services where capacity is provisioned, such as DynamoDB provisioned throughput or instance counts sized for the peak.
Lambda adds a second dimension. Duration cost depends on the memory you configure and the average run time in milliseconds. Enter the memory setting you will actually deploy, because memory and duration trade off against each other.
Choosing between average, peak, and percentile
Different services need different statistics.
| Pricing model | Example | Input to use |
|---|---|---|
| Per request or per GB transferred | S3 requests, API Gateway | Monthly average, summed over the month |
| Provisioned capacity | DynamoDB provisioned, RDS instance size | Peak or a high percentile, since you must cover the load |
| Time running | EC2, RDS instances | Hours the resource exists, not hours it is busy |
| Allocated size | EBS, RDS storage | Provisioned size at the stated date |
The row for time running is a frequent source of confusion. An EC2 instance is billed while it is running, even if its CPU is idle. Utilization in the calculator means the share of time the instance is running, not CPU load.
Handling uncertainty
Often you do not know the numbers. Use these habits.
- Start from measurements. If the workload already exists on premises or in another account, take figures from logs, monitoring, and billing exports rather than from memory.
- Use a range. Build a low, expected, and high case by changing the usage inputs and keeping the configuration fixed. Saving each as a separate estimate makes the spread visible.
- Mark the guesses. Put the assumption in the description field of the service or group, for example "assumes 2 million requests a month, based on the pilot".
- Find the dominant line. Sort the estimate by monthly cost. Spend your effort validating the two or three inputs that drive most of the total, not the many small ones.
Checking an input against a hand calculation
Before you trust a line item, reproduce it. Take the monthly cost the calculator shows, divide by the unit price, and confirm you get the quantity you meant to enter. If the quantity differs, a unit (hours versus days, GB versus TB, thousands versus millions of requests) is usually wrong.
The AWS Price List API returns list prices you can use as the unit price in that check. It is covered in a later chapter. For now, use the rate that the calculator displays for the selected Region and configuration.
Common errors
- Entering requests per second into a field that expects requests per month.
- Using 24 × 30 = 720 hours in one place and 730 in another, which leaves small mismatches between line items.
- Treating utilization as CPU load.
- Entering the final data size instead of the average over the month.
- Forgetting a second dimension, such as Lambda duration or S3 request tiers, so only the obvious dimension is priced.
- Leaving a service at its default usage value. Defaults are placeholders, not forecasts.
Exercise
A service averages 20 requests per second for 20 hours a day and 180 requests per second for 4 hours a day. It is billed per request. Using 730 hours in a month (2,628,000 seconds), how many requests per month should you enter, and why is entering the peak rate for the whole month wrong?
Show answer
The daily share at peak is 4/24 = 1/6. The average rate is 180 × 1/6 + 20 × 5/6 = 30 + 16.67 = 46.67 requests per second. Multiplied by 2,628,000 seconds, that is about 122.6 million requests per month. Entering 180 requests per second for the whole month would give 473 million requests, about 3.9 times too high, because the peak lasts only a sixth of each day and the service is billed on total requests, not on the peak rate.
Exercise
A team enters 8 instances at 100 percent utilization for a batch system that runs 6 hours a day, every day. The instances are stopped the rest of the time. What utilization value should they use, and what mistake did they make?
Show answer
Six hours of 24 is 25 percent, about 182.5 hours a month. They entered the full month, so the compute line is four times too high. Billing follows the time instances are running, so stopped instances do not count toward utilization.