Redis: what's eating memory and time
Three commands for finding the biggest keys, the real memory usage, and which command is slowing the server down.
Biggest keys
redis-cli --bigkeys
Walks the whole database with SCAN and shows the biggest key of each type.
Mind the units: for strings it counts bytes, for collections the number of elements. A list with a million short entries will look “bigger” here than a single 10 MB string.
What it actually weighs
redis-cli --memkeys
Same walk, but measured with MEMORY USAGE — real bytes. Slower, but it doesn’t lie. Redis 6
and up.
A single key:
redis-cli MEMORY USAGE mykey
Both walks cover the entire keyspace. On a large database add -i 0.1 so they pause between
batches instead of hammering the server.
Command stats
INFO commandstats
How many times each command ran and how long it took on average (usec_per_call). Usually
this is where it turns out Redis isn’t slow — somebody is just hammering KEYS in a loop.
Reset the counters before measuring:
CONFIG RESETSTAT