分析redis key的大小

                       分析redis key的大小
 

bigKeys

这是redis-cli自带的一个命令。对整个redis进行扫描,寻找较大的key。例:

格式:redis-cli -h 服务端主机名或者IP地址 -p 端口 [-a password] --bigkeys  

$ redis-cli -h 192.168.0.112 -p 6379 --bigkeys

说明:
①该命令使用scan方式对key进行统计,所以使用时无需担心对redis造成阻塞。
②输出大概分为两部分,summary之上的部分,只是显示了扫描的过程。summary部分给出了每种数据结构中最大的Key。
③统计出的最大key只有string类型是以字节长度为衡量标准的。list,set,zset等都是以元素个数作为衡量标准,不能说明其占的内存就一定多。所以,如果你的Key主要以string类型存在,这种方法就比较适合。

输出内容:

# 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 string found so far 'tx:manager:compensate:order-service:2019-01-25:eXC0yl5s.json' with 69032 bytes
[00.00%] Biggest hash   found so far 'count' with 33 fields
[47.62%] Biggest set    found so far 'menu:url' with 8 members

-------- summary -------

Sampled 21 keys in the keyspace!
Total key length in bytes is 743 (avg len 35.38)

Biggest string found 'tx:manager:compensate:order-service:2019-01-25:eXC0yl5s.json' has 69032 bytes
Biggest    set found 'menu:url' has 8 members
Biggest   hash found 'count' has 33 fields

14 strings with 274555 bytes (66.67% of keys, avg size 19611.07)
0 lists with 0 items (00.00% of keys, avg size 0.00)
1 sets with 8 members (04.76% of keys, avg size 8.00)
6 hashs with 39 fields (28.57% of keys, avg size 6.50)
0 zsets with 0 members (00.00% of keys, avg size 0.00)

猜你喜欢

转载自blog.csdn.net/xiao__jia__jia/article/details/103621979