Pythian Blog: Technical Track

MySQL on AWS: RDS vs EC2

EC2 vs RDS
When moving your MySQL instances to AWS, you would probably have to deal with this decision. This article will highlight some of the key factors that need to be considered in order to help you determine which is the most cost-effective solution for serving your data.
 

Introduction

RDS is based on EC2, so in this post I will focus on the benefits and disadvantages of using the former, versus migrating MySQL into user-managed EC2 instances. The value of RDS resides in simplified provisioning and administration. Several of the most common maintenance tasks such as minor version upgrades, backups, and slave creation are automated and can be managed from the AWS console. On the other hand, RDS imposes some limitations to MySQL functionality so it could be offered “as a Service” while delivering a safe and consistent user experience. Within those limitations we can mention:
  • Storage engine support
  • Plugin-related features
  • Tools or operations requiring SUPER privilege
  • Replication (topologies, filters, etc)
  • Failover
  • Lack of access to the underlying operating system
 

MySQL RDS pros and cons in bullets

Main advantages

  1. Instance provisioning time is within the range of minutes
  2. Instance type supporting the database server can be easily scaled up and down
  3. Storage and IOPS can be scaled up easily
  4. Replicas can be provisioned/destroyed automatically and within minutes
  5. Backups, snapshots and restores (including PITR) processes are greatly simplified and are fully automated
  6. Backups and minor version upgrades are done with minimal impact to production if using Multi-AZ instances.
  7. Multi-AZ instances implements synchronous standbys replicas on a different AZ for failover and backups
  8. Read replicas on different AWS regions can be easily deployed for load balance and Disaster Recovery purposes

Limitations

  1. Once storage is allocated for the instance, it cannot be reclaimed without rebuilding the instance from a logical restore.
  2. Access to the operating system is denied, so any operation that requires OS-level access cannot be performed. Many tasks can be run from an external EC2 instance, but not all.
  3. Access to MySQL user accounts with ‘SUPER’ privilege is denied. Tasks such as configuring replication that require SUPER are handled through RDS stored routines. Configuring dynamic and non-dynamic MySQL variables are handled through RDS parameter groups.
  4. Storage engines other than InnoDB are permitted but not supported and consistent backups / restores are not guaranteed.
  5. Read and standby replicas are implemented separately: standby replicas are synchronous but are not accessible for reading while read replicas are asynchronous and even they can be used for failover, they rely on MySQL asynchronous replication and data may be lost in the process. Due to this separation, it is additional cost to get full DR and read-scaling capabilities.

Costs exercise

A quick estimation comparing RDS and EC2 for similar instances and storage shows that RDS is between 33 and 44% more expensive than EC2:
## MySQL on EC2

-Instances: 3 x m2.4xlarge -Storage: 3 1Tb EBS volumes (provisioned IOPS - 3000 IOPS) + 100Gb/month of snapshots space -Intra-Region Data Transfer: 40Gb/Month

On-demand instances

USD $3465 per month

Reserved instances (1 year, partial upfront)

USD $1490 per month

## MySQL RDS

-Instance type: 1 x db.m2.4xlarge + 1 x db.m2.4xlarge (read replica) -Multi-AZ: yes -Storage: 1Tb (provisioned IOPS - 3072 IOPS, one for each instance) -Backup space: 100Gb/month -Intra-Region Data Transfer: 40Gb/Month

 

On-demand instances

USD $4633 per month

Reserved instances (1 year, partial upfront)

USD $2155 per month

The above costs were estimated using AWS simple monthly calculator

Conclusion

There is no right or wrong decision when choosing which AWS solution is better for MySQL. RDS is a powerful option if your data is already in InnoDB (and only in InnoDB) and you are looking for a simple, low-maintenance deployment. When other engines and more complex topologies come into the scene, or even the need for MySQL plugins, then going to EC2 is a better option. Any critical process or script running locally on a MySQL instance could also be the decisive factor for choosing EC2, usually because of the time spent in moving the data through the network. Finally, the cost is definitely a key factor, especially when moving several instances into RDS.

No Comments Yet

Let us know what you think

Subscribe by email