AWS: cost optimization — purchasing the RDS Reserved Instances
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. 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 (although they also have EC2 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
- AWS Cost Explorer: RDS No Instance type
- Size-flexible reserved DB instances
- Purchasing 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:
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:
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).
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>>>.
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:
“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 — 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:
Take a look at the pricing — db.r5.2xlarge, Offering type — No Upfront:
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:
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 to see that when using the On-Demand one instance will cost 846 dollars:
With the No upfront — 554 dollars:
And with the All upfront — 5541 per year or 461 per month:
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:
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 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:
Still, this is mentioned in the EC2 Reserved Instances documentation:
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:
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:
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:
This also can be found in the Cost explorer running hours costs and usage:
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.
Top comments (0)