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 from one to 5 replicas of a given source DB Instance and serve high-volume application read traffic from multiple copies of your data, thereby increasing aggregate read throughput. Read replicas can also be promoted when needed to become standalone DB instances. Find more features of RDS Read-replicas here .
To migrate a Single-AZ deployment or Multi-AZ DB instance deployment to a Multi-AZ DB cluster deployment with reduced downtime, you can create a Multi-AZ DB cluster read replica. Please visit Working with Multi-AZ DB cluster read replicas for additional details.
Amazon RDS creates a second DB instance using a snapshot of the source DB instance. It will uses the engines’ native asynchronous replication to update the read replica whenever there is a change to the source DB instance. The read replica operates as a DB instance that allows only read-only connections; applications can connect to a read replica just as they would to any DB instance.
To migrate a Single-AZ deployment or Multi-AZ DB instance deployment to a Multi-AZ DB cluster deployment with reduced downtime, you can create a Multi-AZ DB cluster read replica.
Find RDS PostgreSQL instance rdspg-fcj-labs 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 Cluster - new 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.
You can then connect to the read replica using its endpoint and the same username and password as the source instance. 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;
You can also promote this Multi-AZ read replica cluster to a stand-alone cluster. We will do that in the next step.
It will take about 1-2 minutes for your read replica to be detached and promoted as an independent RDS DB Cluster with Multi-AZ DB Cluster deployment option.
At this point, you have successfully migrated your RDS PostgreSQL instance with Multi-AZ DB Instance deployment mode to the RDS PostgreSQL Multi-AZ DB Cluster deployment option.
Congratulations: In this lab, you added a Multi-AZ DB Cluster read replica instance to your configuration to migrate your application/database from Multi-AZ DB Instance deployment option to the Multi-AZ DB Cluster deployment option.
Alternatively you can promote the read replica using the AWS CLI as shown below: