一、现象
- 实例名:r-bp1cxxxxxxxxxd04(主从)
- 时间:2017-11-16 12:26~12:27
- 问题:一分钟内存上涨了2G,如下图所示:
- 键值规模:6000万左右
二、Redis内存分析
1.内存组成
上图中的内存统计的是Redis的info memory命令中的used_memory属性,例如:
redis> info memory
# Memory
used_memory:9195978072
used_memory_human:8.56G
used_memory_rss:9358786560
used_memory_peak:10190212744
used_memory_peak_human:9.49G
used_memory_lua:38912
mem_fragmentation_ratio:1.02
mem_allocator:jemalloc-3.6.0
每个属性的详细说明
属性名 | 属性说明 |
---|---|
used_memory | Redis 分配器分配的内存量,也就是实际存储数据的内存总量 |
used_memory_human | 以可读格式返回 Redis 使用的内存总量 |
used_memory_rss | 从操作系统的角度,Redis进程占用的总物理内存 |
used_memory_peak | 内存分配器分配的最大内存,代表used_memory的历史峰值 |
used_memory_peak_human | 以可读的格式显示内存消耗峰值 |
used_memory_lua | Lua引擎所消耗的内存 |
mem_fragmentation_ratio | used_memory_rss /used_memory比值,表示内存碎片率 |
mem_allocator | Redis 所使用的内存分配器。默认: jemalloc |
计算公式如下: