赞
踩
ads:
关注以下公众号查看更多文章
内存碎片让redis占用比自身实际数据存储更多的内存空间,需要整理redis数据以保证redis内存空间的最大化利用
在redis客户端执行以下命令查看redis内存使用情况
INFO memory
输出如下
- # Memory
- used_memory:1324112
- used_memory_human:1.26M
- used_memory_rss:7667712
- used_memory_rss_human:7.31M
- used_memory_peak:1441312
- used_memory_peak_human:1.37M
- used_memory_peak_perc:91.87%
- used_memory_overhead:1201392
- used_memory_startup:1177920
- used_memory_dataset:122720
- used_memory_dataset_perc:83.94%
- allocator_allocated:1306992
- allocator_active:7635968
- allocator_resident:7635968
- total_system_memory:17179869184
- total_system_memory_human:16.00G
- used_memory_lua:31744
- used_memory_vm_eval:31744
- used_memory_lua_human:31.00K
- used_memory_scripts_eval:0
- number_of_cached_scripts:0
- number_of_functions:0
- number_of_libraries:0
- used_memory_vm_functions:32768
- used_memory_vm_total:64512
- used_memory_vm_total_human:63.00K
- used_memory_functions:216
- used_memory_scripts:216
- used_memory_scripts_human:216B
- maxmemory:52428800
- maxmemory_human:50.00M
- maxmemory_policy:volatile-ttl
- allocator_frag_ratio:5.84
- allocator_frag_bytes:6328976
- allocator_rss_ratio:1.00
- allocator_rss_bytes:0
- rss_overhead_ratio:1.00
- rss_overhead_bytes:31744
- mem_fragmentation_ratio:5.87
- mem_fragmentation_bytes:6360720
- mem_not_counted_for_evict:0
- mem_replication_backlog:0
- mem_total_replication_buffers:0
- mem_clients_slaves:0
- mem_clients_normal:21456
- mem_cluster_links:0
- mem_aof_buffer:0
- mem_allocator:libc
- active_defrag_running:0
- lazyfree_pending_objects:0
- lazyfreed_objects:0

used_memory_human:1.26M 数据占用了1.26m
used_memory_rss_human:7.31M 数据实际占用内存 7.31M
allocator_frag_ratio:5.84 内存碎片化率 5.84
大于1.5,代码需要处理redis内存碎片问题
开启内存碎片整理
config set activedefrag yes
设置内存碎片化超过5m进行碎片整理
config set active-defrag-ignore-bytes 5242880
内存碎片占redis的总内存超过5%时开始碎片整理
config set active-defrag-threshold-lower 5
设置清理过程至少占用cpu 10%
config set active-defrag-cycle-min 10
设置清理过程最大占用cpu 20%
config set active-defrag-cycle-max 20
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。