Difficulty: Advanced
Did Redis ever support keeping part of its dataset on disk when it did not fit in RAM? What happened to that feature, and what are the options today?
Yes. Redis 2.0 shipped an optional Virtual Memory (VM) feature that moved rarely used values to a swap file on disk and kept only keys and hot values in RAM. It was deprecated in Redis 2.4 and removed in 2.6, because it made latency unpredictable and complicated the code, while RAM was getting cheaper. Since then, open-source Redis requires the whole dataset to fit in memory; disk is used only for persistence.
vm-enabled, vm-max-memory and vm-swap-file.An experimental successor called diskstore was also abandoned for similar reasons.
It is a common confusion in interviews. RDB snapshots and the AOF write Redis data to disk, but only to rebuild memory after a restart. Reads are always served from RAM. If the dataset grows beyond RAM, Redis either evicts keys (with a maxmemory-policy other than noeviction) or rejects writes with an OOM error.
If maxmemory is not set and the machine runs low on RAM, Linux may swap Redis's own memory pages to disk. Every access to a swapped page then causes a disk read on the single main thread, and latency collapses for every client. Signs include mem_fragmentation_ratio below 1.0 and high swap usage in /proc/<pid>/smaps. Set maxmemory with headroom and monitor RSS.
| Approach | Notes |
|---|---|
| Shard with Redis Cluster | Spread data across nodes so each fits in RAM |
| Evict cold data | Use Redis as a cache with LRU/LFU and keep the source of truth in a database |
| Commercial tiering | Redis Enterprise / Redis Cloud offer RAM plus flash tiering (marketed as Auto Tiering, now Redis Flex) |
| Disk-based Redis-compatible stores | Apache Kvrocks (RocksDB backed) speaks the Redis protocol with data on SSD |
Each option trades something: cost, latency on cold reads, or full command compatibility.
| Redis 2.0 with VM | Redis today | |
|---|---|---|
| Where reads are served | RAM or swap file | RAM only |
| Dataset larger than RAM | Cold values swapped out | Evict, reject writes, or shard |
| Latency | Unpredictable on cold values | Consistently low |
| Role of disk | Storage and persistence | Persistence only (RDB, AOF) |
Redis Virtual Memory, In-memory design, OS swap, Tiered storage, Persistence vs storage