redisHigh
Fix: Redis Replication Lag Causing Stale Reads
Application reading stale data from Redis replicas
!Symptoms
- Application reading stale data from Redis replicas
- redis-cli INFO replication shows high master_repl_offset gap
- Replica shows master_link_status:down intermittently
- Cache inconsistencies across application instances
?Root Causes
- Network latency between master and replica (cross-zone or cross-region)
- Replica running out of output buffer due to slow consumption
- Master writing faster than replica can sync (write-heavy workload)
- Replica performing RDB save (BGSAVE) blocking replication
- Large keys causing replication stream to stall
#Diagnosis Steps
- 1Check replication info: `redis-cli INFO replication` — compare master_repl_offset
- 2Check replica lag in seconds: `redis-cli INFO replication | grep lag`
- 3Monitor output buffer: `redis-cli INFO clients | grep output_buffer`
- 4Check slow log: `redis-cli SLOWLOG GET 10`
- 5Check memory usage: `redis-cli INFO memory`
>Fix
- 1Move replica to same availability zone as master to reduce network latency
- 2Increase client-output-buffer-limit for replica: `config set client-output-buffer-limit 'replica 512mb 128mb 60'`
- 3Disable RDB persistence on replicas: `config set save ''`
- 4Break up large keys into smaller keys
- 5Use WAIT command for critical reads: `WAIT 1 1000` to ensure replication
*Prevention
- Monitor replication lag with Prometheus redis_exporter
- Alert on master_repl_offset divergence > threshold
- Use Redis Sentinel or Cluster for automatic failover
- Read from master for critical consistency-required operations
- Size replicas with same or better specs than master
Related Error Messages
master_link_status:downLOADING Redis is loading the dataset in memoryBUSY Redis is busy with a blocking commandreplica output buffer limit exceeded