RDS Essentials:
- RDS is a fully managed Relational Database Service:
- Does not allow access to the underlying operating system (fully-managed).
- You connect to the RDS database server in the same way you would connect to a traditional on-premise database instance (i.e. MySQL command line).
- RDS has the ability to provision/resize hardware on demand for scaling.
- You can enable Multi-AZ deployments for backup and high available solutions.
- Utilize Read Replicas (MySQL/PostgreSQL/Aurora) - to help offload hits on your primary database.
- Relational databases are databases that organize stored data into tables.
- The associated tables have defined relationships between them.
- Database supported by RDS:
- MySQL
- MariaDB
- PostgreSQL
- Oracle
- MS SQL Server
- Aurora:
- Is a home grown Relational Database that has been forked from, and fully compatible with MySQL.
- It has five times better performance than MySQL and a lower price point than commercial database.
- Benefits of running RDS instead of database on your own instance:
- Automatic minor updates.
- Automatic backups (point-in-time snapshots).
- Not required to managed operating system.
- Multi-AZ with a single click.
- Automatic recovery in event of a failover.
RDS Multi-AZ Failover:
- Multi-AZ failover (Automatic AZ-Failover) synchronously replicated data to backup (stand-by) database instance located in another availability zone (but in the same region).
- In the event of:
- Service outage in an AZ.
- Primary DB instance failure.
- Instance server type is changed.
- Manual failover initiated.
- Updating software version.
- AWS will automatically switch the CNAME DNS record from the primary instance to the stand-by instance.
RDS backups are taken against the stand-by instance to reduce I/O freezes and slow down if Multi-AZ is enabled.
In order for Multi-AZ to work, your primary database instance must be launched into a "subnet group".
- NOTE: An RDS instance must be launched into a subnet (inside a VPC), just like an EC2 instance. So the same security/connectivity rules, and highly available/fault tolerant concepts apply.
RDS Backups:
- AWS provides automated point-in-time backups against the RDS database instance.
- Automated backups are deleted once the database instance is deleted and cannot be recovered (but you can take your own snapshots of backups before deleting).
- Backups on database engines only work correctly when the database engine is "transactional", but do currently work for all supported database types.
- MySQL requires InnoDB for reliable backups.
RDS Read Replicas:
- Read replicas are asynchronous copies of the primary database that are used for read only purpose (only allow "read connections").
- When you write new data to the primary database, AWS copies it for you to the read replica.
- You can create and have multiple read replicas for a primary database.
- Read replicas can be created from other read replicas (so no performance hit on the primary database).
- MySQL, MariaDB, PostgreSQL and Aurora currently support read replicas.
- You can monitor replication lag using CloudWatch.
Benefits of using Read Replicas
- Read replicas allow for all read traffic to be redirected from the primary database to the read replica. This will greatly improve performance on the primary database.
- Read replicas allow for elasticity in RDS - you can add more read replicas as demand increases.
- You can promote a read replica to a primary instance.
- MySQL:
- Replicate for importing/exporting data to RDS.
- Can replicate across regions.
When should you use Read Replicas
- High volume, non-cached database read traffic (elasticity).
- Running business function such as data warehousing.
- Importing/Exporting data into RDS.
- Rebuilding indexes:
- Ability to promote a read replica to a primary instance.