AWS: cost optimization — purchasing the RDS Reserved Instances
Tags: aws, todayilearned
Published: 2021-04-22 09:46:09

---
title: AWS: cost optimization — purchasing the RDS Reserved Instances
published: true
date: 2021-04-16 05:44:09 UTC
tags: aws,todayilearned
canonical_url: https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/
---

### AWS: cost optimization — purchasing the RDS Reserved Instances

![](https://cdn-images-1.medium.com/max/1024/1*8QppZuMnRQSngTE4H4UqzA.png)

Currently, I’m actively working on our AWS infrastructure costs optimization and will post a series of posts about this.

The first one will be about [AWS RDS Reserved Instances](https://aws.amazon.com/rds/reserved-instances/). The idea is quite simple: you are committing to use some types of instances for one or three years. Here, you’ll be able to choose to pay the commitment immediately for the whole term, and a discount will be bigger, or partially, or pay month by month as usual. In any case, AWS will give you some discount for the service. This discount can be almost twice per usual On Deman pricing, and below will see some calculations on this.

For the AWS EC2, there is a similar solution, the [Saving Plans](https://aws.amazon.com/savingsplans/) (although they also have [EC2 Reserved Instances](https://aws.amazon.com/ec2/pricing/reserved-instances/), but AWS going to use the Saving Plans as their main discounting offer). I guess (and hope) that AWS will add Saving Plans for RDS as well. The AWS EC2 Saving Plans will be examined in the following post of these services, as we already using them and they also help us to save money.

Keep in mind, that Reserved Instances are working for a specific AWS region, and selected EC2 family type.

At first, let’s go to see our current expenses to determine how much and for what we are paying at this moment.

- [AWS RDS expenses analysis](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/#AWS_RDS_expenses_analysis)
- [AWS Cost Explorer: RDS No Instance type](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/#AWS_Cost_Explorer_RDS_No_Instance_type)
- [Size-flexible reserved DB instances](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/#Size-flexible_reserved_DB_instances)
- [Purchasing RDS Reserved Instances](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/#Purchasing_RDS_Reserved_Instances)
- [Savings with the RDS Reserved Instances](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/#Savings_with_the_RDS_Reserved_Instances)

### AWS RDS expenses analysis

Go to the AWS Cost Explorer, choose RDS in the Filters, and check current payment per instance types:

![](https://cdn-images-1.medium.com/max/1024/0*rVJFiiv0RPB7_Rpc.png)

More than half, 111 USD/day, are spent for the _r5.2xlarge_ instances — this our Aurora RDS Production clusters, and we don’t plan to change this type in the future as they are working great for our needs. Thus, it’s worth purchasing Reserved Instances of this type, just need to find out how many instances do we need.

#### AWS Cost Explorer: RDS No Instance type

The second big part of the expenses is marked as “No Instance type”, 37 USD/day.

To understand, what is included there choose the _Group by_ from the _Instance type_ to the _Usage type_:

![](https://cdn-images-1.medium.com/max/1024/0*vxQ4eRTikxnnLpN9.png)

Here we can see the three payment types: `Aurora:StorageIOUsage` - 16 USD, `Multi-AZUsage:db.t2.xlarge` - 14 USD, `RDS:ChargedBackupUsage` - 8 USD, plus everything other (check also the [Tips and Tricks for Exploring your Data in AWS Cost Explorer](https://aws.amazon.com/blogs/aws-cost-management/tips-and-tricks-for-exploring-your-data-in-aws-cost-explorer-part-2/)).

As we can’t decrease them with the Reserved Instances, then just skip this part.

Go back to te _Group: InstanceType_, and check for the other instances — _db.r5.large_ 27 USD/day, _db.t2.xlarge_ — 14 dollars.

Now, go to your RDS dashboard and count how many of each of them:

- db.r5.2xlarge:
- USA-2 region: Production cluster, 4 instances + Aurora ReadReplica AutoScaling
- db.r5.large:
- USA-2 region: Dev and Stage clusters, 4 instances
- db.t2.xlarge:
- EU-3 region: our analitycs Production, 1 server

So, let’s purchase 4 instances of the **db.r5.2xlarge** type in the Ohio region as we will nap plan to change them in the future.

#### Size-flexible reserved DB instances

Check the documentation [here>>>](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithReservedDBInstances.html).

One moment worth mentioning: remember, that when you are buying a reservation for a specific instance type, in our case this will be the _2xlarge_, its discount also will be applied to the whole **db.r5** family, i.e. for the currently used _r5.large_, and _r5.4xlarge_ if we will use them in the future.

In this regard, EC2 Saving Plans of course much more easy and obvious and I really hope to see them for the AWS RDS.

Let’s go back to our sheep serves.

So, our Dev and Stage clusters can be changed in their instance types, so let’s skip them — will not purchase the r5.large Reserved Instances, but later we will see how the r5.2xlarge’s discount will be applied for them too.

Go to the Billings:

![](https://cdn-images-1.medium.com/max/1024/0*2Og3tB5atR6S1KG1.png)

“USD 1.16 per RDS db.r5.2xlarge”, for the 13 days of Aprile they worked 1168 hours, and we’ve paid 1355 dollars for this — let’s calculate

```
>>> 1355/1168.0
1.16
```

Check the [RDS pricing](https://aws.amazon.com/ru/rds/aurora/pricing/) — db.r5.2xlarge costs 1,16 dollars per hour, everything is correct here.

For one month such an instance will cost us:

```
>>> 1.16*24*30
835.19
```

And per year:

```
>>> 1.16*24*30*364
304012.8
```

Remember these numbers — will see shortly what we’ll get prompted during Reserved Instances purchasing.

### Purchasing RDS Reserved Instances

Go to the _RDS — Reserved instances_, click on the _Purchase Reserved DB Instance_:

![](https://cdn-images-1.medium.com/max/1024/0*b-p2Cq8iFIFjMeJb.png)

Take a look at the pricing — _db.r5.2xlarge_, Offering type — _No Upfront_:

![](https://cdn-images-1.medium.com/max/591/0*nmMGn3sOqXr-phIY.png)

_0.760 USD (hourly)_ — is about 547 dollars per month or 199180 per year (now, as we’ve calculated above, we are paying 835 and 30000 accordinly).

If choose the _All upfront_, i.e. to pay upfront for the next year, then the price will be:

![](https://cdn-images-1.medium.com/max/591/0*8EmxRhlUJ3rxNnL9.png)

5,541.00 USD, or by:

```
>>> 5541/364/24
0.63
```

0,63 dollars per hour — almost doubled from the original price!

Or you can do not struggle with the calculations yourself and just use the [AWS Pricing Calculator](https://calculator.aws/#/createCalculator/AuroraMySQL) to see that when using the _On-Demand_ one instance will cost 846 dollars:

![](https://cdn-images-1.medium.com/max/1024/0*0nbPF-a7I8SKOb5P.png)

With the _No upfront_ — 554 dollars:

![](https://cdn-images-1.medium.com/max/1024/0*hUX4RX8k99EHURWC.png)

And with the _All upfront_ — 5541 per year or 461 per month:

![](https://cdn-images-1.medium.com/max/1024/0*hreZeD7UV41KuHLA.png)

In fact, almost the same numbers as we’ve calculated manually.

And the final thing is just to purchase 4 instances of the r5.2xlarge type:

![](https://cdn-images-1.medium.com/max/863/0*lcqndql-jKuPrcD3.png)

![](https://cdn-images-1.medium.com/max/863/0*YzuhIFAsXaThjQw8.png)

Now, let’s wait a couple of days to see how this will impact our billing.

### Saving with the RDS Reserved Instances

The first surprise on the next day was that AWS billed us for the reservations till the end of the month, although this wasn’t mentioned on the [RDS Reserved Instances](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithReservedDBInstances.html) documentation page (even the screenshot above says “will charge $0.00”), and as we’ve chosen the “_No upfront_” option, I’ve expected it will be charged each hour as it is for the EC2 Saving Plans:

![](https://cdn-images-1.medium.com/max/759/0*zk86sTnyGvMP2fa9.png)

Still, this is mentioned in the EC2 Reserved Instances documentation:

![](https://cdn-images-1.medium.com/max/1024/0*-stGd1N1xht4L775.png)

So, it’s April 13th, and we have 17 days left till the end of the month, let’s take our calculator again:

```
>>> 1343/17/4/24.0
0.82
0.82 dollars.
```

If subtract about 100 dollars per day for all other instance types which are not covered by the Reservations (see the screenshot below of the April 14th), we will get 0.76 dollars per one our of the reserved instance:

```
>>> (1343–100)/17/4/24.0
0.7616421568627452
```

Thus, reservations are working, and this can be seen on the April 14th costs in the Cost Explorer:

![](https://cdn-images-1.medium.com/max/1000/0*lE4zjS4PDemIp2jK.png)

Or you can switch to the Hourly rate and see this even on the next day.

Also, useful graphs can be found in the _AWS Cost Management > Reservations > Utilization report_ — here you can see how your reserved instances are utilized:

![](https://cdn-images-1.medium.com/max/1024/0*lO9qQ3HuAwHB9IXx.png)

All our 4 instances of the r5.2xlarge type are used for 100%, and here we also can see how much we’ve saved money: it would cost us 111 dollars per day if using On-Demand payment, 72 we’ve paid for the reservations, so we’ve saved whole 38 dollars per day.

But in the _Coverage report,_ we can find that we are cover all our r5 instances because as we remember _Size-flexible reserved DB instances_ is applied to all r5 in the region, so part of our reservation was used by four r5.large instances:

![](https://cdn-images-1.medium.com/max/1024/0*aAnpi44tKpkpWi1x.png)

This also can be found in the _Cost explorer running hours costs and usage_:

![](https://cdn-images-1.medium.com/max/1024/0*LWLpMkT_OrxU7evs.png)

Plus Aurora AutoScaling where we have some instances created for a short-life in 10–15 minutes, but they are billed per one hour.

In general, RDS Reserved Instances is a really useful option for saving money, although in some places not too obvious and comfortable.

EC2 Saving Plans is much more flexible, and we will speak about this in the following post.

_Originally published at_ [_RTFM: Linux, DevOps, and system administration_](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/)_._

* * *