gpt4 book ai didi

redis - 如何减少 Redis 中的 mem_fragmentation_ratio?

转载 作者:IT王子 更新时间:2023-10-29 06:12:28 29 4
gpt4 key购买 nike

通过 info 命令,我得到

mem_fragmentation_ratio:1.24

大于 1

我知道这意味着 redis 持有一些可以释放的空闲内存。

我怎样才能释放这个内存并降低这个比例?

我尝试了MEMORY PURGE,但比率没有改变。

redis_version:4.0.9

# Memory
used_memory:8347302992
used_memory_human:7.77G
used_memory_rss:9236336640
used_memory_rss_human:8.60G
used_memory_peak:17919661152
used_memory_peak_human:16.69G
used_memory_peak_perc:46.58%
used_memory_overhead:519883816
used_memory_startup:1215600
used_memory_dataset:7827419176
used_memory_dataset_perc:93.79%
total_system_memory:270383198208
total_system_memory_human:251.81G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:21474836480
maxmemory_human:20.00G
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.11
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0

最佳答案

Redis 不太擅长释放未使用的内存。一般来说,redis 会保留它在高峰期消耗的所有内存。这通常不是问题,只要您的服务器有足够的内存来处理它。从您的信息中我可以看出,您的服务器拥有的内存比您为 Redis 主动使用的内存多得多。

明确地说,MEMORY PURGE command仅适用于 jemalloc 内存分配器:

The MEMORY PURGE command attempts to purge dirty pages so these can be reclaimed by the allocator.

This command is currently implemented only when using jemalloc as an allocator, and evaluates to a benign NOOP for all others.

因此,如果您在 windows 或 mac 上运行 redis,您可能无法使用 MEMORY PURGE

不过,一般来说,我不会担心如此接近 1 的碎片率。只有当碎片率低于 1 或远高于 1(例如 10 或更多)时,问题通常才会出现。

关于redis - 如何减少 Redis 中的 mem_fragmentation_ratio?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56799931/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com