liveBook · Manning

Read replication

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

A read replica is a replicated database instance that serves read-only queries and can be promoted to primary in supported configurations.

Read replication scales database reads horizontally by copying changes from a writable primary to one or more read-only replicas. Applications distribute read requests across the primary and replicas while sending writes to the primary. section 10.6.2

Replication is asynchronous, so a replica can lag behind the primary. This improves read throughput when an application performs many more reads than writes, but users may see stale data. section 10.6.2 section 11.5.3

A practical Amazon RDS setup involves:

  • Enable automatic backups before creating the replica. section 10.6.2
  • Create the replica from the primary database; RDS snapshots the source, launches the new instance, activates replication, and provides a read endpoint. section 10.6.2
  • Route read and write requests separately in the application; database replication alone does not make this distinction. section 10.6.2
  • Monitor replication lag and increase cache capacity with additional shards or replicas when lag indicates a capacity problem. section 11.5.3 section 11.6

Scaling a WordPress database

For an RDS-backed WordPress site, create a read replica with the AWS CLI and configure application support for replica reads. WordPress does not support read replicas by default; HyperDB can provide that support, but its configuration is tricky. The replica incurs additional charges and can later be promoted to primary when supported. section 10.6.2 section 10.6.2

$ aws rds create-db-instance-read-replica \
 --db-instance-identifier awsinaction-db-read \
 --source-db-instance-identifier $DBInstanceIdentifier

Use the AWS CLI command to create an RDS read replica from the existing primary instance. section 10.6.2

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Explains asynchronous replication, application routing, creation steps, lag monitoring, promotion, and billing, but not replica internals.
Examples
Uses an RDS WordPress database, HyperDB, AWS CLI commands, distributed read requests, and a Redis gaming application with measurable lag.
What it assumes
Assumes basic database use and application requests while teaching automatic backups, read-write routing, replica lag, and RDS operations.
What you can do after
Apply it via Amazon RDS by creating replicas, routing reads, monitoring lag, and promoting or deleting replicas when appropriate.
How it connects
Connects read replicas with primary databases, automatic backups, application-level routing, replication lag, caching, and high availability.

Also explained in

Compare how 2 books explain read replication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.