Skip to content

Instantly share code, notes, and snippets.

@overplumbum
Created July 3, 2012 21:55
Show Gist options
  • Save overplumbum/3043615 to your computer and use it in GitHub Desktop.
Save overplumbum/3043615 to your computer and use it in GitHub Desktop.
redis memory per db analysys
apt-get install unzip python-pip
pip install https://github.com/sripathikrishnan/redis-rdb-tools/zipball/master
KEYS=$(redis-cli info | perl -nle '/^db.:keys=([0-9]+)/ and print $1' | awk '{ a+=$1 } END { print a }')
rdb -c memory /var/lib/redis/dump.rdb | perl -nle '/^(\d+),.*,(\d+),(\d+)$/ and print $1, " ", $2' | pv -ltpe -s $KEYS | gzip -1 > memory.csv.gz
zcat memory.csv.gz | awk '{ c[$1]++; a[$1] += $2} END { for(i in a) print "db:" i "\t" int(a[i]/1024/1024) "Mb\t" c[i] " keys\t" int(a[i]/c[i]) " b/key" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment