Blog Amazon Web Services High Availability using AWS RDS Multi-AZ and Read Replica

High Availability using AWS RDS Multi-AZ and Read Replica

Are you preparing for AWS Certified Solutions Architect Professional certification exam? In this space, we are writing series of articles on topics which are covered in the Solutions Architect Professional certification exam. In this article, we are explaining one of the important feature available with Amazon web services which is AWS RDS Multi-AZ and Read Replica. You would expect lot of questions from this topic for Solutions Architect Professional exam. You can subscribe to us for receiving the further updates on this topic.

Amazon RDS

This topic addresses the High Availability and Business continuity topic mentioned in the below table and as highlighted in the AWS Blueprint for the exam guide

AWS Certified Solutions Architect Professional BluePrint

Purpose of Multi-AZ and Read Replica

AWS provides the facility of hosting Relational databases. The following databases are supported – PostgreSQLMySQLMariaDBOracle, and Microsoft SQL Server.

For the databases, there are 2 features which are provided by AWS

  1. Multi-AZ – In this architecture, AWS maintains a copy of the primary database in another Availability Zone. So if a failure occurs in the primary database, an instance switch over can occur to the secondary database. The data is replicated synchronous to the standby instance.

Multi-AZ Architecture

The primary DB instance switches over automatically to the standby replica if any of the following conditions occur:

  • An Availability Zone outage
  • The primary DB instance fails
  • The DB instance’s server type is changed
  • The operating system of the DB instance is undergoing software patching
  • A manual failover of the DB instance was initiated using Reboot with failover

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. Note that Amazon RDS Multi-AZ deployments do not failover automatically in response to database operations such as long running queries, deadlocks or database corruption errors.

  1. Read Replica – This is where you take a snapshot of the current RDS in AWS. This is like a read only copy that can be used to increase the scalability of a database. Normally a Read replica is used to offload heavy read traffic for an application. So if you have an application that has a heavy query interface and looks for consistent number of reads, then Read replica can be used. The transactional part can exist in the main database and the reads can happen in the Read replica database.

Read replicas are available in Amazon RDS for MySQLMariaDB, and PostgreSQL.

Some of the other advantages of read replica’s are

  • Enhanced security – All traffic between the source and destination database is encrypted.
  • Read replicas in Amazon RDS for MySQL, MariaDB, and PostgreSQL provide a complementary availability mechanism to Amazon RDS Multi-AZ Deployments. You can promote a read replica if the source DB instance fails. You can also replicate DB instances across AWS Regionsas part of your disaster recovery strategy.

Creating a Multi-AZ Database

Let’s now look at the steps involved in creating a Multi-AZ database. For our example, we will use a MySQL database provided by AWS.

Step 1: After logging into the console , go to the Database->RDS section

Goto Database and then select RDS

Step 2: In the next screen , choose the MySQL Engine

Choose Mysql engine

Step 3: Choose the option of hosting a production database which automatically comes with the Multi-AZ option.

Choose the option of hosting a production database

Step 4: In the DB details , the Multi-AZ Deployment will be marked as ‘Yes’.

Multi-AZ Deployment marked as ‘Yes’.

Specify a database name , user name and password and click on Next step

Specify a database name , user name and password

Step 5: In the next step, choose the VPC. It always a good practice to ensure the database is not publicly accessible.

Configure Advanced Settings

Accept all the default settings and click on Launch DB Instance.

Accept settings and Launch DB Instance

 

Once the database is created, you would get the endpoint for the database

Get the endpoint for the database

Creating a Read Replica

Let’s now look at the steps involved in creating a Read Replica database. For our example, we will use a MySQL database which was created in the earlier steps.

Step 1: After logging into the console , go to the Database->RDS section

Goto Database and then RDS section

Step 2: Navigate to the database which was created in the earlier step. Choose the Instance Actions and choose on Create Read Replica.

Choose the Instance Actions and choose on Create Read Replica.

Step 3: In the next step , you need to choose the instance details which will be used to host the read replica. Also you need to mention the provisioned IOPS and the source database. You then to also specify the new instance identifier for the read replica database.

Create Read Replica DB Instance

Step 4: You can also decide on the region in which the Read replica can be launched in

Decide on region to launch Read Replica

Step 5: Once all the settings are in place, just click on Create Read Replica.

Click Create Read Replica

Once the database has been created you will be able to see this database in the console and use this like an ordinary database

Database Created and shown in console

Final Points to Remember about RDS Multi-AZ and Read Replica

  • In Multi-AZ, the data from the primary instance is replicated to a secondary instance.
  • The secondary instance is located in another Availability zone.
  • In Read Replica, a snapshot is taken of the primary database.
  • Read replicas are available in Amazon RDS for MySQLMariaDB, and PostgreSQL.
  • Read replicas in Amazon RDS for MySQL, MariaDB, and PostgreSQL provide a complementary availability mechanism to Amazon RDS Multi-AZ Deployments
  • All traffic between the source and destination database is encrypted for Read Replica’s.
  • The standby replica in a Multi-AZ deployment cannot take on read requests. It is only meant for a failover and is not used for read purposes.
  • You need to enable backups before creating Read replica’s. This can be done by setting the backup retention period to a value other than 0
  • Amazon RDS for MySQL, MariaDB and PostgreSQL currently allow you to create up to five Read Replicas for a given source DB Instance
  • It is possible to create a read replica of another read replica. You can create a second-tier Read Replica from an existing first-tier Read Replica. By creating a second-tier Read Replica, you may be able to move some of the replication load from the master database instance to a first-tier Read Replica.
  • Even though a read replica is updated from the source database, the target replica can still become out of sync due to various reasons.
  • You can delete a read replica at any point in time.

Summary

In this article we have explained about AWS RDS Multi AZ and Read Replica. This is one of the most important feature offered by Amazon Web Services (AWS) that will help the Developers. You would expect lot of questions from this topic in your certification exam. 

If you are preparing for the AWS certifications exam and looking for any help, please send us a mail or call to our customer support team. 

 

About Mark Oswald

Mark is an experienced software engineer and technology blogger. He has over five years of experience in writing in different technological domains. Writing is his passion and he contributes regularly to the Whizlabs blog to share his knowledge.
Spread the love

1 COMMENT

  1. Amazing information about RDS and Multi-AZ.

    In point to remember no #1
    In Multi-AZ, the data from the primary instance is replicated to a secondary instance.

    So is it chargeable as data transfer cost?

LEAVE A REPLY

Please enter your comment!
Please enter your name here