redis内存碎片(批量删除大量key会导致大量碎片)
全redis整理会导致30左右CPU增高
根据
info memory
mem_fragmentation_ratio(小于1代表操作系统分配内存小于实际使用内存出现 使用了swap。大于1代表有碎片存在)
碎片整理开启方式
配置文件里面 activedefrag yes
config set activedefrag yes
active-defrag-ignore-bytes 100 碎片空间小于100mb不启动碎片整理
active-defrag-threshold-lower 10碎片率小于10%不启动整理 建议 20
active-defrag-cycle-min 1 最小1%CPU用于清理碎片
active-defrag-cycle-max 25 最多25%CPU用于碎片清理 建议10以内
active-defrag-max-scan-fields 1000 整理碎片需要遍历,如果遇到元素超过1000(大key)的就放到单独的处理