当前位置:网站首页>Redis has four methods for checking big keys, which are necessary for optimization
Redis has four methods for checking big keys, which are necessary for optimization
2022-07-05 04:54:00 【Java confidant_】
Click on the official account , Practical technical articles Know in time 
Abstract : In daily life Redis In use , Inevitably encountered because key Too much data is stored, causing requests to be slow or even blocked , This is the time to check Redis The big key To optimize the business , The following provides a summary of some troubleshooting schemes , For reference only .
One 、 What size key It's big ?
Redis practice ( For reference only ):
reasonable Key in Value Byte size of , Less than recommended 10 KB.
Too much Value Will cause data skew 、 hotspot Key、 Instance traffic or CPU Problems such as full performance , The performance impact of such problems should be avoided from the design source .
that value Bytes > 10 kb Can be used as a judgment Big key A reference value of .
Two 、 Troubleshooting key Methods
1、 Use command --bigkeys
--bigkeys yes redis The order that comes with you , To the whole Key scan , Statistics string,list,set,zset,hash The largest of these common data types key.
string The type of statistics is value Bytes of ; in addition 4 Types of complex structures count the number of elements , Can not be seen intuitively value Bytes occupied , therefore --bigkeys For analysis string Large of type key It is useful to , The type of complex structure also needs some third-party tools .
notes : Fewer elements , not always value not big ; There are many elements , Not necessarily. value Big
redis-cli -h 127.0.0.1 -p 6379 -a "password" --bigkeys--bigkeys In order to scan Scan all by delaying calculation key, Therefore, there will be no blocking during execution redis, But there are a large number of instances keys when , The command takes a long time to execute , In this case, it is suggested that slave Scan up .
–-bigkeys In fact, it is to find the largest of the types key, maximal key It doesn't have to be big key, maximal key Not more than 10kb Words , It means that there is no big key.
But if a certain type has more big key (>10kb), Statistics only top1 the key, If you want to count all greater than 10kb Of key, Need to scan with third-party tools rdb Persistent files .
2、 Use memory Command view key Size ( Support only Redis 4.0 Later versions )
redis-cli -h 127.0.0.1 -p 6379 -a password
MEMORY USAGE keyname1
(integer) 157481
MEMORY USAGE keyname2
(integer) 3125833、 Use Rdbtools tool kit
Rdbtools yes python Written A third-party open source tool , Used to resolve Redis Snapshot file . In addition to parsing rdb file , It also provides statistics of individual key Tools of size .
1、 install
git clone https://github.com/sripathikrishnan/redis-rdb-tools
cd redis-rdb-tools sudo && python setup.py install2、 Use
from dump.rdb Snapshot file statistics , Will all > 10kb Of key Output to a csv file
rdb dump.rdb -c memory --bytes 10240 -f live_redis.csv4、 Use go-redis-bigkv
go-redis-bigkv Is a small tool developed by myself . Mainly be based on memory command , scanning redis All of the key, And the results are according to Sort by memory size , And the sorted Results output to txt In file . the reason being that With scan Scan all by delaying calculation key, Therefore, there will be no blocking during execution redis, But there are a large number of instances keys when , The command takes a long time to execute .
Project address :
https://github.com/th3ee9ine/go-redis-bigk
recommend
Technical involution group , Learn together !!

PS: Because the official account platform changed the push rules. , If you don't want to miss the content , Remember to click after reading “ Looking at ”, Add one “ Star standard ”, In this way, each new article push will appear in your subscription list for the first time . spot “ Looking at ” Support us !
边栏推荐
- [Business Research Report] top ten trends of science and technology and it in 2022 - with download link
- English topic assignment (26)
- 775 Div.1 C. Tyler and strings combinatorial mathematics
- Flink集群配置
- 中国金刚烷行业研究与投资预测报告(2022版)
- Rip notes [rip message security authentication, increase of rip interface measurement]
- AutoCAD - feature matching
- English topic assignment (27)
- Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
- AutoCAD - Document Management
猜你喜欢

Special information | finance, accounting, audit - 22.1.23

AutoCAD - Center zoom

Number theoretic function and its summation to be updated

Redis 排查大 key 的4种方法,优化必备

54. Spiral matrix & 59 Spiral matrix II ●●

Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9

2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
![[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator](/img/cc/06580ce7b553182968d273841a78b4.jpg)
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator

Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
![Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar](/img/bf/fb4e85143d1461a2026c88cda4a18d.jpg)
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
随机推荐
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
Fluent objects and lists
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
Personal required code
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
English topic assignment (26)
775 Div.1 C. Tyler and strings combinatorial mathematics
2021 huashubei mathematical modeling idea + reference + paper
669. 修剪二叉搜索树 ●●
669. Prune binary search tree ●●
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens
AutoCAD - graphic input and output
Debug insights
flutter 对象和列表
Unity synergy
Chapter 6 text processing tools for shell programming (awk)
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
Leetcode 222 number of nodes of complete binary tree
775 Div.1 B. integral array mathematics