AWS RDS vs EC2 – Benefits, Limitations, And Tradeoffs

This article will help you make an informed decision and reach your goals effectively and efficiently. Let’s understand Amazon RDS and EC2 hosted databases along with the differences between them.

What is Amazon RDS?

Amazon RDS

Amazon Relational Database Service (Amazon RDS) is a managed Database-as-a-Service (DBaaS) that makes it easy for IT administrators to set up, operate, and scale relational databases in the cloud. RDS is available for popular database engines including MySQL, MariaDB, PostgreSQL, Oracle, and Microsoft SQL Server.

Therefore, when migrating to the cloud, most applications that use any of these database engines can be deployed so that they use Amazon RDS instead of local database servers without too much effort. In addition, Amazon RDS also supports Amazon’s database platform, Amazon Aurora, a MySQL and PostgreSQL compatible relational database.

For each engine, you can choose different database instance types depending on the CPU, memory, storage, and networking requirements. With Amazon RDS, you offload time-consuming database administration tasks such as provisioning, setup, patching, backup, recovery, failure detection, and repair to Amazon, thus freeing your team from worrying about these laborious and error-prone tasks.

RPO and RTO: Key Disaster Recovery Concepts

  • Amazon RDS automatically backs up your databases every 24 hours by default. This feature ensures that, in the worst case, your RTO is 24 hours. With a multi-region (multi-site) active-active multi-region strategy, the RPO is near zero, and RTO could be potentially nil.
  • Routine patching is automated as well, with set maintenance windows to keep your database instances secure.
  • With RDS, you can also have read replicas in zones closer to your users. In order to increase read capacity and free up IOPS, you could route read queries from your applications to the read replica.

You can also send expensive queries to read replicas, thereby reducing the load on the production servers.

Difference between RTO and RPO

What is Amazon EC2?

Amazon EC2

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure access to server instances on demand. Obtaining and configuring capacity is easy – simply use the Amazon EC2 web service interface to add capacity on demand. You have complete control of your computing resources and can scale up or down as your needs change. To provide database services required for your application, you can provision EC2 instances and install the required database engine(s) yourself on the instances.

Next, let us see the tradeoffs you have to make when choosing between Amazon RDS and EC2 for your database instances.

Administration

RDSEC2
Easy to set up. AWS automates the entire process of management, maintenance, and security. Allows you to focus on essential tasks, not routine maintenance. You have multiple options to access the powerful capabilities of a production-ready relational database – the AWS Management Console, the AWS RDS command-line interface, or simple REST API calls.You are in complete control of the OS installed, database version and configuration, and other software components. All routine maintenance activities, including patches, upgrades, backup, replication, and clustering, are your responsibility.

High Availability

RDSEC2
Has built-in high availability. It automatically creates a primary DB instance and replicates the data side-by-side to a standby instance in a different Amazon Availability Zone. This feature ensures that if there is an outage in one zone, you can recover your database from the other zone.It is your responsibility to configure the database server in a highly available cluster.

Backups

RDSEC2
You can set up backups to be automated. AWS Cloudwatch can be used to receive events on backup failures, completion, etc. Also, you can get database snapshots on-demand and keep them as long as you need.Backups have to be enabled by you. You need separate monitoring to make sure that regular backups are happening. One cannot use AWS Cloudwatch for this.

Scalability

RDSEC2
RDS integrates seamlessly with Amazon’s scaling tools for both horizontal and vertical scaling. If you need to scale vertically to a larger or more powerful instance, you can do this in a few clicks. Also, if you need to scale horizontally, spinning up additional read replicas can be automated, so your system instantly responds to increasing usage demands for your read-only workloads.With EC2, you have to set up a scalable architecture manually. This process may involve setting up multiple EC2 instances, load balancing between them, configuring Availability Groups, Sharding, etc.

Performance

RDSEC2
  • When setting up an RDS instance, you have the option of configuring it with a certain number of IOPS provisioned. Provisioning IOPS can be expensive but allows you to get fast, predictable, and consistent Input/Output performance.
  • Amazon RDS integrates tightly with Amazon CloudWatch that gives you insight into database performance.
  • With EC2, you have to pick the right storage volume to get the IOPS and latency you need.
  • From a monitoring standpoint, you cannot use AWS Cloudwatch to monitor database performance since the database server is not AWS-managed. You need to implement third-party database monitoring tools to get insights into database performance.

4 key RDS metrics that you must track and correlate with application performance.

CloudWatch MetricDefinition
IOPSInput and output operations per second
Read and write latencyTime it took from request to completion
ThroughputBytes transferred to or from the database volume
Queue depthI/O requests waiting to be carried out

See this link for a comprehensive list of RDS CloudWatch metrics.

Storage

RDSEC2
    You get three storage options:

  • General-purpose SSD: This is a cost-effective option. SSD volumes deliver single-digit millisecond latencies and can handle up to 3,000 IOPS.
  • Provisioned IOPS: Good for database-intensive workloads that need I/O latency and very high IOPS throughput for extended periods.
  • Magnetic: Handles magnetic storage for backward compatibility.
The IOPS and latency you get depend on the EC2 instance type. You can get up to 16000 IOPS and 2000 Mbps with the right EBS-optimized instance.

Support and Control

RDSEC2
  • You are limited to the database engines supported by Amazon and by the versions supported. Since you do not manage the database server, upgrades and patches are managed by Amazon.
  • You do not have direct access to the system hosting the database; however, you have access to the database administration tools to perform any activities required on the database server.
  • With EC2, you can install any database engine and version you want. You are not limited by the version and configuration AWS supports in RDS (e.g., IBM DB2 is not supported by AWS RDS, but you can install DB2 on an EC2 instance and operate it).
  • You have full access to the operating system and the database server. You can apply any updates and patches you wish and can configure your maintenance windows. You can also choose whether you want to run one or multiple instances on the same EC2 instance, and the ports used are also in your control.

Security

RDSEC2
Offers encryption both at rest and in transit. The storage for the database instances, read replicas, automated backups, and snapshots are all encrypted during storage.In EC2, encryption is at the EBS volume level, and you can also configure encryption at the database level.

Licensing

RDSEC2
  • AWS provides both “License Included” and “Bring-Your-Own-License (BYOL)” models, but they are different for various database flavors/engines.
  • For example, Oracle RDS allows you to bring your license while Amazon RDS for SQL Server supports only the “License Included” licensing model. Further, you cannot bring your SQL licenses for use as the SQL Server is licensed through AWS.
With EC2, you are free to bring your database licenses for use regardless of the database flavor/engine.

Cost

Spending depends on the instance type. You can get the costs from the AWS Cost calculator.

RDSEC2
Is usually more expensive as you rely on Amazon to perform routine management tasks.Installing a database server on EC2 and managing it is usually cheaper than RDS. You will have to handle routine management tasks such as backup, recovery, patching, load management, etc., by yourself.

How to choose between Amazon RDS and EC2?

Amazon RDS vs. EC2

The choice between a database on an EC2 instance and RDS is essentially the choice between an unmanaged environment where the burden is on you to manage everything yourself and a managed service where the cloud vendor shoulders the burden of mundane management tasks. A simple API call gives you control over deployment, backups, snapshots, restores, sizing, high availability, and replicas. In contrast, the self-managed database on the EC2 option requires you to manually set up, configure, manage, and tune the various components, including Amazon EC2 instances, storage volumes, scalability, networking, and security.

Apart from reducing the management overhead, another business driver is increased flexibility and automation. One can achieve this by using an automated CI/CD system that leverages the AWS Command-line interface (CLI), AWS Cloud Development Kit (CDK) and CloudFormation to deploy the database backend with very little manual intervention. Managed services empower you to control the infrastructure and design services that can be easily deployed, replicated, and have auto-healing characteristics built into them.

At the same time, the cost may be a key factor. Amazon RDS can be slightly more expensive than EC2 for the same configuration. So, if you have a tight budget or want to work with a database engine or version not supported by Amazon RDS, you may have to use the EC2-hosted database approach.