記一次Redis記憶體詭異增長
阿新 • • 發佈:2018-12-05
一、現象
- 例項名: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 |
計算公式如下: