Redis4.0如何自動清理記憶體碎片

chenfeng發表於2018-05-24
Redis4.0版本之後支援在執行期進行自動記憶體碎片清理 
透過設定config set activedefrag yes

# redis-cli info memory
# Memory
used_memory:94924567648
used_memory_human:88.41G
used_memory_rss:122715869184
used_memory_rss_human:114.29G
used_memory_peak:138010337568
used_memory_peak_human:128.53G
used_memory_peak_perc:68.78%
used_memory_overhead:21483503188
used_memory_startup:6123112
used_memory_dataset:73441064460
used_memory_dataset_perc:77.37%
total_system_memory:202987839488
total_system_memory_human:189.05G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:128849018880
maxmemory_human:120.00G
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.29
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0

retio的值為1.29,說明有很多記憶體碎片

執行以下命令開始整理:
[root@redis-cache-225 conf]# redis-cli -p 6379 config set activedefrag yes
OK

發現ratio的值越來越小,說明自動清理功能生效:

# redis-cli info memory | grep ratio
mem_fragmentation_ratio:1.16


# redis-cli info memory | grep ratio
mem_fragmentation_ratio:1.12

# redis-cli info memory | grep ratio
mem_fragmentation_ratio:1.09

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2155031/,如需轉載,請註明出處,否則將追究法律責任。

相關文章