redis.conf 中的 maxmemory 参数 [英] maxmemory parameter in redis.conf
问题描述
我正在尝试在 redis 中插入键值".值"是 X 字节,同时将我的应用程序插入到 redis 中.我想知道在从 ./redis-cli 触发INFO"命令后要监视哪个参数来检查 X(或者可能是 X + somevalue ,以防 redis 填充一些数据)字节数已在 redis.Am 中使用确定我的应用程序所需的 maxmemory(redis.conf) 参数.
I am trying to insert key-"value" in redis.The "value" is of X bytes while leaving my application to be inserted in redis. I want to know which parameter to monitor after firing "INFO" command from ./redis-cli to check that X(or perhaps X + somevalue , in case redis pads some data) number of bytes have been used in redis.Am doing this to determine the maxmemory(redis.conf) parameter needed for my application.
我有一个 master 和一个 sentinel,正在使用 redis 进行临时存储.我尝试监视 used_memory 参数.但根据我得到的数据,maxmemory 似乎与 used_memory 无关.
I have one master and a sentinel and am using redis for transient storage.I have tried monitoring the used_memory parameter. But as per the data i got it seems that maxmemory is not related to used_memory.
因此,我正在考虑使用提供序列化长度的调试对象 Mykey".这个长度究竟是什么,我在 redis 文档中找不到任何描述.
So instead I was thinking of using "debug object Mykey" which gives the serializedlength.What exactly is this length , I could not find any description in redis docs.
所以基本上有两个问题:
So basically two questions :
maxmemory 和 used_memory 是否相关,如果是,那么在使用 used_memory 计算插入的键值占用的空间时是否有一些问题.
Are maxmemory and used_memory related ,if yes then is there some catch in using used_memory to calculate space occupied by the inserted key-value.
调试对象Mykey"命令中的serializedlength是什么
What is serializedlength in the "debug object Mykey" command
推荐答案
maxmemory
配置指令规定了应允许 Redis 用于用户数据的最大内存量.当设置为 0(默认值)时,只要底层操作系统允许,Redis 就会分配内存.INFO
命令中的used_memory
值是调用该命令时用户数据消耗的实际内存.两者的关系(只要maxmemory
不为0)就是used_memory
<=maxmemory
.
The
maxmemory
configuration directive dictates the maximum amount of memory that Redis should be allowed to use for user data. When set to 0 (the default value), Redis will allocate memory as long as the underlying OS will allow it. Theused_memory
value from theINFO
command is the actual memory consumed by user data at the time that the command was invoked. The relationship between the two (as long ismaxmemory
isn't 0) isused_memory
<=maxmemory
.
DEBUG OBJECT
输出的 serializedlength
是序列化时存储在该键下的值的长度(以字节为单位).要获得实际的序列化值,您可以使用 DUMP
命令.请注意,由于包括 Redis 对数据结构的编码和开销在内的无数因素,序列化长度不能提供密钥使用的实际内存量的准确度量.
The serializedlength
outputted by DEBUG OBJECT
is the length (size in bytes) of the value stored under that key when serialized. To obtain the actual serialized value you can use the DUMP
command. Note that the serialized length does not provide an accurate measure of the actual amount of memory that's used by the key due to a myriad of factors including Redis' encoding of the data structure and overheads.
通常,为了获得您的 maxmemory
设置的估计值,请尝试存储代表您的数据的 100 个(例如 1000 个)键,检查 used_memory
然后,除以该值,然后将结果乘以具有安全余量(例如至少 %10)的预期键数.
Generally, in order to obtain an estimate for your maxmemory
setting, try storing a few 100s (e.g. 1000) keys that are representative of your data, check the used_memory
afterwards, divide the value and then multiply the result by the number of expected keys with a safe margin (e.g. at least %10).
这篇关于redis.conf 中的 maxmemory 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!