AWS billing is complex. We detail the computation to be followed to go from the sticker price on the website to the actual bill you see on your AWS account. We start with a high-level overview of the different factors that can contribute to the bill and how they are interpreted, including pricing models, cost types, and strategies associated with AWS EC2 usage. We then dive into the different ways AWS provides to visualize costs.
The pricing models and cost types of AWS’s services have differences based on usage, size of company, regions, and even custom pricing agreements your team might have with AWS. Here, we break the common pricing models, types of costs, and credits down and also explore how these costs are made available through AWS Cost Explorer and AWS Cost and Usage Reports (CUR).
Part 1: AWS Credits
AWS Credits are promotional credits given by AWS that can be added to your account. Once added, they are automatically applied for eligible services until they are exhausted or expired.
The credits can be applied to a single account or to organizations as a whole through credit sharing; the difference is shown below.
In single accounts:
If an AWS account has more than one credit, the available credits apply in the following order:
The order of how credits apply if an AWS account has more than one credit:
- The soonest to expire amongst the credits
- The credit with the least number of eligible services
- The oldest of all credits
The order of how credits are applied in an AWS Organization when credit sharing is activated:
- Account that owns the credit is covered for the service charges
- Credits are applied towards the AWS account with the highest spend
- Within the linked account, the charges are grouped by specific fields, and credits are applied to the group with the highest charges
- Within this group, credits are applied to the highest charge first
Part 2: Cost types
AWS cost reports data are usually calculated in one of three ways - to show costs as amortized, blended, or unblended.
- Amortized Costs: It represents the effective daily rate of prepaid fees, combined with monthly reservation fees, including applied discount rates, and spread across the billing period.
- For example, if you pay $365 for an All Upfront RI for one year and you have a matching instance that uses that RI, that instance costs you $1 a day, amortized.
- How is it calculated?
(prepaid fees + reservations) / days
- Use it to see more accurate spending trends that include EC2 usage costs and reservation fees.
- Unblended Costs: Cost is presented on a cash basis, reflecting usage on the day it is charged. This is the default setting, and amounts are calculated at a resource view.
- How is it calculated?
Rate x usage
- Use it to view the amount of discount received per resource.
- How is it calculated?
- Blended Costs: Blended costs are the averaged rates of the reserved and on-demand instances that are used by member accounts that are consolidated under a single billing account. AWS calculates blended costs by multiplying the blended rate for each service with an account’s usage of that service.
- How is it calculated?
Blended rate x account’s usage of service
- Use it to have a consolidated view of member accounts in an AWS parent organization.
- How is it calculated?
Part 3: Inspecting your costs
AWS provides two services to inspect and report your AWS cost information - the AWS Cost Explorer provides a visual representation of costs along with multiple filters and options, and the AWS Cost and Usage Reports provides a more comprehensive set of AWS Cost data, usually exported to a connected S3 bucket.
AWS Cost Explorer:
AWS Cost Explorer provides a visual tool to dive into your AWS costs and usage. It provides ready-to-use reports and allows you to create up to 50 custom ones with filters for service, region, and account.
EC2-Other is the combination of the following costs:
- EBS Volume and Snapshot costs
- NAT gateway usage charges
- CPU credits from t-family EC2 instances
- Idle IP address usage charges
- Data transfer costs
AWS Cost and Usage Reports:
You can get daily reports in CSV format detailing your costs by hour, product, or custom tags and view them using any spreadsheet software or the Amazon S3 API. Each report contains line items for each unique combination of AWS products, usage types, and operations that you use in your AWS account. You can adjust the reports to show information in hourly, daily, or monthly formats.
You can configure AWS CUR to:
- Deliver report files to your Amazon S3 bucket
- Update the report up to three times a day
- Create, retrieve, and delete your reports using the AWS CUR API Reference
The AWS Bill category 'Elastic Compute Cloud' combines EC2 instance running costs, NAT Gateway, EBS, and all EC2 costs except data transfer.
Data transfer is shown separately as “Data Transfer,” which is the combined data transfer rate for all services.
Further, there is the concept of a Data Dictionary, which is explained in the below section.
Part 4: Data dictionary
If you are using the AWS Cost and Usage reports the AWS Data dictionary provides definitions for all the terms you’d see in the reports. These are the most relevant columns from the AWS Cost and Usage Report (CUR):
Identity (Used for identifying line items in the report):
- identity/LineItemId and identity/TimeInterval
- The type of bill that this report covers. (Anniversary, Purchase, Refund)
- AWS, AISPL, etc.
- Other: https://docs.aws.amazon.com/cur/latest/userguide/billing-columns.html
LineItem (They cover all of the cost and usage information for your usage):
- The BlendedRate is multiplied by the UsageAmount.
- This includes the type of charge; possible types are:
- SavingsPlan* (SavingsPlanUpfrontFee, SavingsPlanRecurringFee, SavingsPlanCoveredUsage, SavingsPlanNegation)
- This includes the type of charge; possible types are:
- For example, AWS Elastic Compute Cloud -> “Amazon EC2”
- The UnblendedCost is the UnblendedRate multiplied by the UsageAmount.
- The account ID of the account that used this line item.
- Others: https://docs.aws.amazon.com/cur/latest/userguide/Lineitem-columns.html
Product (metadata for products):
- Describes the source Region code for the AWS service (example: RDS, EC2).
- The geographical area that hosts your AWS services.
- The full name of the AWS service.
- Describes the source Location code for the AWS service (example: CloudFront, Data Transfer).
- Others: https://docs.aws.amazon.com/cur/latest/userguide/product-columns.html
Part 5: Pricing Models
There are five different ways in which you can purchase AWS EC2 usage.
- On-demand Pricing: With On-Demand Instances, you pay for the compute capacity by the second (min. 60 seconds) or hour with no long-term commitments. You have full control over the instance's lifecycle.
- Reserved instances: In this model, you commit to using AWS services for a long period of time—1 or 3 years with the advantage of receiving better discounts. AWS offers several ways to pay for RIs, including no upfront, partial upfront, and all upfront. However, you are billed for all reserved instances, even if you do not use all capacity.
- Savings Plans: Savings Plans offer significant savings over On-Demand Instances, just like EC2 Reserved Instances, in exchange for a commitment to use a specific amount of compute power (measured in $/hour) for a one or three-year period.
- How is it different from Reserved Instances? At a high level, you don’t need to purchase RIs for a given instance type. Instead, you commit to a baseline level of spend per hour on compute that you’ll pay regardless of actual use. Anything at or below that usage level is included; anything above it, you’ll pay at the existing on-demand rates.
- Spot instances: A Spot Instance is an instance that uses spare compute capacity that is available for less than the On-Demand price. A spot instance may be terminated at any time, whenever AWS needs this compute capacity.
- Dedicated hosts: An Amazon EC2 Dedicated Host is a server only for your use, which can help meet your company's compliance needs. It works with AWS License Manager, a tool that simplifies your software license management. You can set your license terms and preferences for host allocation and capacity use in License Manager. AWS then handles these tasks for you, letting you easily launch virtual machines on Dedicated Hosts.
Benefits of using a dedicated host include:
- Saving money by using existing software licenses
- Helping meet compliance requirements with a server dedicated just for your use
- Automatic host maintenance to ensure your workload's availability, even in the event of a host degradation
AWS EC2 is also available in the free tier with 750 hours/month of t4g.small, t2.micro, or t3.micro, depending on your region.
|EC2 tiers||Free||Spot||On-Demand||Savings plan||Reserved instance||Dedicated hosts|
|Commitment||None||No commitment||No commitment||1 or 3 years||1 or 3 years||Optional RI or savings plan|
|Potential savings (compared to on-demand)||Free||Up to 90% off||N/A||Up to 70% off||Up to 70% off||Potential savings on licensing fees|
|Flexibility||No flexibility||Limited flexibility||Most flexible||Flexible||Limited flexibility||Limited flexibility|
|Use-case||Suitable for trials||Fault-tolerant workloads||Short term projects||For predictable workloads||For predictable workloads||For larger teams with expensive licenses & sensitive workloads|
Part 5a: EC2 Savings Plans
Savings Plans are a flexible pricing model offering lower prices compared to On-Demand pricing, in exchange for a specific usage commitment (measured in $/hour) for a one- or three-year period.
AWS offers three types of Savings Plans – Compute Savings Plans, EC2 Instance Savings Plans, and SageMaker Savings Plans. Compute Savings Plans apply to usage across Amazon EC2, AWS Lambda, and AWS Fargate. The EC2 Instance Savings Plans apply to EC2 usage, and SageMaker Savings Plans apply to SageMaker usage.
Savings Plans are available in 3 different payment options:
- The No Upfront option does not require any upfront payment, and your commitment will be charged purely on a monthly basis.
- In the Partial Upfront option, you will be charged at least half of your commitment upfront, and the remaining will be charged on a monthly basis.
- With the All Upfront option, you will receive the lowest prices, and your entire commitment will be charged in one payment.
How Savings Plans are applied (with various scenarios): https://docs.aws.amazon.com/savingsplans/latest/userguide/sp-applying.html
Part 5b: EC2 Reserved instances
In reserved instances, you make a one-year or three-year commitment for the specific resource capacity in a specific Availability Zone.
If you have prepaid usage that isn’t required any longer, you can choose to sell it in the AWS Reserved Instance marketplace. Here, you can list the instances of even a few months.
Here’s the difference between prepaid fees and reservations:
If you pay a partial fee upfront (remember the three options for RIs: no upfront, partial upfront, all upfront), then that is added to the monthly installments. (prepaid fees + reservations)
If you don't pay an upfront (prepaid) fee, then that is basically covered by monthly installments. (0 + monthly installments)
If you pay the complete fee upfront, then no monthly installments are made, which means (prepaid fees + 0).
Part 5c: EC2 Spot Instances
Spot instances use spare EC2 capacity whenever it is available. They are offered at a steep discount when compared to on-demand prices, and the pricing varies with each Availability Zone. They are a cost-effective choice for running applications that can be interrupted, such as batch jobs or background processing tasks.
You can view savings from purchasing Spot Instances at the per-fleet level, and this information is available from the last hour to the last three days. Current EC2 Spot instance pricing is available here, and you can check your spot price history on your console here.
The Spot price is the cost of using extra capacity for each instance type in each Availability Zone. It changes depending on the long-term supply and demand for EC2's extra capacity.
You can set a maximum price for your Spot Instance use, but if not, it defaults to the On-Demand price. Despite setting a high maximum price, it doesn't ensure your Spot Instance will launch, nor does it prevent your Spot Instance from being interrupted by EC2 if they need their capacity back.
It's advised to let the maximum price default to the On-Demand price. Remember, you only pay the Spot price active during your Spot Instance operation.
Check out these Allocation strategies for Spot Instances to get resources based on your specific tasks. Here’s a one-line brief of what each strategy offers.
- PriceCapacityOptimized: Requests Spot Instances from pools with a low chance of interruption and lesser price, ideal for most Spot workloads.
- CapacityOptimized: Requests Spot Instances from pools with low interruption potential, beneficial for workloads with a high cost from interruption.
- Diversified: Distributes Spot Instances evenly across all available pools.
- LowestPrice: Acquires Spot Instances from the cheapest pool with available capacity, likely leading to higher interruption rates.
- InstancePoolsToUseCount: Allocates target capacity evenly across a specified number of lowest priced Spot pools, providing flexibility to meet target capacities even if individual pool capacities are insufficient.
Part 6: Achieving optimal costs
While choosing on-demand EC2 instances can provide the most flexibility for your workload, there is a significant amount of money that can be saved by choosing the right type of instance based on your workload.
As we have seen in the above pricing models for EC2, we can save by either paying for longer term and reserving larger instances to have predictable computing power or by choosing spot instances.
Four key factors should be considered when thinking about optimizing for costs:
- Right size
- Ensure to provision instances that align with your computational needs by factoring in elements such as CPU, memory, storage, and network throughput.
- Select appropriate Amazon instance types that fit your usage, utilizing Amazon CloudWatch metrics to assess instance activity and determine the appropriate time to downsize.
- As a best practice, streamline and optimize your resources to the right size before making a reservation.
- Increase elasticity
- Consider stopping or hibernating Amazon EBS-backed instances that are not in active use, such as those deployed for non-production development or testing.
- Leverage the functionality of automatic scaling to align resources with usage needs, thereby achieving automated and time-based elasticity.
- Choosing a pricing model
- Streamline your costs by combining different purchase types based on your workload - for instance, deploying On-Demand Instances for scaling workloads and Spot Instances for data processing, while utilizing Reserved Instances for predictable, steady workloads.
- For even more efficiency, you can also consider the Lambda serverless option.
- Storage choices Look for ways to reduce costs while maintaining storage performance and availability.
- Changing the EBS volume type to HDD from the default SSD can save 50% of the cost.
- Employing Amazon S3 storage options using lifecycle policies can help further reduce costs.
- Remove EBS snapshots that are no longer required.
AWS billing is complex and this guide is meant to provide a high level explainer for platform teams and the CIO/CTO orgs. Understanding the different pricing models, cost types, and credits available to you is the first step towards optimizing costs.
Using AWS Cost Explorer and Cost and Usage Reports, you can further inspect and dive into the details of your AWS spending across services. Further, leveraging your credits can help you do more for less. Argonaut helps companies optimize their AWS costs by providing a platform to visualize and manage their cloud spend. This is free for all users to leverage. Sign up here to get started.
This whitepaper was written in collaboration with Aadhav, a backend engineer who built out the AWS cost reporting module at Argonaut.