Redis replication
- Compare partial resynchronization with snapshot transfer after a replica disconnects.
Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.
- A replica remembers which stream it followed and how many bytes it applied. The primary’s backlog holds a rolling window of that stream.
- At 4 MiB/s, a filled 64 MiB backlog covers about 16 seconds. A replica on the same history can recover a 10-second gap by requesting the missing bytes.
- After a 20-second gap at that rate, the oldest missing bytes are gone. Redis transfers a dataset snapshot and the writes made since that snapshot.
Reading
- A compatible replication ID and a retained offset allow a replica to receive just the missing suffix. A new replica or a missing history range needs full synchronization.
- A full sync transfers the dataset and catches up subsequent writes. High write rates shorten the backlog window and increase catch-up demand.
Redis replication
Redis replication
Redis Open Source 7.2 architecture
Size the reconnect window
- A filled 64 MiB backlog and a steady 4 MiB/s replication stream hold roughly 16 seconds of history. Use measured replication-offset growth, including bursts, when sizing the backlog.
- A 10 s interruption misses about 40 MiB. An eligible replica on the same history can resume from its next offset if the suffix is retained.
- A 20 s interruption misses about 80 MiB. Here the head of the missing range has been overwritten. The replica needs a full sync even when both servers have otherwise healthy storage.
- A short gap can also need full sync when the requested history is unknown. A promoted primary can recognize its predecessor’s ID up to a recorded offset.
Which reconnects fit the backlog?json
{
"kind": "illustrative PSYNC reconnect cases",
"replicationId": "H1 (symbolic)",
"backlogBytes": 67108864,
"steadyStreamBytesPerSecond": 4194304,
"nominalHistorySeconds": 16,
"assumptions": "Backlog is active, filled and retained. Rate is constant and includes all replication-stream bytes.",
"cases": [
{"history": "H1", "disconnectedSeconds": 10, "missingBytes": 41943040, "expected": "partial if requested offset retained"},
{"history": "H1", "disconnectedSeconds": 20, "missingBytes": 83886080, "expected": "full because required bytes have rolled out"},
{"history": "unknown", "disconnectedSeconds": 1, "missingBytes": 4194304, "expected": "full because history is incompatible"}
]
}
Account for the full-copy cost
- The primary supplies an RDB snapshot, potentially through diskless transfer, and buffers/streams subsequent changes. The replica loads the image and applies the catch-up stream.
- Size bandwidth, memory and disk headroom for resync during normal write traffic. Several disconnected replicas can compete with client traffic when they return.
- A read served from a replica can trail a committed primary write. For a read with a freshness requirement, route or validate it against the application’s consistency contract.
- Observe primary and replica offsets, link state and full/partial synchronization counters. Separate slow application reads from lag in the replication link.