Understanding AWS Billing - Credits, cost types, and pricing models with a focus on EC2

2023-09-1013 minute read

Abstract

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.

Introduction

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.

This blog walks through various ways to obtain free credits from AWS, and this guide shares tips on how to effectively use credits.

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:

  1. The soonest to expire amongst the credits
  2. The credit with the least number of eligible services
  3. The oldest of all credits

In organizations:

The order of how credits are applied in an AWS Organization when credit sharing is activated:

  1. Account that owns the credit is covered for the service charges
  2. Credits are applied towards the AWS account with the highest spend
  3. Within the linked account, the charges are grouped by specific fields, and credits are applied to the group with the highest charges
  4. Within this group, credits are applied to the highest charge first

application of shared credits

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.
  • 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.

calculation of AWS costs

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

Billing:

LineItem (They cover all of the cost and usage information for your usage):

  • lineItem/BlendedCost
    • The BlendedRate is multiplied by the UsageAmount.
  • lineItem/LineItemType
    • This includes the type of charge; possible types are:
      • Credit
      • Discount
      • Fee
      • Refund
      • Tax
      • Usage
      • SavingsPlan* (SavingsPlanUpfrontFee, SavingsPlanRecurringFee, SavingsPlanCoveredUsage, SavingsPlanNegation)
      • RIFee
      • DiscountedUsage
      • BundledDiscount
  • lineItem/ProductCode
    • For example, AWS Elastic Compute Cloud -> “Amazon EC2”
  • lineItem/UnblendedCost
    • The UnblendedCost is the UnblendedRate multiplied by the UsageAmount.
  • lineItem/UsageAccountId
    • The account ID of the account that used this line item.
  • lineItem/UsageStartDate
  • lineItem/UsageEndDate
  • Others: https://docs.aws.amazon.com/cur/latest/userguide/Lineitem-columns.html

Product (metadata for products):

  • product/fromRegionCode
    • Describes the source Region code for the AWS service (example: RDS, EC2).
  • product/region
    • The geographical area that hosts your AWS services.
  • product/ProductName
    • The full name of the AWS service.
  • product/servicecode
  • product/description
  • product/fromLocation
    • 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 pricing tiers

EC2 tiersFreeSpotOn-DemandSavings planReserved instanceDedicated hosts
CommitmentNoneNo commitmentNo commitment1 or 3 years1 or 3 yearsOptional RI or savings plan
Potential savings (compared to on-demand)FreeUp to 90% offN/AUp to 70% offUp to 70% offPotential savings on licensing fees
FlexibilityNo flexibilityLimited flexibilityMost flexibleFlexibleLimited flexibilityLimited flexibility
Use-caseSuitable for trialsFault-tolerant workloadsShort term projectsFor predictable workloadsFor predictable workloadsFor 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.

Payment Options:

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.

  1. PriceCapacityOptimized: Requests Spot Instances from pools with a low chance of interruption and lesser price, ideal for most Spot workloads.
  2. CapacityOptimized: Requests Spot Instances from pools with low interruption potential, beneficial for workloads with a high cost from interruption.
  3. Diversified: Distributes Spot Instances evenly across all available pools.
  4. LowestPrice: Acquires Spot Instances from the cheapest pool with available capacity, likely leading to higher interruption rates.
  5. 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:

  1. Right size
    1. Ensure to provision instances that align with your computational needs by factoring in elements such as CPU, memory, storage, and network throughput.
    2. Select appropriate Amazon instance types that fit your usage, utilizing Amazon CloudWatch metrics to assess instance activity and determine the appropriate time to downsize.
    3. As a best practice, streamline and optimize your resources to the right size before making a reservation.
  2. Increase elasticity
    1. Consider stopping or hibernating Amazon EBS-backed instances that are not in active use, such as those deployed for non-production development or testing.
    2. Leverage the functionality of automatic scaling to align resources with usage needs, thereby achieving automated and time-based elasticity.
  3. Choosing a pricing model
    1. 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.
    2. For even more efficiency, you can also consider the Lambda serverless option.
  4. Storage choices Look for ways to reduce costs while maintaining storage performance and availability.
    1. Changing the EBS volume type to HDD from the default SSD can save 50% of the cost.
    2. Employing Amazon S3 storage options using lifecycle policies can help further reduce costs.
    3. Remove EBS snapshots that are no longer required.

Conclusion

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.

References:

  1. https://lemasyma.github.io/cours/posts/aws_module_6/#section-5-amazon-ec2-cost-optimization
  2. https://d1.awsstatic.com/whitepapers/cost-optimization-reservation-models.pdf?did=wp_card&trk=wp_card
  3. https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/useconsolidatedbilling-credits.html
  4. https://docs.aws.amazon.com/cur/latest/userguide/data-dictionary.html
  5. https://aws.amazon.com/ec2/spot/
  6. https://docs.aws.amazon.com/cur/latest/userguide/billing-columns.html#b-P
  7. https://aws.amazon.com/aws-cost-management/aws-cost-explorer/faqs/

Next post

Engineering Behind Our Cost Reports and Dashboards

5 September 2023
engineeringAWSproduct-updates