redis分析key大小
数据倾斜
影响主从同步
影响宽带
影响性能
redis-cli --bigkeys
- 多次遍历整个redis的所有key
- 执行时可以利用-i参数添加休眠时间,避免占用过多资源
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest hash found so far '"myhash1"' with 3 fields
[00.00%] Biggest string found so far '"product"' with 540 bytes
-------- summary -------
Sampled 3 keys in the keyspace!
Total key length in bytes is 20 (avg len 6.67)
Biggest hash found '"myhash1"' has 3 fields
Biggest string found '"product"' has 540 bytes
0 lists with 0 items (00.00% of keys, avg size 0.00)
2 hashs with 6 fields (66.67% of keys, avg size 3.00)
1 strings with 540 bytes (33.33% of keys, avg size 540.00)
0 streams with 0 entries (00.00% of keys, avg size 0.00)
0 sets with 0 members (00.00% of keys, avg size 0.00)
0 zsets with 0 members (00.00% of keys, avg size 0.00)
使用redis-rdb-tools工具分析
- 需要rdb文件
rdb -c memory dum.rdb > redis.csv
查看单个key
- 不需要rdb文件
redis-memory-for-key -s b.redis -p 7379 myhash