Redis Persistence Interview Questions

Master Redis Persistence with interview-focused questions covering RDB, AOF, Hybrid Persistence, Snapshots, fsync policies, Recovery, Durability, Backup, Disaster Recovery, and enterprise production best practices.

Introduction

Redis is primarily an in-memory database, meaning data is stored in RAM.

Although memory provides extremely fast access, it has one major problem:

Memory contents are lost if the server crashes or restarts (unless persistence is enabled).

Redis Persistence solves this problem by saving in-memory data to disk.

Persistence provides

  • Data Durability
  • Crash Recovery
  • Backup
  • Disaster Recovery
  • Replication Initialization

Redis supports three persistence modes:

  • RDB (Redis Database Backup)
  • AOF (Append Only File)
  • Hybrid Persistence (RDB + AOF)

Redis Persistence Architecture

flowchart LR

Application --> RedisMemory["Redis Memory"]

RedisMemory["Redis Memory"] --> RdbSnapshot["RDB Snapshot"]

RedisMemory["Redis Memory"] --> AofLog["AOF Log"]

RdbSnapshot["RDB Snapshot"] --> Disk

AofLog["AOF Log"] --> Disk

1. What is Redis Persistence?

Answer

Redis Persistence is the mechanism used to save in-memory data onto disk.

Without persistence

Redis Restart

↓

All Data Lost

With persistence

Redis Restart

↓

Load Data

↓

Continue Serving

2. Why is Persistence required?

Persistence provides

  • Crash Recovery
  • Backup
  • Disaster Recovery
  • Data Durability
  • Faster Replica Synchronization

3. What persistence options are available?

Redis supports

  • RDB
  • AOF
  • Hybrid Persistence

Persistence Types

flowchart TD

Redis --> RDB

Redis --> AOF

Redis --> Hybrid

4. What is RDB?

RDB

(Redis Database Backup)

creates a point-in-time snapshot of the entire Redis dataset.

Snapshots are stored on disk.


RDB Workflow

flowchart LR

RedisMemory["Redis Memory"] --> SnapshotDumprdbDisk["Snapshot --> dump.rdb --> Disk"]

5. How does RDB work?

Redis performs

Fork

↓

Child Process

↓

Writes Snapshot

↓

Parent Continues Serving Requests

6. Advantages of RDB

  • Compact File
  • Fast Startup
  • Faster Backup
  • Lower Disk Usage
  • Suitable for Disaster Recovery

7. Disadvantages of RDB

  • Possible Data Loss Between Snapshots
  • Less Durable
  • Snapshot Creation Consumes Resources

8. What is AOF?

AOF

(Append Only File)

records every write command executed by Redis.

Instead of saving snapshots,

Redis logs commands.

Example

SET user venu

HSET customer name John

DEL session1

AOF Workflow

flowchart LR

WriteCommand["Write Command"] --> AppendLogAppendonlyaofDisk["Append Log --> appendonly.aof --> Disk"]

9. Advantages of AOF

  • Better Durability
  • Minimal Data Loss
  • Human Readable
  • Safer Recovery

10. Disadvantages of AOF

  • Larger File Size
  • Slower Recovery
  • More Disk Writes

11. What is Hybrid Persistence?

Hybrid Persistence combines

  • RDB Snapshot
  • AOF Commands

The beginning of the file contains an RDB snapshot followed by incremental AOF changes.

Introduced in Redis 4.


Hybrid Persistence

flowchart LR

RdbSnapshot["RDB Snapshot"] --> AofCommandsSinglepersistencefilesinglePersistence["AOF Commands --> SinglePersistenceFile["Single Persistence File"]"]

12. Why use Hybrid Persistence?

Benefits

  • Fast Startup
  • Better Durability
  • Smaller File
  • Faster Recovery

Recommended for most production deployments.


13. What is the dump.rdb file?

The default RDB snapshot file.

Usually located in the Redis working directory.


14. What is appendonly.aof?

The AOF persistence file.

Contains all write commands.


15. What is fsync?

fsync forces operating system buffers to be written to disk.

Redis supports three AOF synchronization policies.


16. What are AOF fsync policies?

always

Every Write

↓

Disk

Safest

Slowest


everysec

Every Second

↓

Disk

Recommended for production.


no

Operating System decides

when to flush.

Fastest

Least Durable


fsync Comparison

Policy Performance Durability
always Slowest Highest
everysec Balanced High
no Fastest Lowest

17. What is AOF Rewrite?

Over time,

AOF files become very large.

Redis periodically rewrites the AOF into a compact version that represents the current dataset instead of replaying every historical command.

Benefits

  • Smaller File
  • Faster Startup
  • Better Performance

AOF Rewrite

flowchart LR

LargeAof["Large AOF"] --> RewriteCompactaofcompactAof["Rewrite --> CompactAof["Compact AOF"]"]

18. Does Redis block clients during RDB?

No.

Redis uses

Fork

↓

Child Process

↓

Snapshot

The parent process continues serving client requests.


19. Can RDB and AOF be enabled together?

Yes.

This is common in production.

Redis can create RDB snapshots while maintaining an AOF log.

Hybrid persistence further optimizes this approach.


20. Which persistence method loads first?

If both AOF and RDB are enabled,

Redis prefers the AOF file because it usually contains more recent data.


21. What happens during Redis restart?

Redis Starts

↓

Check AOF

↓

Load Data

↓

If No AOF

↓

Load RDB

Recovery Flow

flowchart LR

RedisRestart["Redis Restart"] --> AofMemory["AOF --> Memory"]

AOF

AOF -- Missing --> RDB --> Memory

22. What happens if Redis crashes?

Without persistence

Memory Lost

With persistence

Restart

↓

Reload Data

↓

Continue Serving

23. Banking Example

Customer Sessions

AOF Enabled

Unexpected Restart

Sessions Recovered


24. E-Commerce Example

Shopping Cart

Hybrid Persistence

Server Restart

Cart Restored


25. Gaming Example

Leaderboard

RDB Snapshot

Nightly Backup

Fast Recovery


26. Analytics Example

Real-Time Counters

AOF everysec

Minimal Data Loss


27. Disaster Recovery Example

Primary Redis Server

Hardware Failure

Restore RDB Backup

Replay AOF

Service Restored


28. Common Persistence Problems

  • Persistence Disabled
  • Large AOF Files
  • Slow Disk
  • Frequent Snapshot Creation
  • Insufficient Disk Space
  • Incorrect fsync Policy

29. RDB vs AOF

RDB AOF
Snapshot Command Log
Smaller Files Larger Files
Faster Startup Slower Startup
Less Durable More Durable
Better Backup Better Recovery

30. Which persistence option should be used?

Requirement Recommendation
Maximum Performance RDB
Maximum Durability AOF
Production Systems Hybrid Persistence
Backup Only RDB
Financial Systems AOF everysec or Hybrid

Redis Persistence Workflow

flowchart LR

Application --> RedisMemory["Redis Memory"]

RedisMemory["Redis Memory"] --> RdbSnapshot["RDB Snapshot"]

RedisMemory["Redis Memory"] --> AofLog["AOF Log"]

RdbSnapshot["RDB Snapshot"] --> Recovery

AofLog["AOF Log"] --> Recovery

Enterprise Best Practices

  • Enable persistence in production.
  • Prefer Hybrid Persistence for most workloads.
  • Use AOF everysec for balanced durability and performance.
  • Schedule periodic RDB snapshots.
  • Monitor AOF file size.
  • Enable automatic AOF rewrite.
  • Store backups on separate storage.
  • Test restore procedures regularly.
  • Monitor disk space continuously.
  • Include Redis backups in disaster recovery planning.

Quick Revision

Topic Key Point
Persistence Save Memory to Disk
RDB Snapshot Backup
AOF Command Log
Hybrid RDB + AOF
dump.rdb RDB File
appendonly.aof AOF File
fsync always Highest Durability
fsync everysec Production Recommendation
AOF Rewrite Compact Log
Recovery Load AOF or RDB

Interview Tips

Interviewers frequently ask

  • What is Redis Persistence?
  • Why is persistence required?
  • RDB vs AOF.
  • What is Hybrid Persistence?
  • What is AOF Rewrite?
  • Explain fsync policies.
  • Which persistence mode is best?
  • How does Redis recover after a restart?
  • Can RDB and AOF be enabled together?
  • What is your production recommendation?

A strong interview explanation is:

"Redis persistence ensures that in-memory data survives server restarts and crashes. RDB creates periodic snapshots, while AOF logs every write command for better durability. Hybrid Persistence combines the fast startup of RDB with the durability of AOF, making it the preferred choice for most enterprise deployments. AOF everysec provides an excellent balance between performance and data safety."


Summary

Redis Persistence enables an in-memory Redis instance to safely recover from failures by storing data on disk. Features such as RDB Snapshots, AOF Command Logging, Hybrid Persistence, AOF Rewrite, and configurable fsync policies provide different trade-offs between performance and durability.

Understanding persistence strategies, backup mechanisms, recovery workflows, and production best practices is essential for Backend Developers, Redis Engineers, DevOps Engineers, Database Engineers, and Solution Architects building reliable, enterprise-grade distributed systems.