AWS Cost Analysis: Amazon RDS Costs
Amazon RDS is a managed database service that makes it easy to spin up, operate and scale relational databases to support any size production infrastructure. RDS is one of Amazon Web Services’ most utilized services and has a complicated billing structure encompassing instance running costs, data transfer costs, and provisioned IOPS and Storage. For more details about RDS, check out the AWS documentation.
How Much Does Amazon RDS Cost?
Customers using RDS in their AWS environment have many different variables to consider before spinning up their RDS infrastructure:
- Which database engine are you going to use? The database engine can impact everything from your cost model, hourly costs, and whether or not you need to pay for a database license from a third-party vendor.
- Which region will this instance (or serverless deployment) be deployed in? RDS costs vary for hourly instance costs, storage, and IOPS.
- Is this a Single-AZ or Multi-AZ deployment? Using a Multi-AZ deployment reduces the risk of infrastructure failures but will double your costs.
- What type of activity are we expecting from this resource? Should we be prepared for high data transfer costs across AWS Regions? How often do we need to perform manual database backups?
All of these decisions have a profound impact on your AWS pricing for RDS. The following guide describes how to isolate each main RDS cost category using the Cost and Usage Report (CUR) and what these different cost categories mean. If there are any questions about this guide, please let us know in your GitHub discussions.
RDS Instance Costs
In this guide, I am grouping AWS RDS charges from the cost and usage report into two categories: Existence and Utilization Costs:
- Existence Cost - RDS costs that are associated with running an instance and not impacted by resource activity. Examples of existence costs include ‘InstanceUsage’ and provisioned I/O and storage costs.
- Utilization Cost - RDS costs that are directly impacted by resource activity. Examples include data transfer costs, RDS backup storage, and Aurora serverless usage.
RDS Existence Costs
RDS Existence Cost categories combine instance running costs (similar to EC2 existence cost) with the provisioned services and capacity required to run your RDS instance. Variables like Database engine, region, and deployment type will impact your existence costs. Existence cost analysis will walk through how to analyze RDS costs in five categories: Instance usage, provisioned I/O, provisioned Storage, Performance Insights, and Database Proxy costs. If you’re looking for RDS pricing you can check out the Amazon RDS Pricing Page.
RDS Instance Usage
RDS Instance usage is the cost associated with running an RDS instance. RDS instances can be deployed as a single or multi-az instance and can be covered with a reserved instance. In the following queries, we will first analyze the on-demand costs for a single or multi-az RDS deployment and then perform the same analysis for RDS instances covered by a reserved instance. In the sections below, the queries will analyze differet RDS Instnace pricing models.On-Demand, Single-AZ Instance Usage
The query below will show single_od_cost by [lineItem/ResourceID], [product/instanceType], and [product/region]. These results will show all RDS instances with a Single-AZ deployment being billed with the on-demand pricing model.
For the query above, here is some background on the fields being used and what the filter values mean:
- [lineItem/ResourceID] - A unique identifier for an RDS instance. You can also use this field in the WHERE clause to narrow the analysis to a single RDS instance.
- [product/instanceType] and [product/region] - These are used to identify the instance type and region for each RDS Instance. These are two key variables that determine the pricing of an instance.
- [lineItem/ProductCode] - ‘AmazonRDS’ is the product code for RDS. Use this field to ensure the analysis focuses on RDS costs.
- [lineItem/LineItemType] - ‘Usage’ is the value used to find results for on-demand pricing. Make sure to filter on ‘usage’ when identifying on-demand costs.
- [lineItem/Operation] - The operation helps narrow down the cost categories. For RDS, ‘CreateDBInstance’ is one of the most common operations to capture existence costs.
- [lineItem/UsageType] - For this query, we filtered on ‘%InstanceUsage%’ to capture everything for a single-az RDS deployment.
On-Demand, Multi-AZ Instance Usage
The query below will show multi_od_cost by [lineItem/ResourceID], [product/instanceType], and [product/region]. These results will show all RDS instances with a Multi-AZ deployment billed with the on-demand pricing model.
There is only one difference in the filters for a Multi-AZ query compared to a Single-AZ query:
- [lineItem/UsageType] - The values ‘%Multi-AZUsage’ marks an instance as a Multi-AZ deployment.
Reserved Instance, Single-AZ Instance Usage
If your RDS Instance is covered with a Reserved Instance you will want to understand your RDS Reserved Instance pricing. The query below will show single_reserved_cost by [lineItem/ResourceID], [product/instanceType], and [product/region]. These results will show all RDS instances with a Single-AZ deployment billed with the reserved instance pricing model.
For the query above, here is some background on the fields used and what the filter values mean:
- Instead of using [lineItem/UnblendedCost] to calculate the total cost, this query uses [reservation/EffectiveCost]. This field will add together two costs that are critical for accurately tracking RI costs:
- Hourly amortization of any upfront fees: If your team purchases any RIs that include an upfront fee, your analysis must amortize the cost for the duration of the RI contract. For example, $8,760 in upfront fees for a 1-year contract must be amortized to $1 per hour of the year.
- Hourly fee: If your team purchases any RIs that include an hourly fee, you must add this to the amortization of upfront fees.
- [lineItem/LineItemType] - ‘DiscountedUsage’ is the value used to find results for reserved instance pricing.
Reserved Instance, Multi-AZ Instance Usage
The query below will show multi_reserved_cost by [lineItem/ResourceID], [product/instanceType], and [product/region]. These results show all RDS instances with a Multi-AZ deployment billed with the reserved instance pricing model.
There is only one difference in the filters for a Multi-AZ query compared to a Single-AZ query:
- This query also uses the [reservation/EffectiveCost] field to calculate the total cost.
- [lineItem/UsageType] - The values ‘%Multi-AZUsage’ denotes the instance is a Multi-AZ deployment.
Total RDS Instance Usage Cost
The query below combines Single-AZ On-Demand, Single-AZ Reserved, Multi-AZ On-Demand, and Multi-AZ Reserved RDS instance costs. The final column of this query, total_running_cost, combines all the different cost types.
Provisioned General Purpose Storage
RDS instance storage comes in many different formats. With General Purpose provisioned storage, you are only charged for the provisioned storage and not any of the IOPS consumed. Storage fees are charged as $ per GB per month. In this query, total cost is isolated as gp2_storage_cost by filtering [lineItem/UsageType] with the value ‘%GP2-Storage%’.
Provisioned IOPS Storage
RDS allows users to provision I/O capacity required for your project. You will be charged a fixed amount for the storage provisioned and the IOPS consumed. To narrow down RDS costs to provisioned IOPS, filter the [lineItem/UsageType] to ‘%PIOPS%’. In this query, we are calculating the total cost as piops_cost.
Provisioned Magnetic Storage
Magnetic storage is a previous generation of storage. AWS recommends upgrading to GP2 or GP3 storage if you currently use Magnetic storage in your infrastructure. That being said, we can identify magnetic_storage_cost by filtering the [lineItem/ResourceId] by ‘%StorageUsage’.
Performance Insights for RDS offer free 7-day retention of performance data and 1M API requests per month for your RDS instance at no charge. From there, users can decide to extend the retention up to 24 months for a fixed cost per vCPU. In this query, total performance insights cost is calculated as pi_cost by filtering [lineItem/Operation] as ‘Retention’ and [lineItem/UsageType] as ‘%PI%’.
Note: this is only the cost for retention of performance insights data. We will query the cost of API calls for performance insights in the Utilization section.
The RDS Proxy is a fully managed, highly available database proxy that makes your application more scalable and resilient to failure. The cost of a DB Proxy is based on the capacity of the underlying instances. The total cost is calculated as db_proxy_cost by filtering [lineItem/Operation] as ‘CreateDBProxy%’ and [lineItem/UsageType] as ‘%ProxyUsage’.
RDS Utilization Cost
The activity of your RDS instance determines RDS Utilization costs. The most common types of Utilization costs for RDS instances are data transfer and backup storage costs. In addition to these categories, there are also Utilization costs for Serverless Aurora RDS usage.
Data Transfer Costs
Data transfer costs include sending data from your RDS instance out of AWS entirely and sending data between different AWS Services or regions. Small operational changes can cause massive data transfer costs if not done correctly. The queries below will provide analysis for isolating the different types of data transfer costs.
Data Transfer for RDS to/from the Internet
Data transfer costs for RDS to/from the internet are charged based on the GB of data being transferred. There is no cost for bringing data from the internet into your AWS environment. There is a tiered pricing model for moving data to the internet, meaning the more data sent, the lower the unit cost.
This query below calculates the data_transfer_cost by filtering the [lineItem/UsageType] to ‘DataTransfer-%’. The field data_transfer_gb is also in this query so you can see the amount of data being transferred when there is no cost.
Data Transfer for RDS to/from AWS Service or Region
If your team sends data between different AWS services or Regions, there may also be costs for that. Using the query below you can calculate the aws_data_transfer_cost by isolating [lineItem/UsageType] fields that contain ‘%-aws-%’. I also added the field aws_data_transfer_gb to calculate the data transfer volume.
Backup storage is the cost associated with automated and manual database backups. These costs are charged at a fixed rate of $ per GB per month based on the region the backups are stored in. This query calculates the backup-storage-cost by isolating [lineItem/UsageType] values that contain ‘%ChargedBackupUsage%’.
Aurora Consumption Billing
Amazon Aurora allows customers to run Aurora Serverless or to provision an instance for their workloads. Serverless Aurora, Aurora Storage, and I/O have usage-based billing models. The queries below will show how to identify each of these costs.
Aurora has a serverless offering from AWS that is billed per usage second. This model is great for highly dynamic workloads that don’t require an instance to run at all times. Everything is priced based on usage. The query below compiles the Aurora Serverless costs as aurora_serverless_cost and is identified by isolating [lineItem_UsageType] values that contain ‘Aurora:Serverless%’.
Regardless of whether a customer chooses Aurora Serverless or a provisioned database instance, the Storage costs are driven by usage. These costs can be isolated by filtering the [lineItem/UsageType] field for ‘Aurora:StorageUsage’ values.
Whether a customer chooses Aurora Serverless or a provisioned database instance, the I/O costs are based on usage. These costs can be isolated by filtering the [lineItem/UsageType] field for ‘Aurora:StorageIOUsage’ values.
API Requests for Performance Insights
We analyzed the retention costs for performance insights in the existence cost section. The second cost associated with performance insights is the cost per API call. The first 1M API calls are free; after that, the API calls are charged at $0.01 per 1,000 API calls. The count of API calls and the associated costs can be isolated by filtering the [lineItem/Operation] field as ‘Call’ and the [lineItem/UsageType] field by ‘%API%’.
Total RDS Instance Cost
All the queries until now have been used to isolate specific cost categories for RDS resources. This next section will walk through how to isolate specific instances to understand their costs over time. The table below can be used as a reference guide for mapping [lineItem/LineItemType] and [lineItem/Operation] to cost categories with an explanation of which costs are captured there.
Total RDS Instance Cost
Total Cost by Category
The following query will show total cost by [lineItem/LineItemType], [lineItem/Operation], and [lineItem/UsageType]. Since we potentially include costs from reserved instances, we will have to sum both the [lineItem/Unblendedcost] and [reservation/EffectiveCost] fields. In addition to total costs, since some types of usage are not billed, we also include [lineItemUsageAmount] and the [pricing/unit] to provide visibility into usage.
This query is limited to analyzing RDS costs and removes any ‘Tax’ expenses from the results.
With this base query understood, two variations are helpful depending on the specific questions that need to be answered:
Total Cost by RDS Instance
We can see the total cost by instance and resource category if we take the base query and add [lineItem/ResourceID] in the SELECT, GROUP BY, and ORDER BY statements. This query can return a significant number of search results but is helpful when trying to understand which instances are driving your costs.
Total Cost by RDS Instance by Hour
Once you understand which RDS Instances are costing the most in your environment, you can simply add the [lineItem/UsgaeStartDate] field into your query to track costs over time. To isolate the cost of a single RDS instance, remove the [lineItem/ResourceID] from the SELECT, GROUP BY, and ORDER BY statements and add it to the WHERE statement with a resource ID. Replace the variable insert-rds-are-here with the ARN of your RDS instance.
Strake has agreed to assume ownership and maintenance of the AWS Pricing add-on for Google Sheets. The AWS Pricing add-on allows AWS users to query public AWS Pricing data using customer Google Sheets functions. Strake is committed to keeping the project open-source and is excited to continue building on the idea Mike Heffner brought to the AWS community.
Elastic Compute Cloud (EC2) is the backbone of AWS. EC2 allows customers to access hundreds of different instance types across the globe in seconds. This guide walks through the different types of EC2 costs and how to isolate them using SQL analysis on your Cost and Usage Report (CUR). If you don’t have a CUR active in your account, you can check out the first guide which walks through permissions and the process of creating a CUR.