当前位置:网站首页>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 .
边栏推荐
- Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
- 深入探究指针及指针类型
- Pat 1084 broken keyboard (20 points) string find
- 如何做好功能测试
- Sign SSL certificate as Ca
- My C language learning records (blue bridge) -- files and file input and output
- Handwriting database client
- 银行核心业务系统性能测试方法
- SD卡报错“error -110 whilst initialising SD card
- [ruoyi] set theme style
猜你喜欢
Analyze 菜单分析
Apt installation ZABBIX
【若依(ruoyi)】启用迷你导航栏
Is there a completely independent localization database technology
Codeworks 5 questions per day (1700 average) - day 6
主数据管理理论与实践
【Kubernetes 系列】一文學會Kubernetes Service安全的暴露應用
2022工作中遇到的问题四
Gifcam v7.0 minimalist GIF animation recording tool Chinese single file version
My C language learning record (blue bridge) -- under the pointer
随机推荐
淘宝焦点图布局实战
Single instance mode of encapsulating PDO with PHP in spare time
Audio-AudioRecord Binder通信机制
Linear regression and logistic regression
PMP practice once a day | don't get lost in the exam -7.5
OCR文字識別方法綜述
MySQL learning notes-10-tablespace recycling
Spherical lens and cylindrical lens
codeforces每日5題(均1700)-第六天
Deeply analyze the chain 2+1 mode, and subvert the traditional thinking of selling goods?
Solution: attributeerror: 'STR' object has no attribute 'decode‘
电机控制反Park变换和反Clarke变换公式推导
IPv6 jobs
Apt installation ZABBIX
C语言sizeof和strlen的区别
2.11 simulation summary
故障分析 | MySQL 耗尽主机内存一例分析
微服务注册与发现
4. File modification
Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)