Determine the memory impact of storing indicator counts in one big hash, or several smaller hashes.
See the redis memory docs for the advantages of several smaller hashes.
Store 10mm values in one big hash. Code:
r = Redis.new
N = 10_000_000
r.pipelined { N.times {|n| r.hincrby('aaron-hash', n, rand(N)) } }
###Memory usage: 803MB
$ redis-cli info |grep used_memory_human
used_memory_human:803.36M
hash-max-ziplist-entries
is 512.
Code:
r.pipelined { N.times {|n| k = "aaron-hash:#{n/512}"; r.hincrby(k, n, rand(N)) } }
$ redis-cli info |grep used_memory_human
used_memory_human:109.45M