Debug Foundry

One database can't answer everyone. Copies can.

Turn it, pause it, drag through the steps. Then try a different workload.

Not a video. A small simulation of read replicas: one primary takes writes, copies stream out, reads spread across the replicas.

Drag to turn · scroll or pinch to zoom

Finished state of the replication simulation: clients on the left, a primary database in the middle, two replica databases answering reads on the right

Primary
reads + writes

1/8First step sentence

    0.0s
    Replay the ending with

    What it's for

    Good to know

    Shown is single-leader replication with asynchronous log shipping — the PostgreSQL/MySQL default family, one design among many. The write's acknowledgment here is primary-only: the client hears "done" before any replica has the change, and receiving a log record is not applying it — a replica can hold the record and still serve the old value until it applies. A crash after an async ack but before the stream lands can lose that acknowledged write. That stream creates the lag window — a read that lands on a not-yet-updated replica sees the old value, which is why "read your own writes" is a feature you have to build (route the writer's reads to the primary, track a position in the log, or wait). Synchronous replication narrows the window by confirming the write only after a replica acknowledges — the third sandbox replay uses a one-replica ack — at the cost of slower, less available writes; and even then only that replica is current, not every read everywhere. Replicas scale eligible reads, not writes: every write still funnels through the one primary (splitting writes is the sharding chapter), and a replica read isn't faster, just spread. Replication lag is also not cache expiry: the copy updates when the log record applies, not on a timer. Replicas are a read-scaling and availability tool, not backups: a mistaken delete streams to every copy just as faithfully. Not shown: failover, which is only safe with leader election, fencing (so the old primary can't still accept writes) and catch-up — promoting a stale replica without them can lose acknowledged writes or split the brain; and multi-primary setups.

    How it works, step by step

      Why the steps go in this order

      Before you rely on it

      This is a toy: one primary, two replicas, hand-set traffic ("9 reads : 1 write") and hand-set lag; version and log counters (#41–#43) are the toy's own state, not benchmarks. Real lag varies with load, network and replica count, from milliseconds to seconds and beyond — nothing here is a measurement. "Reads spread across replicas" assumes the app routes them there; proxies, drivers and consistency needs decide that in practice. The cited sources describe production systems with their own measured behavior.

      References