6.3 RDS - Backups, Multi-AZ & Read Replicas
Backups
There are two different types of backups for AWS RDS. Automated backups and Database snapshots.
Automated backups.
It allows you to recover your database to any point in time within a "retention period". Retention period can be between 1 and 35 days. By default, when you create a RDS database, it is 7 days retention period is selected. Automated backups will take a full daily snapshot and will also store transaction logs throughout the day. When you do a recovery, AWS will first choose the most recent daily backup, and then apply transaction logs relevant to that day. This allows you to do a point in time recovery down to a second, within the retention period. So you can at most go back 35 days. You can say I want to recover my database to Friday afternoon at 2:35 pm and 45 seconds. This automated backup is built in RDS so you don't need to worry about this and you just need to turn on automated backups.
Automated backups are enabled by default. The backup data is stored in S3 and you get free storage space equal to the size of your database. So if you have an RDS instance of 10GB, you will get 10GB worth of storage.
Backups are taken within a defined window. During the backup window, storage IO may be suspended while your data is being backed up and you may experience elevated latency. The best practice is to choose a backup window when your database is not being utilized very heavily.
Snapshots
DB snapshots are done manually (i.e. they are user initiated). They are stored even after you delete the original RDS instance, unlike automated backups. The automated backups will be automatically deleted if you delete the RDS instance, but it will prompt you to do a final database backup which can restore as well.
For both of automated backups and database snapshots, whenever you restore either an automated backup or a manual snapshot, the restore version of the database is always a new RDS instance with a new DNS end point.
Encryption
Encryption at rest is supported for MySQL, Oracle, SQL Server, PostgreSQL & MariaDB. Encryption is done using the AWS key Management Service (KMS) service. Once your RDS instance is encrypted the data stored at rest in the underlying storage is encrypted, as are its automated backups, read replicas, and snapshots.
At the present time, encrypting an existing DB instance is not supported. To use Amazon RDS encryption for an existing database, create a new DB instance with encryption enabled and migrate your data into it.
Steps of backups and encryption:
Go to the RDS dashboard and select Instances and select the MySQL database we created in last lecture.
Click Instance Actions -> Take Snapshot. This will take a snapshot manually.
Go to RDS dashboard and select Snapshots. You can see there are lots of snapshots, some of them are automated backups, some of them are manual snapshots. You can do a point in time recovery for any of these snapshots.
You can select a snapshot, and click restore snapshot. When you restore a snapshot it does create a new database, so you have to give it a new DB instance identifier. For now, just set Multi-AZ to No, set Availability Zone to No Preference, and set Publicly Accessible to Yes, and leave other things as default. Click Restore.
Go to Instances, there will be two DB instance. One is the old one, it is being backed up, and the other one is being created. Select the being backed up one, and click Instance Actions -> Restore to Point in Time, so that you can configure a specific point of time to restore if you want.
Thus, you can do a full snapshot restoration, or you can do a point of time restoration.
Go to Snapshots, you can select a snapshot and copy it. This will copy this snapshot to another Region. If you want scale up your database, you can take a manual snapshot for it, and then restore this snapshot, and you can choose another DB instance class so that scale up your database.
You cannot restore a encrypted copy from a snapshot if the original database instance of this snapshot is not encrypted. You need to create a new RDS instance which is encrypted. Go to launch a new DB instance, select MySQL and Production one. Select Multi-AZ to be Yes, and select the DB instance class and give it a identifier, username and password and then click next. Then set the Enable Encryption to be Yes. Then it will give a Master Key, and that key is stored using KMS. This is how you encrypt a RDS database instance.
Multi-AZ (High Availability)
What is multi-AZ?
In the event of planned database maintenance, DB instance failure, or an AZ failure, Amazon RDS will automatically failover to the standby so that database operations can resume quickly without down time and administrative intervention.
Amazon RDS automatically performs a failover in the event of any of the following:
Loss of availability in primary AZ
Loss of network connectivity to primary
Compute unit failure on primary
Storage failure on primary
When failing over, Amazon RDS simply flips the canonical name record (CNAME) for your DB instance to point at the standby, which is in turn promoted to become the new primary. Failovers typically complete within one to two minutes.
Note: when operations such as DB instance scaling or system upgrades like OS patching are initiated for multi-AZ deployments, for enhanced availability, they are applied first on the standby prior to an automatic failover. As a result, your availability impact is limited only to the time required for automatic failover to complete. Amazon RDS multi-AZ deployments do not failover automatically in response to database operations such as long running queries, deadlocks or database corruption errors.
Multi-AZ is for HA and Disaster Recovery only. It is not primarily used for improving performance. For performance improvement you need Read Replicas.
Multi-AZ databases are available for SQL Server, Oracle, MySQL, PostgreSQL and MariaDB.
Amazon RDS provides high availability and failover support for DB instances using Multi-AZ deployments. Amazon RDS uses several different technologies to provide failover support. Multi-AZ deployments for Oracle, PostgreSQL, MySQL, and MariaDB DB instances use Amazon's failover technology. SQL Server DB instances use SQL Server mirroring. Amazon Aurora instances stores copies of the data in a DB cluster across multiple Availability Zones in a single AWS Region, regardless of whether the instances in the DB cluster span multiple Availability Zones.
Read Replicas
What is Read Replicas?
Read Replicas allow you to have a read only copy of your production database. This is achieved by using Asynchronous replication from the primary RDS instance to the read replica. You use read replica's primarily for very read-heavy database workloads. (You could also use In-memory cache).
Read Replica Database supports MySQL Server, PostgreSQL, and MariaDB.
Read Replica Tips:
It is used for scaling, not DR (disaster recovery).
Must have automatic backups turned on in order to deploy a read replica
You can have up to 5 read replicas copies of any databases.
You can have read replicas of read replicas (but watch out for latency, it is asynchronized replication)
Each read replica will have its own DNS end point.
You cannot have Read Replicas that have Multi-AZ.
You can create Read Replica's of multi-AZ source database however.
Read Replicas can be promoted to be their own databases. This breaks the replication. So in this way you can write to it, because you can only read from Read Replicas, you cannot write to it.
Read Replica in a second region for MySQL and MariaDB. Not for PostgreSQL.
Steps of Read Replicas
Go to select a DB instance. Go to Instance Actions and click Create Read Replicas.
DynamoDB vs. RDS
DynamoDB offers "push button" (automatic) scaling, meaning that you can scale your database on the fly, without any downtime.
RDS is not easy and you usually have to use a bigger instance size or to add a read replica. This needs to be done manually.
Last updated
Was this helpful?