Managed relational databases · Chapter 2 of 2
Why read replicas are not failover targets
Replicating data asynchronously allows you to scale read workloads, but read replicas cannot protect your application from a database write failure.
FoundationsBuilds the idea from nothing. No prior AWS assumed.
Understanding asynchronous database replication
Why should you separate write queries from read queries?
Applications send write operations to the primary instance, and direct read queries to the replica.
- 01
The scaling limit of a single database
A relational database handles writes on a single primary instance. When read traffic increases, those select queries consume CPU and memory, slowing down write transactions on the primary database.
- 02
Asynchronous replication to the rescue
Read replicas copy data asynchronously from the primary database. This means the primary commits writes immediately, without waiting for the replica to receive the data, which frees the primary to handle more writes.
- 03
The lag trade off
Because replication is asynchronous, a read replica will always lag slightly behind the primary. Applications that require immediate consistency, such as user login validation, must query the primary database instead of a replica.
Check yourself
Which query type is best suited for execution on an RDS read replica?
Under the hoodThe same thing from underneath: limits, failure modes, numbers.
Promotion mechanics and cross region latency
What happens when you promote a read replica to a primary database?
Applications send write operations to the primary instance, and direct read queries to the replica.
- 01
The replication lag constraint
Under heavy write load or network congestion, replication lag can grow. If the replica lags by several seconds, reading from it will return outdated data, which is known as replication lag.
- 02
Promoting a replica is a one way door
You can promote a read replica to become a standalone database. Once promoted, the replica becomes a primary database instance, the replication link is severed, and you cannot easily link it back.
- 03
The price of cross region replicas
Replicating data to another Region protects against regional disaster and places data closer to international users. However, you must pay for cross-Region data transfer, which is billed per gigabyte.
The numbers
- Read replica count
- Engine-specificLimits vary by database engine and deployment type. Check the current RDS engine documentation.
- Typical replication lag
- Under 1 secondUnder normal operating conditions and network speeds, replication is near instantaneous.
- Cross-Region replication cost
- $0.02 per GBThe cost of data transfer out of the primary region to the replica region.
Check yourself
You promote an RDS read replica to a primary database. What happens to its replication link with the original primary instance?
Official references & further reading
These lessons simplify selected behaviors for learning. Verify current service limits, Region support and production requirements with the official references. Experiments describe their own assumptions.
Report an error or suggest a clearer explanation →