AlgoViz

Replication fundamentals

medium 28 min

How a change travels from one copy to another: what is written in the log (statements, rows or physical bytes), when the client is told it is done (synchronous, semi-synchronous, asynchronous), why replicas lag, and which promises keep users from seeing confusing old data.

Where it shows up

The same pattern appears across everyday software.

  • PostgreSQL streaming replication

    Physical and asynchronous by default. A list of synchronous standbys and a level per transaction turn it into the other modes.

  • MySQL binary log

    Row format is the default. The format choice is deprecated, and row is expected to become the only one.

  • Shopify

    An engineering post compares tight consistency, causal consistency with global transaction ids, and monotonic reads for queries against MySQL replicas.

  • GitLab

    Its load balancing sends a user's reads to the primary after a write, for up to 30 seconds, and goes back to replicas as soon as they have caught up.

  • Azure Cosmos DB

    Offers named levels, among them session consistency, which includes read your writes, and bounded staleness in versions or time.

  • MongoDB

    Secondaries copy the primary's oplog and apply it asynchronously. A write concern of majority makes the client wait for most members.