当前位置:网站首页>Redis has three methods for checking big keys, which are necessary for optimization
Redis has three methods for checking big keys, which are necessary for optimization
2022-07-04 21:44:00 【Young】

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) 312583
3、 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 install
2、 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.csv
边栏推荐
- How was MP3 born?
- minidom 模块写入和解析 XML
- How was MP3 born?
- Golang面试整理 三 简历如何书写
- Jerry's ad series MIDI function description [chapter]
- [weekly translation go] how to code in go series articles are online!!
- Flutter 返回按钮的监听
- Delphi soap WebService server-side multiple soapdatamodules implement the same interface method, interface inheritance
- Daily question -leetcode1200- minimum absolute difference - array - sort
- [buuctf.reverse] 151_ [FlareOn6]DnsChess
猜你喜欢
![[C language] deep understanding of symbols](/img/4b/26cf10baa29eeff08101dcbbb673a2.png)
[C language] deep understanding of symbols

Flutter TextField示例

案例分享|金融业数据运营运维一体化建设
![Jerry's ad series MIDI function description [chapter]](/img/28/e0f9b41db597ff3288af431c677001.png)
Jerry's ad series MIDI function description [chapter]

【活动早知道】LiveVideoStack近期活动一览

WGCNA分析基本教程总结

巅峰不止,继续奋斗!城链科技数字峰会于重庆隆重举行

How is the entered query SQL statement executed?

ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start

Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
随机推荐
MP3是如何诞生的?
Day24: file system
OMS系统实战的三两事
哈希表(Hash Tabel)
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
股票开户佣金最低多少,炒股开户佣金最低网上开户安全吗
Jerry's ad series MIDI function description [chapter]
How much is the minimum stock account opening commission? Is it safe to open an account online
Drop down selection of Ehlib database records
Analysis of maker education technology in the Internet Era
AcWing 2022 每日一题
Methods of improving machine vision system
Interpreting the development of various intelligent organizations in maker Education
Redis03 - network configuration and heartbeat mechanism of redis
Flutter WebView示例
【公开课预告】:视频质量评价基础与实践
Analyzing the maker space contained in steam Education
杰理之AD 系列 MIDI 功能说明【篇】
redis布隆过滤器
Maidong Internet won the bid of Beijing life insurance