当前位置:网站首页>Redis enhancements
Redis enhancements
2022-07-24 04:44:00 【Sun Huide】
LrU It is to eliminate the data that has not been used for the longest time . Five minutes ago and ten minutes ago Delete ten minutes
LfU Is eliminated for a period of time , Least used data . Five times, ten times Delete five times
Cache penetration :
Cache penetration refers to data that does not exist in cache or database , And users are constantly requesting , If initiated as id by “-1” Data or id For very large nonexistent data . The user at this time is likely to be the attacker , The attack will cause too much pressure on the database
Cache penetration Solution :
1. Verification is added to the interface layer , Such as user authentication verification ,id Do basic verification ,id<=0 Direct interception of ;
2. Data not available from cache , In the database, there is no access to , At this time, you can also key-value Write as key-null,
Cache effective time can be set as a short point , Such as 30 second ( Setting too long will cause normal conditions to be unavailable ).
This prevents the attacker from repeatedly using the same id Violent attack
3. The bloon filter 
Cache breakdown :
Cache breakdown It refers to the data not in the cache but in the database ( Generally, the cache time expires ), At this time, there are many concurrent users , At the same time, the read cache does not read the data , At the same time go to the database to get data , Causes the database pressure to increase instantaneously , Cause too much pressure
Breakdown is just the name of this phenomenon, which is not impermissible
Cache avalanche
Cache avalanche It refers to the time when the data in the cache reaches the expiration date in large quantities , And the amount of query data is huge , Causes database pressure to be too big even down machine .
A large number of breakdown occurs in a short time
Cache breakdown refers to concurrent query of the same data , The cache avalanche is that different data has expired , A lot of data can't be found to look up the database .
Cache avalanche Solution
1. The expiration time of cache data is set randomly , Prevent a large number of data expiration at the same time .
2. If the cache database is a distributed deployment , Distribute the hot data evenly in different cache databases .
3. Set hotspot data never to expire
Redis Persistence
Redis Store data in memory So many factors will lead to data loss
Once the data is lost, it needs to be cached again ( Get it again in the database ) if redis If there is new data in, it cannot be recovered
How to persist
1.RDB: Generate a snapshot of the current data and save it on the hard disk .

advantage :
Because it's the whole Redis Binary format of data , Data recovery is the overall recovery
shortcoming :
Generated rdb File is a file on hard disk , Low efficiency of reading and writing
In case of sudden power failure , Only the last generated rdb Data in Not every minute of every second 2.AOF: Record every data operation on the hard disk .

To reduce the size of logs ( redundancy )
Redis Support AOF rewrite The new command of deleting some data is also removed from the log , Achieve the purpose of reducing log capacity
Redis Storage principle

Redis colony

边栏推荐
- [network counting experiment report] Cisco LAN Simulation and simple network test
- 仿今日头条实时新闻微信小程序项目源码
- Determined by hardware (see official 2 and
- Smart contract: release an erc20 token
- C语言:选择排序法
- Design of two power dividers and directional couplers for basic experiment of microwave technology
- Why can't I log on my baidu account? Introduction to the solution of baidu account unable to log in
- -Bash: wget: command not found
- ECB interface is also mdsemodet in essence
- [untitled]
猜你喜欢

OWA dynamic password SMS authentication scheme solves the problem of outlook email two factor authentication

《论文复现》BiDAF代码实现过程(3)模型建立

Esp32 tutorial (I): vscode+platform and vscade+esp-idf

C language classic exercises to write a program to find all the perfects within 1000.

C语言经典习题之评委打分去掉最高最低求平均分

Array force buckle (continuously updated)

链接预测中训练集、验证集以及测试集的划分(以PyG的RandomLinkSplit为例)

Journey of little black leetcode: 590. Post order traversal of n-ary tree

The x-fkgom supporting the GOM engine key.lic is authorized to start

基于C语言设计的一个医院叫号系统
随机推荐
PMIX ERROR: ERROR in file gds_ds12_lock_pthread.c
Er system, in Lin reply bit, count, successfully open r com change
排序——QuickSort
How to download vscode using domestic image seconds
ECB interface is also mdsemodet in essence
LabVIEW master VI freeze pending
e D件系统 NFDavi化,对工程师达高
力扣146题:LRU缓存
E d-piece system is nfdavi oriented, reaching a high level for engineers
Face algorithms
C语言:随机数的生成
Esp32 tutorial (I): vscode+platform and vscade+esp-idf
高频小信号谐振放大器设计-课程设计Multisim仿真
Chiitoitsu(期望dp)
Nautilus 3.19.2为Gnome增添动力
How to make the words on the screen larger (setting method to make the text more comfortable on the large screen)
Uniapp learning
The judges of C language classic exercises score the highest and lowest to get an average score
Good performance and reliability. The parameter that initiates writing IIC co type code and is -4
Baidu wallet helps you repay the inter-bank repayment of your credit card. The handling fee is 0. Newcomers who arrive in real time will be rewarded with 5 yuan