Redis

Persistence Interview Questions

Persistence interview questions for Redis — fundamentals through advanced scenarios.

  • 20Questions with answers
  • 3Difficulty levels

Questions (20)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Beginner
Question

How do RDB and AOF differ, and why do teams often enable both?

Answer:

RDB is a fork-and-snapshot point in time; AOF is a rewriteable log of write commands. RDB restarts faster; AOF with appendfsync everysec loses at most about one second. Many teams enable both so a truncated AOF can still fall back to the last RDB.

Question 2
Interview Beginner
Question

What do appendfsync always, everysec, and no actually trade?

Answer:

appendfsync always fsyncs every write, everysec batches, and no leaves it to the OS. always crushes throughput; no risks more loss after a power fail. everysec is the usual production compromise interviewers expect.

Question 3
Interview Beginner
Question

What does an AOF rewrite do that a growing AOF file does not?

Answer:

AOF rewrite produces a shorter file that reconstructs the same dataset; it is not a second database engine. After rewrite, Redis still uses the AOF fsync policy you chose. Leaving AOF on without rewrite is how disks fill.

Question 4
Interview Beginner
Question

How do you restore Redis from RDB or AOF after a crash?

Answer:

Restoring means placing dump.rdb or appendonly.aof in the data dir and starting Redis, or cloning a replica then replicaof no one. Test restore on a spare host; an untested RDB is not a backup. Match Redis version or know RDB format compatibility.

Question 5
Interview Beginner
Question

When is it correct to run with save "" and appendonly no?

Answer:

save "" disables RDB snapshots; appendonly no disables AOF. A cache with eviction often runs with both off and accepts total loss. A session or job store that people call a cache but cannot lose should not use that profile.

Question 6
Interview Beginner
Question

What is diskless replication and when does it help the primary?

Answer:

Diskless replication via repl-diskless-sync streams the RDB to replicas over the socket instead of writing a temp file on the primary. Use it when the primary disk is the bottleneck. Replicas still need room if they persist locally.

Question 7
Interview Beginner
Question

Does a replica inherit the primary persistence settings?

Answer:

Replica persistence is per process: a diskless sync on the primary does not decide whether the replica writes AOF or RDB. A replica with save "" and appendonly no is RAM-only and cannot rebuild after its own crash without a full resync. Set replica persistence explicitly.

Question 8
Interview Intermediate
Question

How does fork copy-on-write during BGSAVE create latency spikes?

Answer:

fork copy-on-write during BGSAVE duplicates pages the parent dirties while the child writes the RDB. A heavily written dataset during save can briefly approach 2x RSS. That is why saves on a saturated primary cause latency spikes.

Question 9
Interview Intermediate
Question

What happens during BGREWRITEAOF on a live primary?

Answer:

BGREWRITEAOF rewrites a compact AOF in a child using copy-on-write, similar to BGSAVE. The parent keeps appending to a buffer. A rewrite storm plus a big dataset means COW memory spikes you must size for.

Question 10
Interview Intermediate
Question

What is aof-use-rdb-preamble and why does it matter on restart?

Answer:

Mixed RDB plus AOF load can use an RDB preamble inside the AOF so restart is faster than replaying every write. Misconfigured preamble after an upgrade is a common surprise. Know which files you are actually shipping as backups.

Question 11
Interview Intermediate
Question

What should a Kubernetes PreStop hook do for Redis durability?

Answer:

shutdown save versus shutdown nosave decides whether you take a last RDB on stop. Kubernetes SIGTERM without a save can lose the last everysec window. PreStop hooks that run BGSAVE or wait for AOF fsync are the ops answer.

Question 12
Interview Intermediate
Question

Which INFO fields tell you persistence is actually healthy?

Answer:

Checking persistence health means INFO persistence: last_save, aof_rewrite_in_progress, rdb_last_bgsave_status. A failed BGSAVE that nobody alerts on is a silent backup hole. Also watch fork time in LATENCY DOCTOR.

Question 13
Interview Intermediate
Question

Why copy RDB or AOF from a replica instead of the primary?

Answer:

Replica as backup source means BGSAVE or copy files from a replica so the primary does not fork under load. Never copy a live RDB while it is being rewritten. Wait until rdb_last_bgsave_status is ok.

Question 14
Interview Intermediate
Question

How much can you still lose with appendfsync everysec?

Answer:

AOF fsync everysec still loses writes in the last second plus any that were in the rewrite buffer during a crash at the wrong time. Quote that window. Applications that need stronger durability need appendfsync always or a disk database.

Question 15
Interview Advanced
Question

How can repeated BGSAVE raise fragmentation even when used_memory looks stable?

Answer:

COW fragmentation after repeated BGSAVE can raise mem_fragmentation_ratio even when used_memory looks stable. activedefrag or a rolling restart of replicas recovers it. Persistence load is an operations memory problem, not just a disk problem.

Question 16
Interview Advanced
Question

How would you enable AOF on a huge already-running primary without stalling it?

Answer:

Enabling AOF on a huge already-running instance rewrites history and can stall; do it on a replica, wait for catch-up, then failover. Big-bang appendonly yes on the only primary is a late-night incident.

Question 17
Interview Advanced
Question

What does redis-check-aof --fix actually discard?

Answer:

rdbchecksum and AOF load errors can make Redis refuse to start on a truncated AOF unless you redis-check-aof --fix, which discards a tail. Know that --fix is data loss. Prefer keeping the last good RDB.

Question 18
Interview Advanced
Question

How is the replication backlog different from AOF?

Answer:

Replication backlog via repl-backlog-size is not AOF; it is a circular buffer for partial resync (PSYNC). Undersize it and replicas do full RDB resyncs after a blip. That full resync is a persistence-adjacent outage.

Question 19
Interview Advanced
Question

Do RedisJSON or RedisBloom survive a restart if you treat Redis as a cache-only box?

Answer:

Modules and AOF: some module writes must be AOF-aware or they will not survive restart. RedisJSON and RedisBloom need persistence enabled if you treat them as source of truth. A cache-only policy silently drops module data.

Question 20
Interview Advanced
Question

Can Redis give you Postgres-style point-in-time restore?

Answer:

Point-in-time restore in Redis is last RDB plus AOF up to crash, not WAL-level PITR like Postgres. If you need arbitrary-time restore, ship RDB snapshots to object storage on a schedule. Redis alone is not a backup product.

Practice with AI mock interviews

Run Redis mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required