Systems and protocols · Intermediate

Redis replication: asynchronous copies and lag

Follow full and partial synchronization and distinguish replica acknowledgments from complete durability or strong consistency.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. An acknowledgment can precede replication
  2. Trace reconnect and retained history
  3. Understand what WAIT establishes
  4. Separate failover from persistence
  5. Ask Logeia about this articleCheck your understanding

An acknowledgment can precede replication

Redis replication is ordinarily asynchronous. A primary sends changes to replicas, but a successful client response does not imply that every replica has applied or durably stored those changes. Routing reads to replicas can therefore expose an older value immediately after a primary update. Treat this delay as part of the consistency contract rather than assuming that any difference is necessarily corruption. Decide which operations require fresh reads and which can tolerate lag. Merely labeling nodes primary and replica does not determine whether the results satisfy an application’s user-visible requirements.

Trace reconnect and retained history

Suppose a replica disconnects after receiving stream offset 1000 while the primary later advances to 1500. If the required history remains in the replication backlog and the replication identity conditions match, partial resynchronization can send the missing portion. If the retained range or identity is unsuitable, a full synchronization is needed instead. The offset numbers illustrate positions, not necessarily a count of user writes. Reconnection cost depends on update volume and retained history as well as elapsed disconnection time. A short outage during heavy writes can exhaust a small backlog.

Understand what WAIT establishes

WAIT can wait for acknowledgments from a requested number of replicas for preceding writes on the connection. Reaching that acknowledgment count is not a universal proof of strong consistency or permanent storage under every failure scenario. Promotion choice, persistence configuration and simultaneous failures still affect what survives and what later reads observe. On timeout, inspect the returned count rather than assuming that the requested threshold was reached. Waiting is one mechanism with a defined scope; the application still needs to relate that scope to its actual durability and availability requirements.

Separate failover from persistence

Replication, persistence through mechanisms such as RDB or AOF, and failure detection or promotion are related but distinct responsibilities. Having replicas does not make every persistence-free restart safe. Configuration must avoid allowing an unexpectedly empty restarted primary to propagate that state as authoritative data. Monitor replication position, lag and full-sync frequency alongside connection state. Additional replicas can change read capacity without automatically satisfying the desired write-survival contract. Test the specific restart and failover procedure, and identify which node state is eligible to become authoritative after each failure.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Understand the systems behind the web · STEP 13

Choose a learning path