Database / REDIS
How does Redis handle replication lag between a master and its replicas?
Redis replication is asynchronous by default: a write completes and is acknowledged to the client as soon as the master processes it, without waiting for any replica to confirm receipt — which is what makes writes fast, but also means a replica's data can lag slightly behind the master at any given moment, and that gap can widen under heavy write load or network issues.
INFO replication # master_repl_offset:12345 # slave0:...,offset=12300,lag=1
Redis exposes replication offsets on both master and replicas, and the difference between them is effectively the lag — visible via INFO replication, which is the standard way to monitor how far behind a given replica currently is. For workloads that can't tolerate reading stale data from a lagging replica, the WAIT command lets a client block until a write has been acknowledged by a specified number of replicas (with a timeout), effectively trading some of replication's default speed for a stronger consistency guarantee on that specific write, without switching the whole deployment to synchronous replication permanently. Persistent, growing lag over time is usually a sign the replica's hardware, network, or CPU can't keep pace with the master's write volume, and is treated as an operational issue to investigate rather than expected behavior.
More Related questions...
