liveBook · Manning

Read replica

As explained in Fast by Default

A read replica is a database copy maintained primarily to serve read operations, often to distribute read load or support another region.

A read replica is a copy of a primary database that serves read operations while the primary handles writes. It addresses a scalability problem: when queries are already optimized but read volume overwhelms one database server, replicas distribute that traffic across multiple servers and increase read capacity without changing the primary’s configuration. section 5.4.2 section 5.5.1 section 5.1

Replication creates a consistency trade-off. Replication lag is the delay before a write on the primary appears on a replica. Synchronous replication waits for replica confirmation, reducing lag but adding latency to every write; asynchronous replication improves write performance but can leave replicas behind by milliseconds or seconds under heavy load. A replica is therefore appropriate only when the read can tolerate the chosen consistency behavior. section 5.4.2

Use read replicas as a measured scaling pattern:

  • First establish that the bottleneck is scalability under growing load, rather than slow individual queries or a resilience failure. section 5.1
  • Offload read traffic only after query optimization when volume, not inefficient queries, is the limiting factor. section 5.5.1
  • Keep writes on the primary and identify read-after-write flows that would confuse users if they observe stale data. section 5.4.2
  • Choose deliberately between lower-lag synchronous replication and faster asynchronous writes with eventual consistency. section 5.4.2
  • Treat replicas as one database-layer option alongside materialized views, denormalization, connection pooling, indexing, and sharding decisions driven by actual bottlenecks. section 5.5.1 section 5.6

Profile update and stale read

A user updates a profile, then immediately views it. If that follow-up read reaches a replica that has not received the write, the old profile can appear and make the update seem to have vanished. This is a lag-sensitive path: increasing read capacity alone is not enough; routing and consistency behavior must preserve the user-visible result. section 5.4.2

Scaling a read-heavy primary

A single-primary PostgreSQL deployment can serve a very large read-heavy workload with nearly 50 replicas across regions. The approach scales reads horizontally while separately controlling write pressure through connection pooling, workload isolation, and separate sharded databases for new write-heavy features. Sharding follows demonstrated write bottlenecks rather than user count alone. section 5.4.2

Read replicas do not make every database problem a replication problem. They add infrastructure and cannot fix a speed problem caused by poor algorithms or unoptimized queries. They are most useful when the user-facing goal is to keep read paths responsive as demand grows, while making staleness an explicit operational and product decision. section 5.4.2 section 5.1

How Fast by Default covers it

How deep it goes
Explains primary-write and replica-read roles, replication lag, synchronous versus asynchronous trade-offs, and lag-sensitive routing constraints.
Examples
Uses a stale profile view after an update, Figma’s capacity response, and a multi-region PostgreSQL deployment with nearly 50 replicas.
What it assumes
Assumes familiarity with database reads, writes, queries, and primary-server terminology while defining replication behavior.
What you can do after
Evaluate/understand when read traffic can move to replicas and when replication lag makes a read path unsafe.
How it connects
Connects read replicas with eventual consistency, connection pooling, sharding, materialized views, indexing, and denormalization.

Also explained in

Compare how 3 books explain read replica →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast by Default. The section links point to the parts of the book it draws on.