All the basics

What are replicas?

A replica is a live copy of a database. Copies share the reading, and one can take over if the original fails.

A copy machine: every change to the original cabinet is duplicated into more cabinets, so people can read from any of them.

Press Play to watch it run · 4 steps

One database handles all reads and writes and is a single point of failure. Copies take the reads, but can lag a moment behind.

One database versus copiesOne database handles all reads and writes and is a single point of failure. Copies take the reads, but can lag a moment behind.writesreadsreadsYour appMain databaseCopy 1Copy 2

Tap any box to see what it is and what it talks to.

  • Service
  • Database
Open in playground
Text description
  1. Every read and every write goes to one database.
  2. Reads pile up, and writes wait behind them.
  3. The machine fails, and no other machine has a live copy.
  4. Nothing can be read or written, so the whole app stops.
  • A replica is a live copy of the database.
  • Copies take the reads and can replace a failed main database.
  • A copy can be a moment behind the original.

Reach for it when

When reads far outnumber writes, like ten to one, or the business cannot survive losing one database. Not for hobby apps.

The catch

You change your name, reload, and a lagging copy still shows the old one. Fresh reads go to the main.

Say it in an interview“I would add read replicas to scale reads and survive failures. The cost is replication lag, so reads that must be fresh go to the main database.”