Redis 使用 bigkeys 命令查找大 key

Redis 诊断工具 About 2,316 words

大 key 问题

存储得值如果过大,在网络传输时占用过高带宽,导致性能问题。

查找大 key

redis-cli --bigkeys -i 0.1

输出:

# 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 zset   found so far 'race_join:2018120553' with 76 members
[00.00%] Biggest list   found so far 'mp_st:894' with 2 items
[00.00%] Biggest string found so far 'h5-game:tyt_sichuan' with 19 bytes
[00.00%] Biggest list   found so far 'mp_st:978' with 6 items
[00.00%] Biggest string found so far 'login:252' with 28 bytes
[04.33%] Biggest set    found so far 'race_book:2018121431' with 1 members
[04.33%] Biggest list   found so far 'mp_st:8' with 8 items
[08.66%] Biggest list   found so far 'mp_st:328' with 11 items
[08.66%] Biggest list   found so far 'mp_st:241' with 13 items
[12.99%] Biggest set    found so far 'race_book:2018121432' with 2 members
[12.99%] Biggest zset   found so far '20180922tyt_mini' with 80 members
[12.99%] Biggest zset   found so far '201811182048_henan' with 1456 members
[25.97%] Biggest list   found so far 'mp_st:492' with 20 items
[25.97%] Biggest zset   found so far '201811202048_neimenggu' with 6249 members
[44.16%] Biggest set    found so far 'race_book:2018120553' with 29 members
[48.48%] Biggest list   found so far 'mylist' with 100752 items
[57.14%] Biggest zset   found so far '20180824tyt_henan' with 32116 members
[83.12%] Biggest zset   found so far '20181101tyt_henan' with 46203 members

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

Sampled 231 keys in the keyspace!
Total key length in bytes is 4072 (avg len 17.63)

Biggest string found 'login:252' has 28 bytes
Biggest   list found 'mylist' has 100752 items
Biggest    set found 'race_book:2018120553' has 29 members
Biggest   zset found '20181101tyt_henan' has 46203 members

49 strings with 1112 bytes (21.21% of keys, avg size 22.69)
134 lists with 101348 items (58.01% of keys, avg size 756.33)
13 sets with 52 members (05.63% of keys, avg size 4.00)
0 hashs with 0 fields (00.00% of keys, avg size 0.00)
35 zsets with 116908 members (15.15% of keys, avg size 3340.23)

查看大 key 信息

DEBUG OBJECT test_key

输出:

127.0.0.1:6379> DEBUG OBJECT test_key
Value at:0x7fced20badf0 refcount:1 encoding:raw serializedlength:3988 lru:15372545 lru_seconds_idle:6582199
Views: 5,448 · Posted: 2019-04-08

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh