Scrivio Interview library
ConceptFoundations6 min read · updated 13 November 2026

INFO memory is the first place to look when a Redis instance seems to use more RAM than its data should need.

Explain used_memory, used_memory_rss, used_memory_peak, mem_fragmentation_ratio and maxmemory, and what a fragmentation ratio of 1.6 or of 0.7 tells you.

used_memory is what the allocator has handed to Redis, used_memory_rss is what the operating system says the process holds in RAM, used_memory_peak is the highest used_memory so far, mem_fragmentation_ratio is roughly rss divided by used_memory, and maxmemory is the cap on used_memory that triggers eviction or OOM errors. A ratio of 1.6 means about 60 percent extra RAM is held in partly empty pages or not yet returned after an earlier peak, while 0.7 means part of Redis has been swapped out, which is a serious latency problem.

Why this question is asked

When a Redis host runs short of memory, INFO memory is the first thing to read, and it is also easy to misread: two fields that look similar, used_memory and used_memory_rss, can differ by gigabytes, and a ratio near 1 is not always healthy. Interviewers ask about these fields because reading them correctly decides whether we add RAM, defragment, tune eviction or chase a swap problem. In this answer, we will recap how Redis gets memory, explain each field, read the two ratios from the question, and look at the tools that break the numbers down further.

1A Quick Recap: Allocator and Operating System

Redis does not ask the operating system for memory directly every time it creates a key. It asks an allocator, jemalloc by default on Linux builds, which gets large regions from the operating system and carves them into small blocks of fixed size classes, such as 16, 32, 48 or 64 bytes.

So there are two views of memory. The allocator's view is the sum of blocks that Redis currently uses. The operating system's view is the pages that are mapped and resident for the process, which includes blocks Redis has freed but jemalloc has not yet returned, and space wasted inside partly used pages. Almost every confusing memory number comes from the gap between these two views.

Step throughTwo views of the same memory
  1. used_memoryblocks the allocator has handed to Redis: data, buffers, structures
  2. Allocator overheadfree space inside pages, size-class rounding, retained pages
  3. used_memory_rsspages the OS counts as resident for the process
  4. Swappages pushed out to disk; not counted in RSS

4 layers, from the top down. Step through them one at a time.

RSS above used_memory is fragmentation and retention; RSS below it means swapping.

2The Fields One by One

used_memory is the total the allocator has given Redis for data, keys, client buffers, replication buffers and internal structures. It is the number Redis controls and the one maxmemory compares against. used_memory_human shows it in a readable form, and used_memory_dataset estimates the share that is actual data.

used_memory_rss is resident set size as reported by the operating system: the RAM really occupied by the process. used_memory_peak is the high-water mark of used_memory since start or since MEMORY RESET STATS; comparing it with today's used_memory tells us whether the instance was once much bigger.

maxmemory is the limit we configure for used_memory, not for RSS. When used_memory goes above it, maxmemory-policy decides what happens: an eviction policy such as allkeys-lru removes keys, and noeviction makes write commands fail with an OOM error. Replication and AOF buffers are excluded from this comparison, shown as mem_not_counted_for_evict, so that Redis does not evict data to make room for the very buffers that replicate it.

Text
INFO memory
used_memory:6442450944 -- 6.0 GB handed out by jemalloc
used_memory_rss:10307921510 -- 9.6 GB resident
used_memory_peak:10200547328 -- 9.5 GB was the high-water mark
mem_fragmentation_ratio:1.60
maxmemory:8589934592 -- 8 GB cap on used_memory
maxmemory_policy:allkeys-lru
mem_not_counted_for_evict:2097152 -- 2 MB of AOF and replication buffers

3Reading a Ratio of 1.6

mem_fragmentation_ratio is roughly used_memory_rss divided by used_memory. Between about 1.0 and 1.3 is normal; some overhead is unavoidable. At 1.6, as in the sample above, the process holds 60 percent more RAM than it uses.

There are two usual causes, and the peak field tells them apart. If used_memory_peak is much higher than used_memory, the instance grew earlier and then shrank, and jemalloc kept pages that are only partly used, because a page goes back to the operating system only when it is entirely free. If the peak is close to today's usage, the fragmentation comes from a workload that creates and deletes values of many different sizes. Either way, active defragmentation (activedefrag yes) can compact it, and a restart or failover to a freshly synced replica resets it.

4Reading a Ratio of 0.7

A ratio below 1 means RSS is smaller than what Redis uses, which is only possible if some of Redis's pages are not in RAM. They have been swapped out to disk. This is far more serious than fragmentation: an access to a swapped page takes milliseconds instead of nanoseconds, and because the main thread does every command, one page fault stalls every client.

The fix is to remove the memory pressure: lower maxmemory, move other processes off the host, or add RAM. Redis hosts should run with swap disabled or very low swappiness, so the problem shows up as a clear failure rather than as unexplained latency. We can confirm swapping with the swap counters for the process in /proc or with LATENCY DOCTOR.

5Tools That Break the Numbers Down

MEMORY STATS returns a detailed breakdown: dataset, overhead of keys, client buffers, replication backlog, Lua caches, and allocator fields. INFO memory also has allocator_frag_ratio, which isolates fragmentation inside jemalloc, and rss_overhead_ratio, which covers RSS that is not the allocator's at all, such as the binary and shared libraries. MEMORY DOCTOR reads these and prints advice in plain English.

One warning: on an almost empty instance the ratio is meaningless. With 3 MB of data and 10 MB of RSS for code and libraries, the ratio is above 3, and nothing is wrong. MEMORY DOCTOR says so itself, and we should only worry about the ratio once used_memory is at least a few hundred megabytes.

6Follow-up questions

Why can RSS stay high after the dataset shrinks?

Because jemalloc returns a page to the operating system only when every block in it is free. Deleting keys spread across memory leaves most pages partly used, so they stay resident even though used_memory fell. jemalloc also keeps some free pages around for reuse. MEMORY PURGE can release some fully free pages, active defragmentation moves data to empty out pages, and a failover to a fresh replica rebuilds memory compactly.

Should maxmemory be set close to the host's RAM?

No. maxmemory limits used_memory, while the host must also hold fragmentation, buffers not counted for eviction, copy-on-write during forks and the operating system itself. With persistence, maxmemory is usually set to around 60 to 75 percent of RAM.

Which field do I alert on?

On used_memory against maxmemory for eviction risk, on RSS against host RAM for out-of-memory kills, on a fragmentation ratio below 1 for swapping, and on allocator_frag_ratio above about 1.5 on large instances for defragmentation.

7Conclusion

In this answer, we saw that used_memory is the allocator's view of what Redis uses, used_memory_rss is the operating system's view of resident RAM, and used_memory_peak shows how large the instance once was. Their ratio of about 1.0 to 1.3 is normal, 1.6 points to fragmentation or pages kept after an earlier peak, and below 1 means swapping, which must be fixed at once. maxmemory caps used_memory, not RSS, and excludes replication and AOF buffers, and MEMORY STATS, MEMORY DOCTOR and the allocator ratios separate the causes.

What to say in the interviewAbout 70 seconds aloud

Open with

used_memory is what the allocator, jemalloc by default on Linux, has handed to Redis for data, buffers and internal structures. used_memory_rss is what the operating system reports as resident for the process, and used_memory_peak is the high-water mark of used_memory. mem_fragmentation_ratio is roughly RSS over used_memory.

Then, if they want more

Around 1.0 to 1.3 is normal. At 1.6, there is 60 percent extra RAM held in partly empty allocator pages, or the instance was bigger earlier and has not returned pages, which I check against used_memory_peak; active defrag or a failover to a fresh replica fixes that.

Below 1, say 0.7, part of Redis is swapped out, and since the main thread serves everything, every page fault stalls all clients, so I relieve the memory pressure and keep swap off Redis hosts. maxmemory caps used_memory, not RSS; when it is reached, maxmemory-policy either evicts or makes writes fail with OOM, and replication and AOF buffers are excluded, shown as mem_not_counted_for_evict.

For detail I use MEMORY STATS, MEMORY DOCTOR, allocator_frag_ratio and rss_overhead_ratio, and I ignore the ratio on an almost empty instance.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain used_memory, used_memory_rss, used_memory_peak, mem_fragmentation_ratio and...": https://scrivio-interview-library.netlify.app/databases/redis-internals/b9cc1f53f6/