redis.exceptions.ResponseError: OOM command not allowed when used memory > 'maxmemory'.
Im getting above error and I tried setting up through redis-cli, the maxmemory config is not available. It has only below attribute.
CONFIG GET *
- "activerehashing"
- "yes"
- "list-max-ziplist-size"
- "-2"
- "list-compress-depth"
- "0"
- "slowlog-max-len"
- "128"
- "lua-time-limit"
- "5000"
- "slowlog-log-slower-than"
- "10000"
- "stream-node-max-entries"
- "100"
- "hash-max-ziplist-entries"
- "512"
- "set-max-intset-entries"
- "512"
- "zset-max-ziplist-entries"
- "128"
- "hash-max-ziplist-value"
- "64"
- "stream-node-max-bytes"
- "4096"
- "zset-max-ziplist-value"
- "64"
- "hll-sparse-max-bytes"
- "3000"
- "notify-keyspace-events"
- ""
2
Answers
Redis Cloud sells databases of fixed sizes. So, you can’t change the maxmemory. If you are getting an OOM error, that means you need to store less stuff or buy more Redis.
Setting maxmemory will only solve the problem of increasing or decreasing your database size, but if you want that your Redis does not throw error when it becomes full, you have to configure
maxmemory-policy
.There is no magic here, ofcourse. When you ask Redis to not throw error when Redis is full and accomodate the new data coming in, the only option it has it to delete the old data. How exactly will it delete the data (either by recency or frequency) that is driven by the configuration
maxmemory-policy
.If you are not sure, you can go for:
maxmemory-policy allkeys-lru
which will basically delete the keys which have been least recently used (LRU).
The complete list of options can be viewed here.