Blog

Redis Evictions: Find What Is Filling Memory

Diagnose rising Redis evictions and a falling cache hit rate by comparing maxmemory, eviction policy, and key-prefix growth.

WatchLog product example: Redis is at maxmemory, evicting keys, and most memory is held by the cart prefix without a TTL.

If Redis starts evicting keys and the cache hit rate falls, compare the two with memory and the configured eviction policy before increasing the limit. The problem could be more keys, larger values, changed expiration, or normal churn after a deploy. A hit-rate drop alone does not tell you which case you have.

Confirm Redis is evicting keys, not just expiring them

Compare used memory and maxmemory with changes in evicted_keys, expired_keys, keyspace_hits, and keyspace_misses. Use rates or changes over the same window and account for counter resets. Calculate hits divided by hits plus misses; a nearly idle cache can give a noisy ratio.

An expired key reached its timeout. An evicted key was removed to make room. Cold traffic or a changed key pattern can lower the hit rate without eviction. With noeviction, check rejected writes instead of looking for a rising eviction count. See the Redis eviction policy documentation.

Find the prefix that grew

On the WatchLog Redis page, line up memory, evictions and hit rate. Open the key-prefix view to compare memory share, changes in bytes and key count, and how many sampled keys have an expiry.

In the WatchLog product example above, Redis is at its 64 MB limit and evicting 2,341 keys per minute. The sampled cart:* prefix holds most of the memory with no TTL. The collector reports a nearby catalog-import deploy and heavy client traffic. Those are leads: confirm the application writes that prefix and whether its TTL behavior changed. The sampled prefix view and client stats do not prove which client wrote an individual key.

Pick the change that matches the cause

If a cache-only prefix unexpectedly stopped expiring, fix the writer’s TTL behavior first. Existing keys may still need a separate cleanup plan. Avoid clearing the cache in bulk during peak load, when repopulating it could overload the database. If valid working-set growth caused the issue, size extra memory with headroom for process overhead, persistence and replication. If non-cache data shares the instance, don't switch to a policy that can evict it without understanding the impact.

After one change, compare Redis errors, eviction rate, hit rate and downstream latency under similar traffic.

Set up the Redis view before the next spike

Follow the WatchLog Redis and Valkey setup guide, then check that the memory limit and hit-rate series are populated. If prefix sampling is enabled, verify that it reports the key groups you expect. See the full Redis product example.

See your own servers in five minutes.

Free on WatchLog Cloud for 5 servers or nodes, or run it yourself, open source.