redis mem_fragmentation_ratio 过大

最近有个业务bug,导致redis存储了很多没用的key,删除后发现mem_fragmentation_ratio过大:

127.0.0.1:6379> info memory
# Memory
used_memory:104430120
used_memory_human:99.59M
used_memory_rss:2633490432
used_memory_peak:2709867544
used_memory_peak_human:2.52G
used_memory_lua:46080
mem_fragmentation_ratio:25.22
mem_allocator:jemalloc-3.6.0
127.0.0.1:6379> 

used_memory_human:99.59M 很小,表示redis实际使用的内存很小,used_memory_rss:2633490432而操作系统分配给redis的内存很大,说明redis并没用把内存返还给操作系统。看来需要重启redis。

执行如下命令:

127.0.0.1:6379> shutdown save
(1.50s)
not connected> 

127.0.0.1:6379> info memory
# Memory
used_memory:95559360
used_memory_human:91.13M
used_memory_rss:104247296
used_memory_peak:95644424
used_memory_peak_human:91.21M
used_memory_lua:33792
mem_fragmentation_ratio:1.09
mem_allocator:jemalloc-3.6.0

你可能感兴趣的:(redis,redis)