Memory Purge

344 views
Skip to first unread message

Aneel Khan

unread,
Jan 25, 2021, 9:30:06 PM1/25/21
to Redis DB
Hi 

I am getting memory fragmentation alert and ran memory purge command but still getting the mem_fragmentation_ratio alert. Any recommendations?

localhost:36000> info memory
# Memory
used_memory:79447392
used_memory_human:75.77M
used_memory_rss:324177920
used_memory_rss_human:309.16M
used_memory_peak:26014302824
used_memory_peak_human:24.23G
used_memory_peak_perc:0.31%
used_memory_overhead:24625848
used_memory_startup:4445376
used_memory_dataset:54821544
used_memory_dataset_perc:73.09%
allocator_allocated:79686840
allocator_active:87453696
allocator_resident:335425536
total_system_memory:202722881536
total_system_memory_human:188.80G
used_memory_lua:39936
used_memory_lua_human:39.00K
used_memory_scripts:360
used_memory_scripts_human:360B
number_of_cached_scripts:1
maxmemory:53687091200
maxmemory_human:50.00G
maxmemory_policy:noeviction
allocator_frag_ratio:1.10
allocator_frag_bytes:7766856
allocator_rss_ratio:3.84
allocator_rss_bytes:247971840
rss_overhead_ratio:0.97
rss_overhead_bytes:-11247616
mem_fragmentation_ratio:4.08
mem_fragmentation_bytes:244689640
mem_not_counted_for_evict:348
mem_replication_backlog:1048576
mem_clients_slaves:49694
mem_clients_normal:19001414
mem_aof_buffer:348
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0

localhost:36000> memory purge
OK

localhost:36000> info memory
# Memory
used_memory:79284104
used_memory_human:75.61M
used_memory_rss:324222976
used_memory_rss_human:309.20M
used_memory_peak:26014302824
used_memory_peak_human:24.23G
used_memory_peak_perc:0.30%
used_memory_overhead:24494760
used_memory_startup:4445376
used_memory_dataset:54789344
used_memory_dataset_perc:73.21%
allocator_allocated:79463464
allocator_active:87207936
allocator_resident:335405056
total_system_memory:202722881536
total_system_memory_human:188.80G
used_memory_lua:39936
used_memory_lua_human:39.00K
used_memory_scripts:360
used_memory_scripts_human:360B
number_of_cached_scripts:1
maxmemory:53687091200
maxmemory_human:50.00G
maxmemory_policy:noeviction
allocator_frag_ratio:1.10
allocator_frag_bytes:7744472
allocator_rss_ratio:3.85
allocator_rss_bytes:248197120
rss_overhead_ratio:0.97
rss_overhead_bytes:-11182080
mem_fragmentation_ratio:4.09
mem_fragmentation_bytes:244979872
mem_not_counted_for_evict:348
mem_replication_backlog:1048576
mem_clients_slaves:16922
mem_clients_normal:18903098
mem_aof_buffer:348
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0

Thank you

Greg Andrews

unread,
Jan 26, 2021, 1:48:23 PM1/26/21
to Redis DB
At the time you sent the purge command, your Redis-server process was using 75.77 megabytes of RAM.  After the purge command, your Redis-server process was using 75.61 megabytes.  The purge released 0.16 megabytes (160 kilobytes) of memory.  The reduction is about one quarter of one percent of the total.
I wouldn't expect the fragmentation ratio to change much with such a small change in memory consumption.

And your Redis-server process is using a pretty small amount of RAM in both of the INFO commands you posted.  When the RAM consumption is small, the fragmentation ratio statistic is not very useful. Have a look at a previous discussion thread from several years ago about the display of fragmentation ratio when memory usage is low:  https://groups.google.com/g/redis-db/c/9iOtJXNXar8/m/geJUZU5vDwAJ

I also note that your Redis-server reports the current RAM usage is less than 100 megabytes (quite small), but at some point in the past it was more than 24 gigabytes (quite large).  There was a previous discussion thread about the fragmentation ratio stat in this same situation:  https://groups.google.com/g/redis-db/c/9iOtJXNXar8/m/geJUZU5vDwAJ
The summary is:  The Redis documentation says the fragmentation ratio can display a misleading number when the Redis server process is now using very little RAM after using a lot of RAM in the past.

I'm not a Redis Labs employee, I'm just a member of this discussion group who has been using Redis in various ways since 2011.  It's my opinion (mentioned in the thread in my first link above) that the fragmentation ratio is not a very useful statistic.  It can be somewhat useful when your Redis-server process is consuming lots of RAM, but the items that are much more useful are used_memory,  used_memory_rss, and total_system_memory.  These can tell you how close your process is to consuming all the server's memory (potentially triggering a crash), which is the most important memory statistic.  Some of the other items in the INFO output can tell you which parts of Redis are using the memory, and this can be helpful to know if you need to restart the process to release memory back to the rest of the server, but this is secondary to the warning about an impending overflow of memory consumption.

Ankit Gupta

unread,
Mar 30, 2021, 4:45:43 AM3/30/21
to Redis DB
Hi,

You can try enabling active defragmentation.  (config set activedefrag yes)

张飞虎

unread,
Apr 28, 2023, 10:25:02 AM4/28/23
to Redis DB
Has the problem finally been solved?

张飞虎

unread,
Apr 28, 2023, 10:28:19 AM4/28/23
to redi...@googlegroups.com
thank you

张飞虎 <cheun...@gmail.com>于2023年4月28日 周五22:25写道:
--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/Xla2OQ0DxyI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/80b4fc38-87c8-4edd-afd6-8c9b0bedbb57n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages