Nov 17, 20264 min read

RDS Read Replicas: Setup, Lag, Promotion and When to Use Them

Create an Amazon RDS read replica for PostgreSQL, watch replication lag, promote it to a standalone instance, and when a primary with Multi-AZ is the better tool.

Illustration for RDS Read Replicas: Setup, Lag, Promotion and When to Use Them

An Amazon RDS read replica is a copy of a database instance that applies changes from the primary asynchronously and can take read traffic. Teams add one when reporting, search indexing or an analytics job is crowding the writer.

A read replica is not a Multi-AZ standby: replication is asynchronous, so a replica can lag, and a failover is a promotion you start, after which the replica is a new primary and does not automatically take the old writer's endpoint.

This guide creates a PostgreSQL replica, checks lag, and promotes it. Encore provisions the primary in your AWS account from application code; it does not create replicas.

Read replicas at a glance

Read replicaMulti-AZ standbyEncore primary
PurposeOffload reads, create a copy to promoteAutomatic failover of the writerThe database your service declares
ReplicationAsynchronousSynchronous to the standbyNot applicable
ReadableYesThe standby is not a read endpointThe primary is what encore run and deployed services use
FailoverManual promotionAutomaticNot a replica topology
Who creates itYou, in RDS or TerraformYou, as an RDS settingEncore, on deploy to your account

Create a PostgreSQL read replica

The primary must have automatic backups enabled, because RDS uses the backup and transaction logs to seed the replica. Create the replica in the console or with the CLI, in the same region or in another region, as described in Creating a read replica:

~
$ aws rds create-db-instance-read-replica \ --db-instance-identifier app-postgres-read \ --source-db-instance-identifier app-postgres \ --db-instance-class db.t3.medium \ --publicly-accessible false

RDS for PostgreSQL allows up to 15 read replicas of a source instance in the supported configuration. The replica can use a different instance class than the primary. Give it a security group that your readers can reach, and keep it off the public internet.

Applications must use the replica endpoint for read-only sessions and the primary endpoint for writes. A connection pooler or a second pool in the app is the usual split. Do not send a read that follows a write on the primary to the replica and expect to see the row immediately.

Watch lag and promote

ReplicaLag is the CloudWatch metric to alarm on, and in PostgreSQL, pg_last_xact_replay_timestamp() on the replica and pg_stat_replication on the primary give a closer look. If lag grows through a heavy write period, either reduce write bursts, enlarge the replica, or stop sending lag-sensitive reads there.

To make a replica a writable instance, promote it, which cannot be undone: the replica stops following the old primary, and you must point writers at the new endpoint (or swap DNS) yourself. Take a backup of the primary first, and pause writers if you need a consistent cutover rather than a last burst of unreplicated transactions.

A Multi-AZ deployment is still the tool for automatic writer failover. A replica can complement it, but it does not replace it.

Best fit: read-heavy workloads that can tolerate some lag, or a copy you are prepared to promote during a planned move.

The primary in Encore, replicas in RDS

Encore

Encore brings infrastructure from code: sqldb.NewDatabase is provisioned as RDS for PostgreSQL in your AWS account, or Cloud SQL in your GCP account, as the AWS and GCP infrastructure docs describe. encore run starts Postgres locally, and Encore provisions an IAM role for the service, or a service account on GCP.

Encore does not create read replicas or expose a second read endpoint. If you add a replica to the RDS instance Encore provisioned, configure the replica in RDS or Terraform, grant the application a read-only connection string yourself, and keep writes on the Encore-managed primary. Do not assume Encore will route queries or fail over to that replica.

A coding agent working in the repository changes the schema and queries against the declared database. The replica remains an RDS object next to that primary.

Best fit: services that want the primary declared in code and, if needed, a read replica managed explicitly in RDS.

How to choose

Create a read replica when you have read traffic that can tolerate asynchronous lag. Use Multi-AZ for writer failover. Use Encore when you want the primary provisioned from application code in your own account, and add a replica only when you are ready to own its endpoint, lag and promotion.

Frequently asked questions

What is an RDS read replica?

A read replica is a second RDS instance that receives changes from a primary asynchronously and can serve read-only traffic. If the primary fails, a replica does not fail over automatically; you promote it, at which point it becomes a standalone writer and stops replicating.

How many PostgreSQL read replicas can I create?

Amazon RDS for PostgreSQL supports up to 15 read replicas per source instance, including replicas of replicas in the supported topology. Check the current RDS quota and engine documentation for your version, because cross-region replicas and cascading replicas have additional limits.

How do I know if a replica is falling behind?

Watch the ReplicaLag CloudWatch metric, which is the number of seconds the replica is behind the primary. In PostgreSQL you can also query pg_stat_replication on the primary and pg_last_xact_replay_timestamp on the replica. Plan the application around lag; a read-your-writes path should use the primary.

Does Encore create RDS read replicas?

No. Encore provisions the primary RDS instance, or Cloud SQL on GCP, from the database declared in your code. A read replica is created in the RDS console or with the AWS API against that instance if you need one. Point read-only queries at the replica endpoint yourself.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders