当前位置:网站首页>Redis cache breakdown, cache penetration, cache avalanche
Redis cache breakdown, cache penetration, cache avalanche
2022-07-06 03:07:00 【Attacking Xiao Wang 666】
Cache penetration
a large number of key Not in cache , The request goes directly to the database , and key It's not in the database ( Finally back to null, A meaningless query ), If hackers create such a large number of request attacks , Cache penetration may occur
Solution :
1. You can verify at the front end or back end , Filter illegal requests , For example, judge whether the request has been tampered by the summary Algorithm
2. Invalid cache key, Set a shorter effective time ( Not recommended )
3. The bloon filter , A very clever data structure , The concrete realization is :
Store all possible request values in the bloom filter , When requested by the user , First, judge whether the value exists through the bloom filter , If no error message is returned directly .
The process is as follows
When stored , Through multiple hash Function calculation , Then set the corresponding position of the bit array to 1
When comparing , The use of multiple hash The algorithm calculates the request parameters , Judge whether each element at the corresponding position in the digit group is 1, If there is any inconformity, it will be judged as fasle
Of course , Different strings may be hashed out in the same position ( You can appropriately increase the size of the digit group or adjust hash function )
Cache avalanche
It is caused by memory server downtime or simultaneous failure of a large number of hotspot caches at the same time , The request landed in the database
Solution :
1. For server downtime , It can be distributed ( Master-slave ) To improve usability , Or current limiting , Prevent a large number of requests for access at the same time
2. For hotspot cache invalidation , It can be set to never expire ( Not recommended ), Or set the expiration time randomly ( Peak staggering failure )
Cache breakdown
Cache avalanche is aimed at the situation that a large number of caches for different requests are invalidated , Cache breakdown refers to the situation that a large number of requests are the same and the cache fails
Solution :
Hotspot cache does not expire
Use mutexes , Only one request thread can reload the results into the cache after the cache expires , Other threads wait , Finally, query from the cache .
边栏推荐
- Briefly describe the implementation principle of redis cluster
- QT release exe software and modify exe application icon
- Pure QT version of Chinese chess: realize two-man, man-machine and network games
- [Chongqing Guangdong education] higher mathematics I reference materials of Southwest Petroleum University
- Atcoder beginer contest 233 (a~d) solution
- Add one to non negative integers in the array
- 【若依(ruoyi)】启用迷你导航栏
- [unity3d] GUI control
- 银行核心业务系统性能测试方法
- Solution: attributeerror: 'STR' object has no attribute 'decode‘
猜你喜欢
![[concept] Web basic concept cognition](/img/27/14bcd73ca70d136436a4382a1b4bd1.jpg)
[concept] Web basic concept cognition

RobotFramework入门(二)appUI自动化之app启动

Referenceerror: primordials is not defined error resolution
![Buuctf question brushing notes - [geek challenge 2019] easysql 1](/img/37/c38a933ce7fa5d2b8fa597965ffcb2.png)
Buuctf question brushing notes - [geek challenge 2019] easysql 1
![[Chongqing Guangdong education] higher mathematics I reference materials of Southwest Petroleum University](/img/0f/520242492524522c887b6576463566.jpg)
[Chongqing Guangdong education] higher mathematics I reference materials of Southwest Petroleum University

Which ecology is better, such as Mi family, graffiti, hilink, zhiting, etc? Analysis of five mainstream smart brands

深入探究指针及指针类型

IPv6 jobs
How to do function test well

Maturity of master data management (MDM)
随机推荐
这些不太会
OCR文字識別方法綜述
Qt发布exe软件及修改exe应用程序图标
Introduction to robotframework (I) brief introduction and use
Daily question brushing plan-2-13 fingertip life
ERA5再分析资料下载攻略
Pat 1084 broken keyboard (20 points) string find
适合程序员学习的国外网站推荐
Apt installation ZABBIX
jsscript
2345 file shredding, powerful file deletion tool, unbound pure extract version
Résumé des méthodes de reconnaissance des caractères ocr
技术分享 | undo 太大了怎么办
Custom attribute access__ getattribute__/ Settings__ setattr__/ Delete__ delattr__ method
SD卡报错“error -110 whilst initialising SD card
Add one to non negative integers in the array
银行核心业务系统性能测试方法
Performance test method of bank core business system
【指针训练——八道题】
Game theory matlab