Skip to main content
Cost Optimization Techniques
for AWS PostgreSQL
Mydbops MyWebinar - 40
Jan 24th, 2025
Consulting
Services
Consulting
Services
Managed
Services
❏ Database Management and Consultancy Provider
❏ Founded in 2016
❏ Assisted 800+ happy customers
❏ AWS Service Delivery Partner(RDS)
❏ PCI & ISO Certified
About Us
❏ Why is cost optimization in crucial?
❏ Inventory
❏ Instance type downgrade based on CPU usage
❏ Instances with provisioned IOPS
❏ RDS Storage reduction
❏ Snapshots
❏ Amazon graviton instances
❏ Reserved instances
❏ Cost saving summary
❏ Best practises
Agenda
Why Cost Optimization?
❏ Control and reduce unnecessary spending
❏ Reducing over-provisioning of hardware
❏ Alligining costs with business needs
❏ Prevent budget overruns
❏ Increase business agility
Why cost optimization?
Disclaimer
❏ All price calculations are made using the AWS Pricing Calculator and
are approximate values
❏ All the prices mentioned is in US Dollars
❏ The prices are calculated for on-demand and reserved instance types
and is on a monthly basis
❏ The cost for reserved instances are calculated assuming no upfront
payment and for a period of one year.
AWS Inventory
Inventory
Aurora Instances :
AWS Account-1
DB instance types Number
db.r5.16xlarge 2
db.t3.medium 2
db.t4g.medium 2
db.m5.24xlarge 1
db.m6g.4xlarge 1
db.m5.xlarge 1
db.m6g.xlarge 1
RDS Instances :
DB instance types Number
db.r6.8xlarge 6
db.r6g.xlarge 4
db.r6g.2xlarge 4
db.r6.4xlarge 3
db.r5.8xlarge 3
db.r6g.xlarge 3
db.r6g.16xlarge 2
db.r6g.large 1
Inventory
Aurora Instances :
AWS Account-3
DB instance types Number
db.r5.24xlarge 3
AWS Account-2
RDS Instances :
DB instance types Number
db.m5.2xlarge 1
AWS Account-4
RDS Instances :
DB instance types Number
db.m6g.large 4
Instance type downgrade based on CPU usage
Instance type downgrade based on CPU usage
Proposed instance downsizing based on CPU usage analysis for 2-3 weeks :
AWS account 1
Instance type
Proposed
Instance type
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Average CPU
usage
Savings with
Reserved
Instance
Savings with
On-demand
Instance in $
db.r6g.8xlarge db.r6g.4xlarge 2,268.40 3,449.98 <20% 1134.2 1724.99
db.r6g.16xlarge db.r6g.12xlarge 4,536.88 6,899.23 <10% 1134.23 1724.99
db.r6g.2xlarge db.r6g.xlarge 567.14 862.13 <15% 281.61 430.7
db.r6g.2xlarge db.r6g.xlarge 567.14 862.13 <15% 281.61 430.7
db.r5.8xlarge db.r5.4xlarge 2,536.02 3,854.40 <15% 1268.01 1927.2
db.r5.8xlarge db.r5.4xlarge 2,536.02 3,854.40 <20% 1268.01 1927.2
db.t3.medium db.t3.small 120.23 154.76 20% 60.08 77.41
db.r6g.8xlarge db.r6g.4xlarge 2,268.40 3,449.98 <15% 1134.4 1724.99
db.t4g.medium db.t4g.small 96.43 121.91 <15% 48.25 60.59
Total Savings: $6,752.16 $10,244.85
Instance type downgrade based on CPU usage
AWS account 2
AWS account 3
Instance type
Proposed
Instance type
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Average CPU
usage
Savings with
Reserved
Instance
Savings with
On-demand
Instance in $
db.r5.24xlarge db.r5.16xlarge 7,608.06 11,563.20 <20% 2536.02 3854.4
Total Savings: $2,536.02 $3,854.40
Instance type
Proposed
Instance type
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Average CPU
usage
Savings with
Reserved
Instance
Savings with
On-demand
Instance in $
db.m6g.large db.t3.medium 211.26 329.96 <20% 91.03 175.2
db.m6g.large db.t3.medium 211.26 329.96 <20% 91.03 175.2
Total Savings: $182.06 $350.40
Instance type downgrade based on CPU usage
Total cost reduction per month by changing the instances type from all the AWS accounts:
For Reserved instances $9470.24
For On-demand instances $14449.65
Instances with provisioned IOPs
Instances with Provisioned IOPS
Provisioned IOPS usage has been analyzed for 2-3 weeks, and suggestions have been provided accordingly :
AWS account 1
AWS account 2
Instance type Storage allocated Provisioned IOPS
Average IOPS
usage
db.t3.medium 100 GB 4000 500-600
Instance type Storage allocated Provisioned IOPS Average IOPS usage
db.m6g.large 100 GB 3000 300-350
db.m6g.large 100 GB 3000 100-200
db.m6g.large 100 GB 3000 1500-2000
Instances with Provisioned IOPS
Instead of using Provisioned IOPS, we can switch to GP3 storage, offering the same IOPS
performance at a lower cost.
Instance type Storage
Provisioned
IOPS
Cost of
Provision IOPS
+ Storage
Cost of GP3
storage
Savings by
changing
Storage in $
db.t3.medium 100 GB 4000 862.2 26.2 836
db.m6g.large 100 GB 3000 653.2 26.2 627
db.m6g.large 100 GB 3000 653.2 26.2 627
db.m6g.large 100 GB 3000 653.2 26.2 627
Total Savings: $2,714
RDS Storage Reduction
Storage Reduction
Proposed instances optimized based on storage usage analysis over the past 2-3 weeks. Adjusting the allocated
storage can help reduce storage costs and decrease snapshot sizes, resulting in additional savings.
AWS account 1
Instance type
Storage allocated
in GB Data size in GB Free Storage Free storage %
Proposed
allocated Storage
in GB
db.t3.medium 404 GB 14 GB 393 GB 98% 150 GB
db.m5.xlarge 250 GB 12 GB 238 GB 95% 100 GB
db.t4g.medium 1100 GB 25 GB 1075 GB 97% 400 GB
db.t3.medium 100 GB 7.42 GB 92.58 GB 92% 50 GB
db.m6g.xlarge 20 GB 11 MB 19.99 GB 99% 6 GB
Storage Reduction
AWS account 2
Instance type
Storage allocated
in GB Data size in GB Free Storage Free storage in %
Proposed
allocated Storage
in GB
db.m6g.large 100 GB 75 MB 99.99 GB 99% 30 GB
db.m6g.large 100 GB 8445 KB 99.99 GB 99% 30 GB
db.m6g.large 100 GB 3000 MB 99.97 GB 99% 30 GB
Total storage reduction 1168 GB
Total Savings $232.13
Storage Reduction
Note: To achieve the storage reduction, a logical rebuild is required.
Logical
Replication
Snapshots
Snapshots
❏ Taking a DB copy, used for restoration , new instance creation
❏ Manual RDS snapshots are retained indefinitely, leading to ongoing
monthly storage costs—review and delete unused snapshots to
optimize expenses and achieve cost savings
Snapshots
AWS account 1
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Cost in $
ident1 September 2021 3403 323.29
ident2 February 2022 5965 566.67
ident3 March 2022 6521 619.5
ident4 March 2022 11404 1,083.38
ident5 May 2022 11808 1,121.76
ident6 May 2022 11146 1,058.87
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Cost in $
ident7 July 2022 6050 574.75
ident8 February 2022 7999 759.9
ident9 May 2022 8999 854.9
ident10 January 2022 6999 664.9
ident11 March 2021 348 33.06
ident12 March 2021 348 33.06
ident13 March 2021 348 33.06
ident14 May 2021 538 51.11
Total Savings: $7,778.21
Snapshots
Snapshots
AWS account 2
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Monthly Cost in $
ident1 March 2021 6070 576.65
ident2 March 2021 5543 526.59
ident3 July 2021 12029 1,142.76
ident4 September 2021 13,760.00 1,307.20
ident5 December 2021 13,083.00 1,242.88
ident6 January 2022 16,262.00 1,544.89
ident7 January 2022 14,989.00 1,423.95
ident8 February 2022 16,756.00 1,591.82
ident9 April 2022 18,699.00 1,776.40
ident10 April 2022 18,644.00 1,771.18
ident11 April 2022 18,612.00 1,768.14
Snapshots
AWS account 2
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Monthly Cost in $
ident12 April 2022 18,650.00 1,771.75
ident13 April 2022 18,651.00 1,771.85
ident14 April 2022 18,566.00 1,763.77
ident15 April 2022 18,034.00 1,713.23
ident16 April 2022 17410 1,653.95
ident17 April 2022 17,331.00 1,646.44
ident18 April 2022 16,878.00 1,603.41
ident19 April 2022 16,701.00 1,586.60
ident20 May 2022 18,705.00 1,776.97
ident21 September 2022 7691 730.64
ident22 September 2022 18,796.00 1,785.62
ident23 September 2022 18,727.00 1,779.07
Total Savings: $34,255.76
Snapshots
AWS account 3
AWS account 4
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Monthly Cost in $
ident1 January 2022 148 14.06
ident2 March 2022 163 15.48
ident3 April 2022 180 17.10
ident4 April 2022 180.00 17.10
Total Savings: $63.74
Snapshot Identifier Snapshot creation date Snapshot Size in GB Snapshot Monthly Cost in $
ident1 August 2022 100 9.5
ident2 August 2022 100 9.5
ident3 September 2022 100 9.50
ident4 December 2021 100.00 9.50
ident5 August 2022 100.00 9.50
ident6 August 2022 100.00 9.50
ident7 September 2022 100.00 9.50
ident8 October 2022 100.00 9.50
ident9 September 2022 100.00 9.50
Total Savings: $85.50
Snapshots
Total cost of Manual snapshots for all the AWS accounts combined
Note:
Snapshot costs are calculated based on allocated RDS storage; old snapshots can be moved to AWS Deep Glacier for
significantly lower costs compared to S3. Below is a cost comparison.
S3 Standard - General purpose storage Glacier Deep Archive
Total Savings $42183.21
Storage Cost
First 50 TB / Month $0.025 per GB
Next 450 TB / Month $0.024 per GB
Over 500 TB / Month $0.023 per GB
Storage Cost
All Storage / Month $0.002 per GB
Amazon Graviton Instances
Amazon Graviton Instances
AWS has introduced Amazon Graviton Instance types (M6g and R6g) for Amazon RDS and Aurora, offering better
cost-performance compared to x86 counterparts. Supported by PostgreSQL 12.3+ for RDS and 11.9+ for Aurora,
Graviton 2 instances deliver up to
● 52% price/performance
● 7x the performance, 4x the compute cores, and faster memory and floating-point performance over
first-generation Graviton processors
● 50% faster encryption performance per core
Additionally, migrating to Graviton 2 from Intel requires no code changes or porting for RDS and Aurora.
Reference:-
https://aws.amazon.com/blogs/database/key-considerations-in-moving-to-graviton2-for-amazon-rds-and-amazon-a
urora-databases/
Amazon Graviton Instances
AWS account 1
Instance type
Equivalent
graviton
Instance
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Savings with
Graviton Reserved
Instance
Savings with
Graviton On-demand
Instance
db.r5.16xlarge db.r6g.16xlarge 23,159.60 26,908.94 1,394.92 1,341.53
db.r5.16xlarge db.r6g.16xlarge 23,159.60 26,908.94 1,394.92 1,341.53
db.t3.medium db.t4g.medium 226.08 260.61 24.28 32.24
db.r5.
8xlarge db.r6g.8xlarge 2,536.71 3,855.09 267.62 404.42
db.r5.8xlarge db.r6g.8xlarge 2,536.71 3,855.09 267.62 404.42
Amazon Graviton Instances
AWS account 2
Instance type
Equivalent
graviton Instance
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Savings with
Graviton
Reserved
Instance
Savings with
Graviton
On-demand
Instance
db.r5.8xlarge db.r6g.8xlarge 2,536.71 3,855.09 267.62 404.42
db.m5.xlarge db.m6g.xlarge 538.69 804.26 50.67 78.84
db.t3.medium db.t4g.medium 982.43 1,016.96 23.8 32.85
db.r5.large db.r6g.large 159.1 241.59 16.64 25.55
Total: $3,708.80 $4,065.80
Amazon Graviton Instances
AWS account 3
Total cost saving after switching to Graviton machines for all AWS account
Instance type
Equivalent
graviton
Instance
Cost with
Reserved
Instance
Cost with
On-demand
Instance
Savings with
Graviton
Reserved
Instance
Savings with
Graviton
On-demand
Instance
db.m5.2xlarge db.m6g.2xlarge 1,003.49 1,534.64 101.25 157.68
Total: $101.25 $157.68
For Reserved instances $3,809.34
For On-demand instances $4,223.48
Reserved Instances
❏ Cost Savings: Offer up to 72% discounts compared to on-demand pricing.
❏ Commitment Terms: Require a 1- or 3-year commitment.
❏ Payment Options: Flexible payment plans, including All Upfront, Partial
Upfront, and No Upfront, cater to different budget preferences.
❏ Modifications: Can modify RIs to change Availability Zones, instance sizes
(within the same family), or networking types.
❏ Ideal Use Case: Best for steady, predictable workloads (e.g., long-running
applications).
Reserved Instances
Cost saving summary
Cost saving summary
Sr. No Sections Total cost saving
1 Manual Snapshot removal $42,183.21
2 Instances size reduction (Instance type change)
$9470.24 (Reserved Instances)
$14449.65 (On-demand Instance)
3 Instances Migration (Intel to Graviton)
$3,809.34 (Reserved Instances)
$4,223.48 (On-demand Instance)
4 IOPS decrease/ Changing storage to GP3 $3132
5 Storage reduction (reducing the storage allocated) $232.13
Total cost saved:
$58826.92
(Reserved Instances)
$64220.47
(On-demand Instances)
YOU
YOUR BOSS
Best practises
❏ Cost Allocation Tags: Tag resources for detailed cost tracking and accountability.
❏ Reserved Instances and Savings Plans: Reduce costs for predictable workloads
❏ Monitor and Optimize Usage: Use tools like AWS Cost Explorer, Trusted Advisor, and Compute Optimizer.
❏ Enable Budgets and Alerts: Set budget thresholds and receive notifications to avoid overruns.
❏ Choose the Right Instance Types: Match workloads to the most efficient EC2 instance types.
Best practises
❏ Use Appropriate Storage Types
GP3 for cost-effective performance, Provisioned IOPS for high I/O demands.
❏ Optimize Query Performance
Regularly analyze and tune queries using tools like Performance Insights and Enhanced Monitoring.
❏ Delete Unused Resources
Clean up idle databases, manual snapshots, and unused read replicas.
❏ Performance Optimization
Query caching, partitioning
❏ Optimize Backup Storage
Setting appropriate retention periods for automated backups; avoid keeping excessive backups.
Best practises
❏ Scale with Demand
Adjust the number of replicas dynamically based on demand
❏ Turn Off Unused Databases
Stop RDS instances when not in use, Use RDS Pause and Resume
❏ Optimize Network Costs
RDS instances in the same region as the applications to minimize data transfer costs. Avoid excessive
cross-region replication.
Best practises
Thank you!