Redis Explained, Memory Metrics and Performance Insights

Posted by Peter G Kellner on September 28, 2023 · 3 mins read
Ad: Learn Modern JavaScript on YouTube (3 Hours & Free)

Redis Explained: Memory Metrics and Performance Insights

Redis is an unmistakable presence in the world of databases, particularly for its blazing speed. But what’s the secret sauce behind its quicksilver performance? Today, we’re going to shed some light on Redis’s in-memory operations, determine how to gauge its memory consumption, and decipher some of the enigmatic metrics it yields.

The Phenomenon of In-Memory Operations

The nucleus of Redis’s speed is its in-memory operation. While many databases frequently make pitstops at the disk, which is inherently slower, Redis zips straight through operations in RAM, the equivalent of reading an open book versus searching for one in a vast library. But like any intricate machinery, to truly appreciate its prowess, we must peer under the hood.

Querying Redis: Memory Metrics Unveiled

If your hands are on the levers of a Redis instance and you’re itching to know its memory footprint, the magic spell is INFO MEMORY.

Execute this:

$ redis-cli INFO MEMORY

And voilà, you’re presented with a cascade of metrics. Let’s dissect some of the crucial ones:

  1. used_memory: This is the raw count of bytes Redis has allocated. It’s the direct measurement of the memory that Redis acknowledges it’s using.

  2. used_memory_human: If you’re averse to long, winding numbers, this is your ally. It morphs the raw byte count from used_memory into more palatable figures, such as “3.42M” or “1.28G”.

  3. used_memory_rss: Think of this as the memory metric with an external perspective. While used_memory tells you about Redis’s own estimation, used_memory_rss shows how much memory the operating system thinks Redis is hogging. Disparities between the two can emerge from phenomena like memory fragmentation.

  4. mem_fragmentation_ratio: If this reads above 1.0, it implies that used_memory_rss trumps used_memory, hinting at potential memory fragmentation.

Memory vs. Disk: The Redis Ballet

It’s a common quandary: “If Redis is chiefly in-memory, why the disk usage?” The answer is twofold: persistence and recovery. While the core of Redis sings in memory, it doesn’t neglect the safety dance with the disk. Through mechanisms like RDB snapshots and AOF logs, Redis ensures data isn’t lost in unforeseen mishaps. Thus, while its operations are lightning-fast thanks to memory, the data persists on disk for safety.


Redis, with its in-memory operations, is like a masterful ballet dancer, swift and graceful. But behind the scenes, it’s a blend of intricate metrics and processes. By diving deep into its memory metrics, not only do we appreciate its performance but also ensure it operates at peak efficiency. So the next time Redis leaves you in awe, remember, it’s not just magic; it’s meticulous engineering.