Database / REDIS
How do you troubleshoot high memory usage in a Redis instance?
High memory usage troubleshooting starts with distinguishing "memory usage is high but expected" from "memory usage is growing unexpectedly," since the fixes are very different.
INFO memory MEMORY DOCTOR redis-cli --bigkeys MEMORY USAGE mykey
- Check INFO memory for
used_memory,maxmemory, andmem_fragmentation_ratio— a high fragmentation ratio can mean actual data usage is much lower than the process's real memory footprint suggests. - Run redis-cli --bigkeys to sample the keyspace and identify unusually large individual keys, which are a common, easy-to-fix source of runaway memory.
- Check for missing TTLs on data that was meant to be temporary — a caching pattern that forgot to set an expiration accumulates forever.
- Review the eviction policy and maxmemory setting — if neither is configured appropriately, memory has no ceiling at all.
- Check for unbounded collection growth — a List or Set that only ever gets appended to, with nothing trimming or expiring it, is a classic slow memory leak in application logic rather than in Redis itself.
- Use MEMORY USAGE on suspect keys to confirm exactly how much a specific key is consuming, rather than guessing from aggregate stats alone.
More Related questions...
