当前位置:网站首页>Redis cache penetration
Redis cache penetration
2022-06-10 21:12:00 【Fly link】
One 、 Problem description
key The corresponding data does not exist in the data source , Every time for this key The request for could not be fetched from the cache , Requests are pushed to the data source , That could crush the data source . For example, use a non-existent user id Get user information , No matter cache or database , If hackers exploit this vulnerability, they may crush the database

Two 、 Solution
There must be no data that cannot be cached or queried , Because the cache is written passively on Miss , And for the sake of fault tolerance , If no data can be found from the storage tier, it will not be written to the cache , This will cause the non-existent data to be queried by the storage layer every time it is requested , It loses the meaning of caching
Solution :
1. Cache null values
If the data returned by a query is empty ( Whether the data doesn't exist or not ), We still put this empty result (null) Cache , Setting the expiration time for empty results can be very short , Up to five minutes
2. Set up an accessible list ( White list )
Use bitmaps Type defines a list of accessible , list id As bitmaps The offset , Every visit and bitmap Inside id Compare , If you visit id be not in bitmaps Inside , To intercept , Access not allowed
3. Use of Blum filter
- The bloon filter (Bloom Filter) yes 1970 Proposed by bron in . It's actually a very long binary vector ( Bitmap ) And a series of random mapping functions ( hash function )
- The bloom filter can be used to retrieve whether an element is in a collection . Its advantage is that the space efficiency and query time are far more than the general algorithm , The disadvantage is that it has certain error recognition rate and deletion difficulty
- Hash all possible data to a large enough bitmaps in , A certain nonexistent data will be bitmaps Intercept , Thus, the query pressure on the underlying storage system is avoided
- Real-time monitoring : If I found Redis Hit rate of begins to decrease rapidly , Need to check access objects and data , Cooperate with operation and maintenance personnel , You can set up a blacklist to restrict services
边栏推荐
- 蛮力法/邻接表 深度优先 有向带权图 无向带权图
- 72. 编辑距离 ●●●
- Lengsuanling, a 30-year tortuous history of IPO of a domestic brand
- 一、Vulkan开发理论基础知识
- Four methods to obtain the position index of the first n values of the maximum and minimum values in the list
- 蛮力法/1~n的全排列 v3 递归
- 微积分复习1
- MySQL Basics
- Mba-day21 linear programming problem
- Obtained network time + time zone (+8)
猜你喜欢

連接mysql報錯 errorCode 1129, state HY000, Host ‘xxx‘ is blocked because of many connection errors
![[generation confrontation network learning part I] classic Gan and its existing problems and related improvements](/img/5a/0a4015cd4dcc21afd16ca7f895d909.png)
[generation confrontation network learning part I] classic Gan and its existing problems and related improvements

app測試用例

揭秘:春晚微信红包,是如何抗住 100 亿次请求的?

pdf.js-----js解析pdf文件實現預覽,並獲取pdf文件中的內容(數組形式)

LeetCode:1037. Effective boomerang - simple

72. editing distance ●●

Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading

Explain L3 cache to solve circular dependency

Theoretical basis of distributed services
随机推荐
Is Jiuzhou futures regular? Is it safe to open an account
MySQL Basics
H.264中NALU、RBSP、SODB的关系
Li Kou 10821084 solution_ Question of SQL query type
LeetCode:1037. Effective boomerang - simple
Redis缓存雪崩
Portable FDW framework for Pb
User defined date component. The left and right buttons control forward or backward year, month, week and day turning
【电脑使用】如何设置没有自启项的软件开机启动
冷酸灵,一个国产品牌IPO的30年曲折史
Stacked bar graph move the mouse into the tooltip to prompt that the filter is 0 element, so as to realize custom bubbles
Redis缓存穿透
Identity and access management (IAM)
Unity analyzes the rendering of built-in terrain and does some interesting things
Brute force method /k integers out of 1~n integers
Serial Print() and serial The difference of write() function, and the problem of hexadecimal and string sending and receiving format in serial port communication and detailed explanation of the conver
【生成对抗网络学习 其一】经典GAN与其存在的问题和相关改进
LeetCode 进阶之路 - 删除排序数组中的重复项
Obtained network time + time zone (+8)
In depth learning experience and tools