Skip to main content
PreparationZone Logo
PrepZone

Replication Models

Single-leader, multi-leader, and leaderless replication — sync vs async trade-offs.

Pass checkpoint below

Read these first

Why this matters

  • Read replicas are the first scaling lever after connection pooling; misrouting writes or freshness-sensitive reads causes subtle production bugs.
  • Failover during Black Friday tests whether your replication topology promotes cleanly in under two minutes.
  • Interviews contrast single-leader, multi-leader, and leaderless designs with concrete trade-offs.

Single-leader replication

The most common pattern: one primary accepts writes; replicas apply the WAL asynchronously.

App writesINSERT / UPDATE
LeaderPrimary node
Replica 1Read traffic
Replica 2Read traffic
Writes go to the leader; replicas serve read traffic asynchronously.

Single-leader characteristics

  • Write path — all INSERT/UPDATE/DELETE go to the leader.
  • Read path — replicas serve read traffic with bounded staleness.
  • Failover — promote a replica when the leader fails; brief write outage.
  • VaultCommerce use — Postgres primary + two read replicas for browse and search hydration.
Java
-- Application routing (HikariCP data sources)
-- writeDataSource → primary.vaultcommerce.db
INSERT INTO orders (id, user_id, total) VALUES ($1, $2, $3);

-- readDataSource → replica.vaultcommerce.db
SELECT id, status, total FROM orders WHERE user_id = $1 ORDER BY created_at DESC;

After checkout, VaultCommerce reads the confirmation page from the primary so the customer never sees "order not found" due to replica lag.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 4 sections

  • Synchronous vs asynchronous replication
  • Multi-leader replication
  • Leaderless replication
  • Monitoring replica health

Test yourself

Answer these before moving on — recall is what makes it stick.