Unless you are new to Backend development, it is likely that you have heard about Amazon RDS. In brief, Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.
I will try to compare Amazon RDS vs Amazon EC2 for PostgreSQL database. This post might help you in choosing either use Amazon RDS or your own Amazon EC2 instance with PostgreSQL installed.
One of the advantages of developers using Amazon RDS instead of managing their own databases is that it reduces or eliminates their administrative responsibilities.
Benefits of using Amazon RDS over Amazon EC2 for PostgreSQL server.
Setting up a PostgreSQL database on Amazon RDS is just a few clicks and go. There is no need to buy hardware, install the software and manage database access. You can configure everything from the AWS Dashboard and its done!
Amazon RDS is a highly available relational database. It comes with a feature called Amazon RDS Multi-AZ Deployment, which automatically creates a primary DB Instance and synchronously replicates the data to a standby instance in a different Availability Zone (AZ).
If you go with your own EC2 instance, you have to setup PostgreSQL for high availability from one of the different replication solutions.
With Amazon RDS, you get automated backups that let you recover to a pointed time you choose. You also get a simple way to take consistent and deliverable snapshots on-demand and keep them as long as you want.
While setting up backup & restore on PostgreSQL is not as easy as it is with Amazon RDS.
With the Multi-AZ feature, AWS provides a synchronous “standby” replica of every database in another “zone.” Since both the database and its replica are in sync, there is no chance of data loss. It also offers domain name server (DNS) to access RDS, so even if the master database instance goes down, an RDS automatic failover mechanism will change the master DNS to a replica in order to achieve high availability.
While PostgreSQL directly does not provide automatic failover, you will have to manually setup automatic failover with PostgreSQL. You might also have to configure repmgr to manage replication and failover in a cluster of PostgreSQL servers.
Scaling up your database becomes very easy with Amazon RDS. You can scale your database by adding replicas. You can scale your RDS Instance vertically and horizontally with single push of a button.
You might need to setup Streaming Replication to scale your database. You will also face a downtime.
AWS RDS offers PIOPS (Provisioned IOPS) in order to achieve fast, consistent and predictable Input/Output (I/O) performance.
Amazon RDS sends metrics to CloudWatch every single minute for each and every database instance that is active with no additional charge.
Amazon RDS allow you to secure your data with the help of data encryption. You can encrypt it with the keys and it is managed by AWS Key Management Service. You can read more about Encrypting Amazon RDS Resources.
Amazon RDS makes sure that your database stays up-to-date with latest patches.
Let us discuss about some of the cons of using AWS RDS.
- No access to the RDS instance. Yes, you heard it right, as RDS is a managed database. you can’t access the server operating system.
- Server time is fixed to UTC.
Not much limitations using Amazon RDS right? Let’s compare pricing, considering similar instance configurations.
Instance type: m4.large | 2 vCPUs | 8 GB Memory | Moderate I/O
Storage: EBS General Purpose SSD | 100 GB @ $0.1 per GB per month
Total Cost (approximate): $85 per month
Instance type: db.m4.large | 2 vCPUs | 8 GB Memory | Moderate I/O
Storage: 100 GB
Total Cost (approximate): $155 per month
RDS clearly sounds expensive, but it has its own advantages. There is no right or wrong decision when choosing RDS or EC2 for database. And like most of the things, it’s a cost vs effort/complexity trade-off.
If you’re looking for a simple, low-maintenance solution, RDS should be a better option. When it comes to production deployments, the multi-AZ deployment provided by RDS turns out to be very useful, definitely reducing efforts/cost for the database/devops engineer. If you have to do complex configurations like optimizing postgres config file, migrate Write-Ahead-Log, run pgbouncer etc., having your database on EC2 is the only option.
Thanks for reading this article. Please recommend this article if you found it helpful.