简体   繁体   中英

maxmemory parameter in 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.

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.

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 :

  1. 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.

  2. What is serializedlength in the "debug object Mykey" command

  1. 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. The used_memory value from the INFO command is the actual memory consumed by user data at the time that the command was invoked. The relationship between the two (as long is maxmemory isn't 0) is used_memory <= maxmemory .

  2. 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.

Generally, in order to obtain an estimate for your maxmemory setting, try storing a few 100s (eg 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 (eg at least %10).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM