REDIS内存占用率高



我们写了6.7M个键,值大小为600字节。总内存使用量预期为4.2GB,但我们注意到rss内存使用量为5.7GB。

为什么redis使用额外的2GB内存?

memory info命令输出

info memory
# Memory
used_memory:5913620368
used_memory_human:5.51G
used_memory_rss:6065446912
used_memory_rss_human:5.65G
used_memory_peak:5913639024
used_memory_peak_human:5.51G
used_memory_peak_perc:100.00%
used_memory_overhead:338769120
used_memory_startup:1018080
used_memory_dataset:5574851248
used_memory_dataset_perc:94.29%
allocator_allocated:5913554768
allocator_active:6065409024
allocator_resident:6065409024
total_system_memory:34359738368
total_system_memory_human:32.00G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.03
allocator_frag_bytes:151854256
allocator_rss_ratio:1.00
allocator_rss_bytes:0
rss_overhead_ratio:1.00
rss_overhead_bytes:37888
mem_fragmentation_ratio:1.03
mem_fragmentation_bytes:151892144
mem_not_counted_for_evict:3738
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:17440
mem_aof_buffer:4096
mem_allocator:libc
active_defrag_running:0
lazyfree_pending_objects:0

redis中的键数

info keyspace
# Keyspace
db6:keys=6765516,expires=0,avg_ttl=0

请查看此https://redis.io/topics/faq:

64位系统将比32位系统使用更多的内存来存储相同的键,特别是当键和值很小的时候。这是因为指针在64位系统中占用8个字节. 当然,优势在于你可以在64位系统中拥有大量内存,所以为了运行大型Redis服务器,64位系统或多或少是必需的。另一个选项是shardi

最新更新