0
0
Redisquery~10 mins

Memory usage analysis (INFO memory) in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Memory usage analysis (INFO memory)
Run INFO memory command
Receive memory stats
Parse key metrics
Analyze memory usage
Identify bottlenecks or inefficiencies
Optimize or monitor accordingly
The flow shows running the INFO memory command, getting memory stats, parsing key metrics, analyzing usage, and then optimizing or monitoring.
Execution Sample
Redis
127.0.0.1:6379> INFO memory
# Memory
used_memory:1024000
used_memory_rss:2048000
used_memory_peak:3072000
mem_fragmentation_ratio:2.0
mem_allocator:jemalloc-5.1.0
This command shows Redis memory usage details like used memory, peak memory, and fragmentation ratio.
Execution Table
StepActionMetric ExtractedValueMeaning
1Run INFO memory commandused_memory1024000Bytes of memory Redis is using
2Parse outputused_memory_rss2048000Memory allocated by OS (resident set size)
3Parse outputused_memory_peak3072000Highest memory used since start
4Parse outputmem_fragmentation_ratio2.0Memory overhead due to fragmentation
5Parse outputmem_allocatorjemalloc-5.1.0Memory allocator used by Redis
6Analyze fragmentationmem_fragmentation_ratio2.0High fragmentation means inefficient memory use
7DecisionOptimize or monitor-If fragmentation >1.5, consider optimization
8Exit--Analysis complete
💡 All key memory metrics extracted and analyzed for optimization decisions
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
used_memory010240001024000102400010240001024000
used_memory_rss002048000204800020480002048000
used_memory_peak000307200030720003072000
mem_fragmentation_ratio00002.02.0
mem_allocatorunknownunknownunknownunknownjemalloc-5.1.0jemalloc-5.1.0
Key Moments - 3 Insights
Why is used_memory_rss larger than used_memory?
used_memory_rss includes all memory allocated by the OS, including fragmentation and overhead, while used_memory is the actual memory Redis is using for data. See execution_table rows 1 and 2.
What does a mem_fragmentation_ratio of 2.0 mean?
It means Redis is using twice as much memory as the data size due to fragmentation or allocator overhead. High fragmentation can cause inefficiency. See execution_table row 4 and 6.
Why do we check used_memory_peak?
used_memory_peak shows the highest memory Redis has used since start, helping to understand memory spikes. See execution_table row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what is the mem_fragmentation_ratio value?
A1.0
B2.0
C0.5
D3.0
💡 Hint
Check the 'Metric Extracted' and 'Value' columns at step 4 in execution_table.
At which step do we identify that memory fragmentation might be a problem?
AStep 6
BStep 5
CStep 2
DStep 7
💡 Hint
Look for the step where mem_fragmentation_ratio is analyzed in execution_table.
If used_memory_peak was lower than used_memory, what would that indicate?
AMemory usage is currently at its highest
BMemory fragmentation is low
CMemory usage has never been that high before
DRedis is using a different allocator
💡 Hint
Compare used_memory and used_memory_peak values in variable_tracker.
Concept Snapshot
Run the Redis command INFO memory to get memory stats.
Key metrics: used_memory, used_memory_rss, used_memory_peak, mem_fragmentation_ratio.
used_memory = actual data memory used.
used_memory_rss = OS memory allocated (includes fragmentation).
mem_fragmentation_ratio >1 means memory overhead.
Use these to monitor and optimize Redis memory usage.
Full Transcript
This visual execution shows how to analyze Redis memory usage using the INFO memory command. First, the command is run to get memory statistics. Then key metrics like used_memory, used_memory_rss, used_memory_peak, and mem_fragmentation_ratio are extracted. The used_memory shows actual memory used by Redis data. The used_memory_rss shows memory allocated by the operating system, which is usually larger due to fragmentation and overhead. The used_memory_peak shows the highest memory used since Redis started, helping identify memory spikes. The mem_fragmentation_ratio indicates how much extra memory is used due to fragmentation; a value of 2.0 means twice the memory is used compared to actual data size, which is inefficient. By analyzing these values, one can decide if optimization or monitoring is needed. This step-by-step trace helps beginners understand how Redis memory metrics relate and how to interpret them for better memory management.