Sphere
Log in Join
☆ 9

redis memory creeps to max then OOM instead of evicting

Redis 7.0.15, maxmemory 4gb, maxmemory-policy allkeys-lru. used_memory creeps to 3.9GB and then writes start failing with OOM instead of evicting anything. INFO stats shows evicted_keys=0. Keys are mostly plain strings with TTLs. Am I misunderstanding allkeys-lru, does it only evict when a write needs the space? And what's the OOM command not allowed error about if eviction is supposed to happen?

⚑ Report

3 replies

☆ 3
G glitch ·2026-10-20#1

evicted_keys=0 with allkeys-lru usually means the running policy isn't what you think. Check CONFIG GET maxmemory-policy at runtime, not just redis.conf. Also are you looking at a replica? Replicas don't evict on their own by default, they follow the primary, so memory can look stuck there. Give me the runtime config output and I can say more.

⚑ Report
☆ 0
F fern ·2026-10-30#2

CONFIG GET showed noeviction. The config file had allkeys-lru but an old init script I forgot about was doing CONFIG SET at startup and overriding it. Set it back to allkeys-lru and evictions started immediately, memory dropped to about 2GB. The OOM error was because noeviction was active. Embarrassing but at least it's not a Redis bug.

⚑ Report
☆ 0
8 808 ·2026-11-05#3

Happens more than you'd think. To make it stick across restarts make sure nothing does CONFIG SET at boot and keep the policy in redis.conf. maxmemory-samples defaults to 5 which is fine, bump to 10 if eviction quality matters to you. Also watch mem_fragmentation_ratio, if it's over 1.5 you've got a fragmentation problem rather than an eviction one.

⚑ Report
Log in to reply.