The symptom and its nearby causes#
Writes fail with OOM command not allowed when used memory > 'maxmemory'. while reads succeed. The reply comes from the server, so the connection and network are fine. Redis source, server.c
Three causes produce the same reply:
- The policy forbids eviction. With
noeviction, Redis evicts nothing and returns an error on commands that would add data. Commands that only read existing data still work.noevictionis the default inredis.conf. Eviction policies · redis.conf - The policy allows eviction but finds no candidates. The
volatile-*policies evict only keys with an expiration, and they behave likenoevictionwhen no keys have one. ElastiCache's default parameter group usesvolatile-lru, so a cache whose keys carry no TTL refuses writes exactly asnoevictionwould. Eviction policies · ElastiCache engine parameters - Something grew faster than eviction can keep up: a new key family without expiry, a few keys that became very large, or memory outside the dataset such as client buffers.
This guide is one of a set on runtime dependency failures.
Why they look alike#
All three end with used_memory above maxmemory. The difference lies in what Redis was allowed to remove and what filled the space. A cache used as a cache usually wants an allkeys-* policy; a store used for data that must not disappear, such as queues or locks, often runs noeviction deliberately, and there the error is the intended signal that the store is full.
Read the memory state#
These commands read state only.
redis-cli -h REDIS_HOST -p 6379 INFO memory | grep -E '^(used_memory|used_memory_dataset|maxmemory|maxmemory_policy|mem_not_counted_for_evict|mem_clients_normal):'
redis-cli -h REDIS_HOST -p 6379 INFO stats | grep -E '^(evicted_keys|current_eviction_exceeded_time):'
redis-cli -h REDIS_HOST -p 6379 INFO keyspace
used_memory is the total Redis allocated, and used_memory_dataset is the part holding data. maxmemory and maxmemory_policy echo the configuration. evicted_keys counts keys evicted because of the limit, and current_eviction_exceeded_time is how long, in milliseconds, used_memory has stayed above maxmemory. The keyspace line reads db0:keys=...,expires=..., where expires is the number of keys with a TTL. mem_not_counted_for_evict is replica and AOF buffer memory left out of the eviction comparison, and mem_clients_normal is memory used by normal clients. INFO fields · maxmemory and buffers
To size a suspect key, MEMORY USAGE reports the bytes a key and its value take. For nested types it samples elements (SAMPLES), so the figure is an estimate. MEMORY USAGE
redis-cli -h REDIS_HOST -p 6379 MEMORY USAGE 'cart:checkout:12345'
To find large keys you do not know about, redis-cli --bigkeys (by size or element count) or --memkeys (by memory) scans the whole keyspace with SCAN. It does not block the server the way KEYS does, but it issues many commands against an instance already in trouble. The -i option adds a sleep between SCAN calls to lower the load, at the cost of a much longer run. Run it against a replica if you have one; the docs say these modes work on cluster replicas. Scan for big keys
redis-cli -h REPLICA_HOST -p 6379 --memkeys -i 0.01
On ElastiCache, DatabaseMemoryUsagePercentage is used_memory/maxmemory and Evictions comes from evicted_keys. Read the policy from the parameter group, since CONFIG is restricted there. ElastiCache metrics · Restricted commands · describe-cache-parameters
aws elasticache describe-cache-parameters \
--profile PROFILE --region REGION --cache-parameter-group-name PARAMETER_GROUP \
--query "Parameters[?ParameterName=='maxmemory-policy'].ParameterValue" \
--output text --no-cli-pager
Decision table#
| Policy | evicted_keys | Keys with TTL | Points to |
|---|---|---|---|
noeviction | 0 | any | Store full by design; growth or the limit |
volatile-* | 0 or flat | 0 or few | No eviction candidates |
volatile-* | rising | many | TTL keys evicted, persistent keys fill memory |
allkeys-* | rising fast | any | Growth outpaces eviction, or memory outside the dataset |
If used_memory_dataset is much smaller than used_memory, look at what is not data: mem_clients_normal for large client buffers, or replication buffers. INFO fields
An illustrative incident with two outcomes#
This example is illustrative. The orders service caches order summaries in an ElastiCache cluster in account 111122223333. From 15:40 UTC, writes fail with the OOM error and checkout falls back to slow database reads.
In the first outcome, the parameter group shows volatile-lru. INFO keyspace reads db0:keys=4210388,expires=51200, and evicted_keys has barely moved for a day. A release at 11:00 added a summary:v2:* key family written without a TTL. Those keys cannot be evicted under volatile-lru, the TTL keys have already been evicted, and the remaining space filled. The data store is behaving as configured; the release changed what it holds. Cache keys across versions
In the second outcome, the policy is allkeys-lru and evicted_keys is climbing by thousands a second. --memkeys on a replica finds one list, export:pending, at 3.1 GB, grown by a batch job that pushes faster than it consumes. The other keys are being evicted to make room for one key that eviction picks last because it is touched constantly. The problem is that one key's owner, and a larger node would only delay the error.
Limits#
MEMORY USAGE with sampling estimates nested values; a list with uneven element sizes can be off by a wide margin. --bigkeys ranks keys within each type by size or element count, which is not the same as memory; use --memkeys for bytes. MEMORY USAGE · Scan for big keys
On ElastiCache Serverless, MEMORY USAGE is unavailable. Restricted commands
A rising connection count can also raise client memory, and connection limits produce a different error. Max clients or timeouts · Read-only production investigation
Questions#
Why do Redis reads work while writes fail with OOM?
The OOM check rejects commands that may add data once memory is above maxmemory and nothing can be evicted. Commands that only read existing data still run normally, so a cache can look half healthy.
Can volatile-lru return an OOM error?
Yes. The volatile-* policies evict only keys with an expiration. If few or no keys have a TTL, they behave like noeviction and refuse writes once memory is full.
Is redis-cli --bigkeys expensive?
It scans every key with SCAN rather than blocking with KEYS, so it does not stall the server, but it sends many commands and takes a long time on large datasets. Throttle it with -i and prefer a replica.