当前位置:网站首页>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
边栏推荐
- 股票开户佣金最低多少,炒股开户佣金最低网上开户安全吗
- Rotary transformer string judgment
- Huawei ENSP simulator configures ACL access control list
- Hash table
- Jerry's ad series MIDI function description [chapter]
- Jerry added the process of turning off the touch module before turning it off [chapter]
- Master the use of auto analyze in data warehouse
- Jerry's ad series MIDI function description [chapter]
- maya灯建模
- minidom 模塊寫入和解析 XML
猜你喜欢

CloudCompare&Open3D DBSCAN聚类(非插件式)

torch. Tensor and torch The difference between tensor

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

The video sound of station B is very low - solution

How was MP3 born?

如何借助自动化工具落地DevOps

Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
![[ 每周译Go ] 《How to Code in Go》系列文章上线了!!](/img/bf/77253c87bfa1512f4b8d3d8f7ebe80.png)
[ 每周译Go ] 《How to Code in Go》系列文章上线了!!

Keep on fighting! The city chain technology digital summit was grandly held in Chongqing

【C語言】符號的深度理解
随机推荐
开源之夏专访|Apache IoTDB社区 新晋Committer谢其骏
gtest从一无所知到熟练使用(4)如何用gtest写单元测试
[early knowledge of activities] list of recent activities of livevideostack
旋变串判断
Open3D 曲面法向量计算
面试官:说说XSS攻击是什么?
Numpy vstack and column_ stack
2021 CCPC Harbin I. power and zero (binary + thinking)
[ 每周译Go ] 《How to Code in Go》系列文章上线了!!
A quick start to fastdfs takes you three minutes to upload and download files to the ECS
Learning breakout 3 - about energy
刘锦程荣获2022年度中国电商行业创新人物奖
Flink1.13 SQL basic syntax (I) DDL, DML
Lambdaquerywrapper usage
Redis transaction
redis RDB AOF
For MySQL= No data equal to null can be found. Solution
How much is the minimum stock account opening commission? Is it safe to open an account online
How was MP3 born?
Configuration of DNS server of Huawei ENSP simulator