A read replica is a read-only copy of a DB instance. RDS creates it from a snapshot of the source, then keeps it up to date with the asynchronous streaming replication of PostgreSQL. Applications can send read-only queries (reports, dashboards, searches) to the replica and keep the primary free for writes.
| Primary | Read replica | |
|---|---|---|
| Reads | Yes | Yes |
| Writes | Yes | No, the replica is read-only |
| Endpoint | Its own | Its own, different from the primary |
| Data | Current | A few seconds behind (replica lag) |
| Number | 1 | Up to 15 per source, in the same or another Region |
In the list of databases:
rdspg-lab-db.
In Settings and Instance configuration:
rdspg-lab-db.rdspg-lab-db-readdb.t4g.micro
A replica can use a different instance class than its primary. Keep the same class or larger for a replica that you might promote, or one that must keep up with a busy primary.
In Availability, the console selects Multi-AZ DB instance deployment by default:

In Connectivity, the console copies the settings of the source. Check them:
rdspg-lab-subnet-grouprds-sg
Keep the other settings and choose Create read replica at the bottom of the page.
In the list of databases:
rdspg-lab-db changes to Modifying while RDS takes a snapshot of it. Its role is now Primary.rdspg-lab-db-read appears under it with the role Replica and the status Creating.
The replica takes about 10 to 15 minutes. rdspg-lab-db stays available the whole time.
When rdspg-lab-db-read is Available, choose it. On the Connectivity & security tab, choose Endpoints in Connect using and expand Additional configurations:
rdspg-lab-db.rds-sg.
Scroll down to Replication:
rdspg-lab-db-read has the role Replica, the source rdspg-lab-db, the state Replicating, and a lag of a few seconds.
On the App server, connect to the endpoint of the replica. Enter the master password when psql asks for it:
R=<endpoint of rdspg-lab-db-read>
psql -h $R -d pglab \
-c "SELECT pg_is_in_recovery() AS is_replica, count(*) AS accounts FROM pgbench_accounts;" \
-c "SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS replica_lag_seconds;" \
-c "CREATE TABLE test_write(id int);"
pg_is_in_recovery() is t: the server is a replica. It has all 5,000,000 rows of pgbench_accounts from chapter 3.replica_lag_seconds is the time since the last transaction that the replica applied.
replica_lag_seconds grows when nobody writes to the primary, because it measures the time since the last replayed transaction. It is a good lag indicator only while the primary is busy. The CloudWatch metric ReplicaLag of the replica is more reliable.