当前位置:网站首页>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 .
边栏推荐
- MySQL advanced notes
- Fault analysis | analysis of an example of MySQL running out of host memory
- CobaltStrike-4.4-K8修改版安装使用教程
- 八道超经典指针面试题(三千字详解)
- Yyds dry inventory comparison of several database storage engines
- Selenium share
- Single instance mode of encapsulating PDO with PHP in spare time
- 这些不太会
- 【若依(ruoyi)】ztree 自定义图标(iconSkin 属性)
- Deeply analyze the chain 2+1 mode, and subvert the traditional thinking of selling goods?
猜你喜欢

QT release exe software and modify exe application icon

RobotFramework入门(一)简要介绍及使用

华为、H3C、思科命令对比,思维导图形式从基础、交换、路由三大方向介绍【转自微信公众号网络技术联盟站】

XSS challenges绕过防护策略进行 XSS 注入

PMP每日一练 | 考试不迷路-7.5
![[Yu Yue education] basic reference materials of digital electronic technology of Xi'an University of Technology](/img/47/e895a75eb3af2aaeafc6ae76caafe4.jpg)
[Yu Yue education] basic reference materials of digital electronic technology of Xi'an University of Technology

I sorted out a classic interview question for my job hopping friends

2345 file shredding, powerful file deletion tool, unbound pure extract version

【概念】Web 基础概念认知

codeforces每日5题(均1700)-第六天
随机推荐
Analyze menu analysis
Derivation of anti Park transform and anti Clarke transform formulas for motor control
MySQL advanced notes
MySQL learning notes-10-tablespace recycling
My C language learning record (blue bridge) -- on the pointer
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
Universal crud interface
Web security SQL injection vulnerability (1)
Pat 1046 shortest distance (20 points) simulation
Prototype design
[unity3d] GUI control
My C language learning records (blue bridge) -- files and file input and output
Linear regression and logistic regression
C language - Blue Bridge Cup - promised score
3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
Deeply analyze the chain 2+1 mode, and subvert the traditional thinking of selling goods?
Modeling specifications: naming conventions
Technology sharing | what if Undo is too big
07 单件(Singleton)模式
手写数据库客户端