Replication Explained: WAL Shipping, Lag, and Failover
Replication is the log, applied elsewhere. We follow a write through the transaction log to the replica: how streaming replication ships WAL, how the replica replays it, and what lag actually means at each stage. Then we measure what lag does to a read-heavy application in real time. We compare synchronous and asynchronous modes on the same workload — durability vs. availability — and walk the failure modes: lag-driven stale reads, split-brain after failover, and the promotion decisions a replication topology forces on you. The video ends with practical monitoring: what to watch to know your replica is healthy.
Topics covered:
- WAL shipping and replay mechanics
- What lag is at each replication stage
- Sync vs. async durability trade-offs
- Failover, split-brain, and health monitoring
Related articles
Why Your Query Is Slow (And It's Not the Index)
Buffer pool misses, WAL contention, lock waits, and connection pooling — the non-index causes of database slowness.
Replication Lag and Consistency Guarantees
Async vs sync replication, read-after-write consistency, and the physical limits of replicating data across nodes.
Write-Ahead Logging and Crash Recovery
WAL, checkpointing, and ARIES recovery — how databases guarantee durability without fsyncing every row.
More in Databases
B-Trees: The Shape of Databases
Why every major database is a tree shaped like a disk page — and how to read your index's health from its shape.
WatchPostgres Internals Tour: Processes, Buffer Pool, WAL, and MVCC
A guided tour of PostgreSQL internals — process model, buffer manager, WAL, and MVCC — the mechanisms that make Postgres behave the way it does.
DetailsSQL Joins and Execution Plans: Nested Loop, Hash, and Merge
How the database executes joins — nested loop, hash join, and merge join — and how to read execution plans to see which strategy your query gets.
DetailsConnection Pools, Database-Side: What a Connection Really Costs
What actually happens to your database when connections pile up — the connection lifecycle, pool sizing math, and why max_connections is not a tuning knob.
DetailsStorage Engines: LSM-Trees vs. B-Trees
LSM-trees vs. B-trees — how each storage engine writes, compacts, and reads, and what that means for write and read amplification in your workload.
DetailsSharding Strategies: Partition Keys, Distribution, and Rebalancing
How sharding actually works — partition keys, data placement, cross-shard queries, and the operational reality of splitting one database into many.
DetailsTransactions and Isolation Levels: ACID, MVCC, and Anomalies
What transactions actually guarantee — ACID mechanics, MVCC, and the real behavior behind each isolation level, demonstrated with concrete anomalies.
DetailsDatabase Indexes Visualized: B-Trees, Covering Indexes, and Planner Decisions
How database indexes actually work — B-trees, hash indexes, covering indexes, and when the planner will or won't use the index you made.
DetailsQuery Optimizer Internals: From Parse Tree to Execution Plan
What happens inside a query optimizer — parse, rewrite, join ordering, cost models, and how the planner decides the plan your query gets.
DetailsDepth, delivered weekly
One technical dispatch a week — articles and episode notes before they go public.
One technical dispatch per week. No noise.