NoSQL · Data models beyond tables

How does Redis persistence work?

MediumredispersistencedurabilityUpdated Oct 2026
Quiz this track

Short answer

Redis offers RDB snapshots, append-only file logging, or both. RDB is compact and fast to load but can lose recent writes; AOF with everysec fsync loses at most about a second.

Redis is an in-memory store, but it can persist to disk. RDB writes point-in-time snapshots, which are compact and quick to restore. AOF appends every write command and replays the log on startup. You can enable both.

text
save 900 1
save 300 10
save 60 10000

appendonly yes
appendfsync everysec
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
RDB snapshots are triggered by write counts, while AOF is flushed every second. The combination trades some durability for throughput.

Trade-offs

  • RDB: compact, fast restart, but loses everything since the last snapshot on a crash
  • AOF everysec: loses at most about one second, with modest fsync overhead
  • AOF always: strongest durability, but much slower because every write waits for disk
  • No persistence: fastest, but data disappears on restart and is only suitable for pure cache

AOF can grow large, so Redis rewrites it in the background into a compact form. AOF rewrite and RDB save both fork the process, which briefly costs memory and CPU. On a large dataset, copy-on-write memory during the fork can be significant.

Persistence is not the same as replication. A replica can still be lost with its primary, and an accidental FLUSHALL propagates. Keep external backups if Redis holds data you cannot rebuild.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What is the difference between RDB and AOF?
  2. 2What does appendfsync everysec guarantee?
  3. 3Why can a fork cause a memory spike?
  4. 4When is no persistence acceptable?

Say it in the interview

Redis can persist with RDB snapshots, AOF logs, or both. RDB is compact and fast to restore but can lose recent writes, while AOF with everysec fsync loses at most about a second. AOF always is more durable but much slower. I also account for the fork cost during snapshot and rewrite, because copy-on-write can spike memory. If Redis holds data I cannot rebuild, I still keep external backups, since persistence does not protect against a bad delete.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live NoSQL mock interview and get scored feedback on depth, clarity and confidence.