Redis in depth · senior
Redis persistence, replication and Sentinel
Redis can lose data in several ways: a restart without persistence, the last seconds before a snapshot, and asynchronous replication during a failover. Match the setting to the data.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- RDB: point-in-time snapshots made by a forked child. Compact and fast to load, but you lose everything since the last snapshot. A fork of a big dataset can stall Redis briefly.
- AOF: a log of every write. appendfsync everysec (the common default) loses up to about a second. always is safest and slowest.
- Both together is common: AOF for durability, RDB files for backups.
- Replication is not persistence: if a primary with persistence off restarts empty and its replicas sync from it, they wipe themselves.
- Replication is asynchronous: the primary acknowledges before replicas have the write, so a failover can lose the last writes. WAIT makes one write wait for replicas, but is still not a guarantee. min-replicas-to-write makes a cut-off primary stop accepting writes.
- Sentinel: at least 3 processes in different failure zones watch the primary. When enough agree it is down (the quorum), one promotes a replica. Clients ask Sentinel for the current primary.
- Split brain: an old primary cut off from Sentinels but not from some clients keeps accepting writes. After the network heals it becomes a replica and its separate writes are thrown away. Clients must re-resolve the primary on failover.
- Picks: a cache needs no persistence. A job queue needs AOF, replicas and noeviction, or a real broker. A leaderboard that is slow to rebuild needs RDB plus AOF. Money must not live only in Redis: a durable ledger comes first.
The red pen
Common traps: mistake → fix
Mistake: Redis is in memory, so it cannot persist
Fix: RDB and AOF exist.
Mistake: Replicas are backups
Fix: an empty primary can wipe them.
Mistake: Sentinel guarantees no data loss
Fix: failover can lose writes.
Mistake: AOF always for everything
Fix: it is slow and needed for few cases.
Easy to hard
Questions interviewers ask, easy to hard
- RDB, AOF or no persistence for a cache, a queue and a leaderboard?
- How does Redis stay available when a node dies?
- About 2,000 wallet credits vanished after a Sentinel failover. How?
- What are min-replicas-to-write and WAIT?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.