How do I resolve the error message "OOM command not allowed" for an ElastiCache for Redis cluster node?

3 minute read
0

I received the "OOM command not allowed when used memory greater than 'maxmemory'" error when querying my Amazon ElastiCache for Redis cluster node? How do I resolve this?

Short description

An OOM error occurs when an ElastiCache for Redis cluster can't free any additional memory.

ElastiCache for Redis implements the maxmemory-policy that's set for the cache node’s parameter group when out of memory. The default value (volatile-lru) frees up memory by evicting keys with a set expiration time (TTL value). When a cache node doesn't have any keys with a TTL value, it returns an error instead.

To resolve this error and to prevent clients from receiving OOM command not allowed error messages, do some combination of the following:

  • Set a TTL value for keys on your node.
  • Update the parameter group to use a different maxmemory-policy parameter.
  • Delete some existing keys manually to free up memory.
  • Choose a larger node type.

Note: The exact combination of the resolutions you use depends on your particular use case.

Resolution

Set a TTL value for keys on your node

You can set a TTL value for keys on your node. The default volatile-lru memory management policy then evicts expired keys to free up memory.

If you set a TTL value, you can also use the volatile-ttl setting. This setting makes space by evicting only those keys with an expire time set, starting with the keys with the lowest TTL.

Choose a different maxmemory-policy setting

Set the maxmemory-policy for a cache node parameter group to one of the following values:

  • allkeys-lru: Make space by evicting less recently used keys first.
  • allkeys-random: Make space by evicting random keys.
  • volatile-random: Make space by evicting random keys with an expire set.

Additionally, Redis 4.0 offers least frequently used (LFU) eviction modes:

  • allkeys-lfu: Make space by evicting the key that was accessed the fewest number of times.
  • volatile-lfu: Make space by evicting keys with an expire set, starting with the one that was accessed the fewest number of times.

Delete existing keys to free up memory

You can delete existing keys to free up memory using the DEL command. For more information, see Del key [key...] on the redis.io website.

Important: Deleting existing keys temporarily resolves OOM errors. Be sure to also reconsider your memory management strategy.

Choose a larger node type

Each node type has a different amount of available memory. You can't modify the amount of available memory on a node. However, you can use a larger node type with more storage.

Important: Using a larger node type temporarily resolves OOM errors. Be sure to also reconsider your memory management strategy.


Related information

Redis 4.0.10 parameter changes

Redis node-type specific parameters

Key eviction - Overview of Redis key eviction policies (LRU, LFU, etc.)

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago