当前位置:网站首页>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 .
边栏推荐
- Spherical lens and cylindrical lens
- Atcoder beginer contest 233 (a~d) solution
- What are the principles of software design (OCP)
- 多态day02
- CobaltStrike-4.4-K8修改版安装使用教程
- Derivation of anti Park transform and anti Clarke transform formulas for motor control
- 主数据管理理论与实践
- Force buckle 146 LRU cache
- 2.12 simulation
- 2022工作中遇到的问题四
猜你喜欢
主数据管理理论与实践
XSS challenges bypass the protection strategy for XSS injection
Solution: attributeerror: 'STR' object has no attribute 'decode‘
What is the investment value of iFLYTEK, which does not make money?
Yyds dry inventory comparison of several database storage engines
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
Installation and use tutorial of cobaltstrike-4.4-k8 modified version
Software design principles
[kubernetes series] learn the exposed application of kubernetes service security
Selenium share
随机推荐
有没有完全自主的国产化数据库技术
How to improve the enthusiasm of consumers when the member points marketing system is operated?
电机控制反Park变换和反Clarke变换公式推导
【指针训练——八道题】
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
RobotFramework入门(二)appUI自动化之app启动
Solution: attributeerror: 'STR' object has no attribute 'decode‘
1003 emergency (25 points), "DIJ deformation"
Self made CA certificate and SSL certificate using OpenSSL
2.13 simulation summary
技术分享 | undo 太大了怎么办
Introduction to robotframework (III) Baidu search of webui automation
My C language learning record (blue bridge) -- on the pointer
XSS challenges bypass the protection strategy for XSS injection
1. Dynamic parameters of function: *args, **kwargs
JS regular filtering and adding image prefixes in rich text
IPv6 jobs
My C language learning record (blue bridge) -- under the pointer
Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]
Add one to non negative integers in the array