Amazon RDS Read Replicas provide enhanced performance and durability for RDS instances. They make it easy to elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads. You can create a DB instance read replica from a Multi-AZ DB cluster in order to scale beyond the compute or I/O capacity of the cluster for read-heavy database workloads. You can direct this excess read traffic to one or more DB instance read replicas. You can also use read replicas to migrate from a Multi-AZ DB cluster to a DB instance.
Please visit Working with Multi-AZ DB cluster read replicas for additional details.
A DB instance read replica of a Multi-AZ DB cluster is different than the reader DB instances of the Multi-AZ DB cluster in the following ways:
For more information, see Overview of Multi-AZ DB clusters.
To create a read replica, specify a Multi-AZ DB cluster as the replication source. One of the reader instances of the Multi-AZ DB cluster is always the source of replication, not the writer instance. This condition ensures that the replica is always in sync with the source cluster, even in cases of failover.
Find RDS PostgreSQL instance rdspg-fcj-labs-read-test under the Databases menu and click on the radio button in front of the DB Instance. Click on the Actions drop down on the right side and choose Create Read Replica.
For Settings, you must provide a DB Instance Identifier (i.e. the name for this instance).
For the Availability section, select Multi-AZ DB instance deployment option.
For simplicity, we’ll leave the rest at their defaults. Scroll to the bottom and click Create read replica.
After you click Create read replica, you’ll be taken back to the Databases page. Click the refresh icon to refresh the page and you should see the read replica being created.
It will take about 10 minutes for your read replica to be created. Your primary database continues to be available as this happens
Once the Read Replica status is Available on the Databases page (you may need to use the refresh icon to see the latest Status), click on the new read replica instance.
On the detail page for the read replica, first notice the endpoint. The read replica has a different endpoint than your primary instance.
Next, scroll down to view the replication details. You can see that our primary cluster is replicating to our read replica instance.
You can then connect to the read replica using its endpoint and the same username and password as the source cluster. For example, connect and execute the following query to check the replication lag between the source and the replica:
SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS replica_lag;
Congratulations: In this lab, you added a Multi-AZ DB Instance read replica instance to your Multi-AZ DB Cluster configuration for scaling out read workload.
Alternatively you can promote the read replica using the AWS CLI as shown below: