I build CacheDeck, an iPhone app for checking production Redis during an incident. You won't need it here: everything below runs in Docker with redis-cli.
I started a fresh Redis container, wrote nothing to it, and read INFO memory:
used_memory:1421152 used_memory_rss:24793088 mem_fragmentation_ratio:17.94 If your dashboard alerts on that field, it would page you for a server that holds no keys. Later the same container held 200,000 keys and reported 4.38, with 420 MB of RSS above the data. INFO prints both readings in the same field, and you can get memory back only in the second case.
My setup: the redis:8 image (Redis 8.10.3, jemalloc 5.3.0) in Docker on a Mac, run on 18 November 2026.
Four states of one server
I took four snapshots: empty, after writing 1,000,000 keys with 400-byte values, after deleting four keys out of every five, and 30 seconds after turning on active defragmentation.
INFO memory | empty | 1M keys | 80% deleted | activedefrag, 30 s |
|---|---|---|---|---|
used_memory | 1.4 MB | 495.6 MB | 107.1 MB | 107.1 MB |
used_memory_rss | 24.8 MB | 526.6 MB | 527.0 MB | 176.2 MB |
allocator_frag_ratio | 1.00 | 1.00 | 4.10 | 1.39 |
allocator_rss_ratio | 1.91 | 1.03 | 1.03 | 1.06 |
rss_overhead_ratio | 2.69 | 1.03 | 1.03 | 1.10 |
mem_fragmentation_ratio | 17.94 | 1.06 | 4.38 | 1.65 |
MB here means a million bytes. I ran the sequence three times: the empty server read 17.44 to 17.94, the deleted state 4.38 to 4.92, and defrag ended at 1.65 each time. The tables show one run. The commands:
docker run -d --name fraglab redis:8 docker exec fraglab redis-cli INFO memory | grep -E '^(used_memory|used_memory_rss|.*_ratio):' # 1,000,000 keys with 400-byte values docker exec fraglab sh -c 'awk "BEGIN{v=sprintf(\"%400s\",\"\"); gsub(/ /,\"x\",v); for(i=0;i<1000000;i++) printf \"SET k:%d %s\n\", i, v}" | redis-cli --pipe' # delete 4 of every 5 keys docker exec fraglab sh -c 'awk "BEGIN{for(i=0;i<1000000;i++) if(i%5!=0) printf \"DEL k:%d\n\", i}" | redis-cli --pipe' The headline ratio divides the whole process by the data
mem_fragmentation_ratio is used_memory_rss divided by used_memory. The INFO docs define used_memory as the bytes Redis allocated, and used_memory_rss as the bytes the operating system sees for the whole process. RSS includes the binary, the allocator's own bookkeeping and the pages jemalloc keeps after a free. On an empty server that baseline is 24.8 MB against 1.4 MB of data, which gives you 17.94.
Redis splits that division into the three ratios above it:
-
allocator_frag_ratiodivides the allocator's active pages by the bytes Redis asked for. The docs call it "the true (external) fragmentation metric (notmem_fragmentation_ratio)". -
allocator_rss_ratiocovers resident pages the allocator "can and probably will soon release back to the OS". -
rss_overhead_ratiocovers RSS outside the allocator: code, shared libraries, stack.
On the empty server allocator_frag_ratio reads 1.00, so the allocator has no holes. All of the 17.94 comes from the two overhead ratios. MEMORY DOCTOR on that container printed this and no diagnosis:
this instance is empty or is using very little memory, my issues detector can't be used in these conditions.
Deleting 80% of the keys left the RSS where it was
After the deletes, used_memory fell from 495.6 MB to 107.1 MB, and RSS stayed at 527.0 MB. allocator_frag_ratio jumped to 4.10. My reading: every fifth key survived, so most allocator pages still hold a live value, and jemalloc can't release a page that has one.
MEMORY DOCTOR now listed three issues, and its first suggestion was MEMORY PURGE. I ran it. RSS read 526,958,592 bytes before the purge and the same number after. MEMORY PURGE asks jemalloc to return dirty pages, and these pages still held data.
Watch for this state if you rely on maxmemory. Eviction compares maxmemory with used_memory, so Redis counted 107 MB while the kernel charged the container for 527 MB.
activedefrag gave back 351 MB in 30 seconds
The redis:8 image ships with activedefrag no. I turned it on:
docker exec fraglab redis-cli CONFIG SET activedefrag yes Redis started moving live values into fewer pages, so jemalloc could free the emptied ones:
after CONFIG SET activedefrag yes | RSS | mem_fragmentation_ratio |
|---|---|---|
| 0 s | 527.0 MB | 4.38 |
| 10 s | 290.5 MB | 2.71 |
| 20 s | 179.0 MB | 1.67 |
| 30 s | 176.2 MB | 1.65 |
| 60 s | 176.2 MB | 1.65 |
It stopped at 1.65 with 41.5 MB of holes left (allocator_frag_bytes:41532096). The default active-defrag-ignore-bytes is 104857600, and redis.conf describes it as the minimum waste before defrag starts. Below 100 MB of holes, Redis leaves them alone, so a dashboard threshold of 1.5 stays red after defrag has done its job on this dataset.
Defrag costs CPU. The defaults let it take from 1% (active-defrag-cycle-min) to 25% (active-defrag-cycle-max), so check yours before you turn it on at peak traffic.
What each reading tells you
| You see | What it means | Check next |
|---|---|---|
High ratio, used_memory of a few MB | process baseline divided by almost nothing | nothing; MEMORY DOCTOR says the same |
allocator_frag_ratio well above 1, used_memory far below used_memory_peak | holes left by a mass delete or expiry wave | activedefrag, or a replica restart and failover |
High ratio, allocator_frag_ratio near 1.00, large used_memory | resident pages the allocator hasn't returned, or memory outside the allocator | allocator_rss_ratio, rss_overhead_ratio, MEMORY MALLOC-STATS |
| Ratio below 1.0 | per the docs, the OS swapped part of Redis out | swap usage on the host; I did not reproduce this one |
The slowlog has a similar trap: an empty log means no command crossed 10 ms, and your cache can feel slow below that line. I measured that one on the CacheDeck blog.
CacheDeck's free Incident view shows mem_fragmentation_ratio as one of six tiles from INFO, and colors it only when used_memory is at least 100 MB, so the empty server above stays green at 17.94. The tile shows the combined ratio only. For the breakdown, run INFO memory or MEMORY DOCTOR in the Workbench, which takes read commands in the free tier. CONFIG SET is a write: it needs Pro, and the app shows the target server and asks you to confirm before it sends the command. cachedeck.com
Run the grep line on your largest instance and tell me in the comments which of the three ratios is highest.
Redis is a registered trademark of Redis Ltd. CacheDeck is not affiliated with, endorsed by, or sponsored by Redis Ltd.

