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

Last updated: 2019-06-04

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

Short Description

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

When it's out of memory, ElastiCache Redis implements the maxmemory-policy that is set for the cache node’s parameter group. 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 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.

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

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

Choose a larger node type

The maximum available memory on an ElastiCache Redis is determined by the node type and cannot be modified. 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?