Create Read Replica For RDS DB Instances

In this tutorial , We will learn How to create a read replica for the existing RDS DB Instance from AWS Console.

Check the below articles on ,

How to Create RDS Instance using AWS Console

How to Create RDS Instance using Terraform

What Is Read Replica?

Amazon RDS has the functionality of creating a replica for the source DB Instance.Any changes to the Source database will be copied to the replica database.

Read Replica is nothing but having the exact copy as of the Source DB Instance.

To reduce the load to the master (Source DB Instance) DB , You can create and use the read replica for the applications to fetch data.

Working With Read Replica

When we create a Read replica from the existing Source DB Instance , First Amazon RDS will create a snapshot of the source DB instance from that It will create a read only Database known as Read Replica.

You cannot make changes to the Read Replica such as UPDATE , INSERT ,ALTER.You can only read the data from the Read replica DB Instance such as SELECT query.

Whenever a new update or changes happens in the Master / Source DB Instance , It will automatically copies the data to the replica DB Instance.

Creating Replica In Multiple Region

  • Lets say You’re running a Source DB Instance in the Mumbai Region .Now you want to create a read replica for that DB Instance.
  • Read replica can be created either the same region as of Source DB Instance or the Different AWS Region.
  • If you create Read replica in different AWS region , Amazon RDS enables a secure connection between the source and replica DB instance for copying the data.

Points To Note

  • When you create a read replica from source DB Instance , First It will create a snapshot and using the snapshot it will create read replica DB instance.
  • But during this process of snapshot creation , The Source DB Instance will face an I/O suspension.
  • Also If the source DB Instance is running long thread queries or It has long running transactions It will slow down the process of replica instance creation.
  • If you have Multi-AZ setup for the DB Instance , You can avoid this issue as the replica instance will be created from the Secondary source DB Instance.

Creating Read Replica

To create a Read Replica , Login to RDS Console

Choose DB Instances , Select the Source DB Instance for which you want to create a read replica.

Under Actions , Choose Create read replica

Under Instance specifications , Its recommended to use the same Instance type and the storage class as of Source DB Instance.

If required you can change the Instance type.

If you choose Multi-AZ deployment , Then It will create a another read replica in different availability zone.This is to ensure that If one read replica goes down , Data will be replicated from Source DB Instance to Another replica DB Instance.

You can setup Multi-AZ for read replica , Even If you don’t have Multi-AZ for the Source DB Instance.

Under Network & Security , You have the option to choose the Destination region.

It can either be the same region as of Source DB Instance or Different AWS region.

If Publicly accessible is set to Yes , The replica DB Instance can be directly accessed from any IP Address (You can modify the Security group of DB Instance to allow for particular subnet or IP Address for security).

If the Publicly accessible is set to No , It can be accessed with the VPC. Such that You can access the read replica through SSH Tunnelling.

Under Settings , You should choose the Source DB Instance and Also You should specify a Name for the read replica DB Instance.

Change the other configurations If required or leave it to default values and then Click Create read replica.

Once you click Create read replica , You should see that the Status of Source DB Instance be Modifying , This is because When you create a Read replica from an RDS Instance , The Role of the source DB Instance will be promoted from Instance to Master.

Once the Status of the Read replica Instance becomes Available , You can connect to it by using the same DB credentials as of Source DB Instance.

You only have to change the DB Host (endpoint) of the Replica DB Instance.

Wrapping Up

We have learnt how to create read replica from the existing RDS DB Instance.

Also We understood the concept of read replica.Hope you found it helpful.

Thanks for reading this article.

Please do check out my other publications.