How do I resolve the error message "OOM command not allowed when used memory > 'maxmemory'" for an Amazon ElastiCache Redis cluster node?

Last updated: 2020-06-08

Clients receive the error "OOM command not allowed when used memory 'maxmemory'" when querying my Amazon ElastiCache for Redis cluster node. What does this error mean, and how do I fix it?

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 is 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 these 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 only 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 cannot 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 only temporarily resolves OOM errors. Be sure to also rethink your memory management strategy.


Did this article help you?

Anything we could improve?


Need more help?