Amazon Relational Database Service (RDS) is a managed service that allows you to easily deploy database servers for your applications.
RDS supports a variety of open source database engines, including MySQL, MariaDB, and PostgreSQL. Other proprietary database engines are supported, including Microsoft SQL Server, Oracle, and IBM Db2. When you’re building a business application, using RDS for your database reduces the amount of effort required to spin it up and maintain it over its lifecycle.
When you deploy a new Amazon RDS instance, you can select an “instance type” which allocates a certain number of virtual CPUs and memory to your database server. This service is built on top of Amazon EC2, so you’ll see some of the same instance types available in RDS.
The costs for each instance type varies; more vCPUs and memory results in a higher cost. Some instance types are intended for databases that consume large amounts of memory, but don’t necessarily need a significant number of CPU cores.
Check out the Amazon RDS pricing page for full details on the available instance types.
When you resize an Amazon RDS instance, it must be shutdown and rebooted to apply the new instance type. This reboot is handled by the RDS service once you apply the change. The RDS service defers instance class changes to a scheduled maintenance window, or you can elect to apply the change immediately.
One unique feature of the Amazon RDS service is that you can easily switch from Intel / AMD 64-bit CPU architectures to ARM-based Graviton CPUs, or vice versa. The instance classes that end with a “g” indicate that they use Graviton CPUs. For example, t4g, m7g, and r7g, are all Graviton-powered RDS instance classes.
Stratusphere™ FinOps is a SaaS application that helps you identify cost savings opportunities in the cloud, across your entire organization. To find specific cost savings opportunities for RDS DB instance resizing, head over to the Findings section. Then, specify the Amazon Relational Database Service under the Service filter, and choose Efficiency under the Categories.
The specific Finding that you’re looking for is called “Amazon RDS Idle DB Instances.” This will inform you of any RDS instances that have not had a database connection for 7 days or more. Under the Resource ID column, you can see the Amazon Resource Name (ARN) of the specific RDS database instance that is idle.
After you’ve identified the list of RDS instances that are ripe for deletion or down-sizing, you can run through the steps in the Remediation section below.
Before you resize an Amazon RDS database instance, there are several risks and other details that you should be aware of.
To remediate Amazon RDS idle instances, simply remove the database server from your AWS account.
To delete an RDS instance from your account, you can follow these steps.
After initiating the process, it may take a few minutes for your Amazon RDS instance to be deleted.
You can also consider resizing your RDS instances, after they’ve been provisioned. This technique allows you to scale down your database servers, therefore reducing cloud spend, but still keeping the database accessible to business applications.
Follow these steps to resize your Amazon RDS instance.
After following the above steps, your Amazon RDS instance will be resized in the background. It will take several minutes to perform the resizing operation. This resize operation will result in downtime for your database. Make sure you plan this change and notify users about application outages in advance.
You can use automation tools for AWS, such as the AWS CLI or AWS PowerShell module, to delete or resize Amazon RDS instances. The API call that deletes RDS instances is called DeleteDBInstance, and the API that modifies the Amazon RDS instance type is called ModifyDBInstance. You can find a list of the supported DB instance classes in this AWS documentation.
As with any AWS automation, you’ll need to configure your AWS credentials in order to access the AWS APIs for your account.
You can use the AWS CLI tool to perform remediations across a large number of Amazon RDS instances. This is especially useful to automate if you’re dealing with many instances split across different AWS regions and accounts.
By default, RDS takes a final snapshot, before deleting the RDS instance, to prevent data loss. You can optionally skip this snapshot, using the parameter shown.
By default, the AWS CLI produces paged output, but this is not desirable for silent automation scripts. Use the --no-cli-pager parameter to alter this behavior.
aws rds delete-db–instance --db-instance-identifier stratusgrid01 --skip-final-snapshot --no-cli-pager
If you are sure that you need to keep the RDS instance around, you can resize it to a smaller, less expensive DB instance type. The command below shows how to accomplish this.
aws rds modify-db-instance --db-instance-identifier stratusgrid01 --db-instance-class db.t3.small --apply-immediately
If you do not have a default region set, or need to target a different region, you can also specify the region that you’re operating against, by using the --region parameter.
You can use the AWS RDS module for PowerShell to automate RDS instance deletion. You’ll want to use the Remove-RDSDBInstance command, in the AWS.Tools.RDS module. Make sure you specify the RDS instance name, and skip the final snapshot, if desired. The -Force parameter prevents interactive confirmation prompts from popping up during script execution.
Remove-RDSDBInstance -DBInstanceIdentifier stratusgrid01 -SkipFinalSnapshot $true -Force
If you’re confident that you need to keep the RDS instance in your account, you can reduce spend by resizing it to a smaller RDS instance type. The Edit-RDSDBInstance PowerShell command allows you to modify the configuration of an existing RDS instance.
Edit-RDSDBInstance -DBInstanceIdentifier stratusgrid01 -DBInstanceClass db.t4g.micro -ApplyImmediately $true
You can use the -Region parameter for AWS PowerShell commands to specify an alternative region, depending on where the RDS instance resides.
Depending on the API call you make, to change the configuration of your Amazon RDS instance, you might receive different error messages. Let’s take a look at a couple of errors and how to resolve them.
You can save large amounts of potential spend, across your entire AWS Organization, by identifying unused Amazon RDS instances with Stratusphere™ FinOps, and cleaning them up. The effort required to delete an RDS instance is very low, making it an easy way to reduce your monthly cloud spend.
For applications with certain data schemas, you may want to consider modernizing your architecture with a fully-managed NOSQL database. Using a managed database service, such as Amazon DynamoDB, can simplify cost and performance scaling with its on-demand performance mode.
StratusGrid can consult with you to strategize and implement a modernized architecture for your cloud workloads. Contact us today for more information.
BONUS: Download Your FinOps Guide to Effective Cloud Cost Optimization Here ⤵️