Search code examples
redisredis-cliredisclient

How to modify maxmemory on Redis cloud


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 *
  1. "activerehashing"
  2. "yes"
  3. "list-max-ziplist-size"
  4. "-2"
  5. "list-compress-depth"
  6. "0"
  7. "slowlog-max-len"
  8. "128"
  9. "lua-time-limit"
  10. "5000"
  11. "slowlog-log-slower-than"
  12. "10000"
  13. "stream-node-max-entries"
  14. "100"
  15. "hash-max-ziplist-entries"
  16. "512"
  17. "set-max-intset-entries"
  18. "512"
  19. "zset-max-ziplist-entries"
  20. "128"
  21. "hash-max-ziplist-value"
  22. "64"
  23. "stream-node-max-bytes"
  24. "4096"
  25. "zset-max-ziplist-value"
  26. "64"
  27. "hll-sparse-max-bytes"
  28. "3000"
  29. "notify-keyspace-events"
  30. ""

Solution

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