Redis & Caching (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Redis Persistence: RDB vs AOF vs Hybrid.
senior LevelredisAdvanced Internals
In Simple Words:
- RDB (Snapshotting): Point-in-time binary snapshot of memory dumped to disk via
BGSAVE(fork()copy-on-write). Compact file, fast restart, but risk of losing minutes of data between snapshots. - AOF (Append Only File): Logs every write command sequentially (
appendfsync everysec). Highly durable (at most 1 second of data loss), but larger file sizes and slower restart. - Hybrid Persistence (Default in Redis 5+): RDB snapshot preamble + AOF incremental log tail for fast restarts and high durability.