当前位置:网站首页>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 .
边栏推荐
- 1. Dynamic parameters of function: *args, **kwargs
- How to do function test well
- Eight super classic pointer interview questions (3000 words in detail)
- My C language learning records (blue bridge) -- files and file input and output
- CobaltStrike-4.4-K8修改版安装使用教程
- Polymorphic day02
- [kubernetes series] learn the exposed application of kubernetes service security
- 2345 file shredding, powerful file deletion tool, unbound pure extract version
- Maturity of master data management (MDM)
- Solution: attributeerror: 'STR' object has no attribute 'decode‘
猜你喜欢

Microsoft speech synthesis assistant v1.3 text to speech tool, real speech AI generator

Linear programming matlab
![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

NR modulation 1

Apt installation ZABBIX

Linear regression and logistic regression

Qt发布exe软件及修改exe应用程序图标

电机控制反Park变换和反Clarke变换公式推导

C language - Blue Bridge Cup - promised score
随机推荐
建模规范:命名规范
4. File modification
【Kubernetes 系列】一文學會Kubernetes Service安全的暴露應用
Polymorphic day02
2022工作中遇到的问题四
【Kubernetes 系列】一文学会Kubernetes Service安全的暴露应用
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
Problems encountered in 2022 work IV
Microsoft speech synthesis assistant v1.3 text to speech tool, real speech AI generator
How to read excel, PDF and JSON files in R language?
How does yyds dry inventory deal with repeated messages in the consumption process?
Linear regression and logistic regression
Audio audiorecord binder communication mechanism
Apt installation ZABBIX
RobotFramework入门(三)WebUI自动化之百度搜索
Data and Introspection__ dict__ Attributes and__ slots__ attribute
Introduction to robotframework (III) Baidu search of webui automation
My C language learning record (blue bridge) -- on the pointer
Briefly describe the implementation principle of redis cluster
resulttype和resultmap的区别和应用场景