当前位置:网站首页>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

边栏推荐
- 想知道一个C程序是如何进行编译的吗?——带你认识程序的编译
- C language classic exercises to write a program to find all the perfects within 1000.
- Smart contract: release an erc20 token
- [2023 core technology approval test questions in advance] ~ questions and reference answers
- 工程师能力模型与技能要求
- Question 146: LRU cache
- In the business interaction and foreign service of.Gz, we integrate multiple models
- 打印1000年到2000年之间的闰年
- Merge sort
- Qt5.14_ Realize the free drag and drop combination function of vs2019 panel under mingw/msvc
猜你喜欢

Uniapp learning

Imitate today's headlines real-time news wechat applet project source code

后 SQL 时代降临:EdgeDB 2.0 发布会预告

Event extraction and documentation (2020-2021)

归并排序(Merge sort)

微波技术基础实验二 功分器与定向耦合器设计
![[network counting experiment report] Cisco LAN Simulation and simple network test](/img/42/c0bd30ae7b693f93075e91645070a5.png)
[network counting experiment report] Cisco LAN Simulation and simple network test

最大公约数

greatest common divisor

Array force buckle (continuously updated)
随机推荐
What if the computer can't take screenshots? The solution to the problem that the shortcut screen capture key of the computer cannot be used
Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
Determined by hardware (see official 2 and
The judges of C language classic exercises score the highest and lowest to get an average score
Sort - quicksort
Why can't I log on my baidu account? Introduction to the solution of baidu account unable to log in
归并排序(Merge sort)
Share a login interface template of QT implementation
《论文复现》BiDAF代码实现过程(3)模型建立
Esp32 tutorial (I): vscode+platform and vscade+esp-idf
[2023 core technology approval test questions in advance] ~ questions and reference answers
C语言经典习题之猴子吃桃问题
你有多久没有换新手机了?
Clickpaas, a low code service provider, has completed a strategic merger with BiP technology to jointly build an industrial digital base
Godson leader spits bitterness: we have the world's first performance CPU, but unfortunately no one uses it!
PHP修改配置文件的两种方法
How much do you know about thread pool and its application
Middle aged crisis, workplace dad who dare not leave, how to face life's hesitation
由硬件确定(服务的服绍,可参看官方2 和
C language: bubble sorting