为什么 Redis Sorted Set 使用如此多的内存开销?

问题描述

我正在设计一个包含约 3000 个排序集键的 Redis 数据存储,每个键有 60 - 300 个项目,每个项目的大小约为 250 字节。

used_memory_overhead = 1055498028 字节和 used_memory_dataset= 9681332 字节。这个比例似乎太高了。 used_memory_dataset_perc 小于 1%。内存使用量超过 1.16G 的最大值并导致密钥被逐出。

排序集真的有 99% 的内存开销吗?我是否只需要找到另一个解决方案?我只想要一个按值中的字段排序的值列表。

这是 MEMORY INFO输出used_memory_dataset_perc 不断减少,直到

# Memory
used_memory:399243696
used_memory_human:380.75M
used_memory_RSS:493936640
used_memory_RSS_human:471.05M
used_memory_peak:1249248448
used_memory_peak_human:1.16G
used_memory_peak_perc:31.96%
used_memory_overhead:390394038
used_memory_startup:4263448
used_memory_dataset:8849658
used_memory_dataset_perc:2.24%
allocator_allocated:399390096
allocator_active:477728768
allocator_resident:499613696
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:1248854016
maxmemory_human:1.16G
maxmemory_policy:volatile-lru
allocator_frag_ratio:1.20
allocator_frag_bytes:78338672
allocator_RSS_ratio:1.05
allocator_RSS_bytes:21884928
RSS_overhead_ratio:0.99
RSS_overhead_bytes:-5677056
mem_fragmentation_ratio:1.24
mem_fragmentation_bytes:94804256
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:385555150
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0

如果相关,我正在使用 AWS Elasticache

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)