当前位置:网站首页>Redis exploration: cache breakdown, cache avalanche, cache penetration
Redis exploration: cache breakdown, cache avalanche, cache penetration
2022-07-01 12:46:00 【Bronze God】
In today's Internet Environment , It seems that every system will use cache , Big data is rampant , A lot of data because of the traditional mysql Hard disk query will become a system bottleneck . Therefore, the purpose of introducing cache is to improve the response speed of the system , Increase throughput . Put popular data into the cache to reduce the number of database searches . Since caching matters , When applying caching , Problems encountered and solutions , It becomes a must for programmers 、 The interview will be .
Basic cache logic used in the system

The first axe : Cache penetration
Cache penetration refers to querying data that does not exist at all . Because the cache does not exist , So the request will query the database , Because there is no data , It will not be stored in the cache .

terms of settlement
1. Cache null : This is very simple , It's easy to think of , I'll also store the problematic data in the cache , Tell cache , It's problematic , Don't pass it back . Avoid sending requests through the cache to the database .
2. Use of Blum filter : Use bloom filter , Put the database data , Map to bloom filter . As the first safety door , Filter invalid requests .
The second axe : Cache breakdown
Buffer breakdown refers to a Key The hotspot cache data expires at a certain point in time , Just at this time, there are a lot of requests to query this Key, These requests are sent to the database .

terms of settlement
Put hotspot data into cache in advance , And set never expire or use scheduled tasks to refresh cached data and expiration time .
Using distributed locks , Ensure that when the cache fails, a large number of concurrent messages will not be sent to the database .
The difference between cache penetration and cache breakdown
The cache penetration request is not in the cache , There is no data in the database , Plus a lot of concurrency , Resulting in system paralysis .
The cache breakdown request is not in the cache , But some data in the database .
The third axe : Cache avalanche
Cache avalanche refers to key Large area failure at the same time , Cause a large number of requests to be sent to the database . It is a special case of buffer breakdown .
The common reason is :1.redis The server is down ;2. A large amount of cached data has the same expiration time , At a certain point in time, thunderstorms .

terms of settlement
Spread the expiration time , Set to fixed time + random number , Reduce the possibility of expiration together .
Use locks or message queues , Limit the amount of concurrency .
Set up multi level cache , image CPU Third level cache , Layer by layer screening .
边栏推荐
- Shell script imports stored procedures into the database
- Nc100 converts strings to integers (ATOI)
- I spent tens of thousands of dollars to learn and bring goods: I earned 3 yuan in three days, and the transaction depends on the bill
- 木架的场景功能
- Logstash error: cannot reload pipeline, because the existing pipeline is not reloadable
- Relationship between accuracy factor (DOP) and covariance in GPS data (reference link)
- shell脚本导入存储过程到数据库
- The popular major I chose became "Tiankeng" four years later
- Router.use() requires a middleware function but got a Object
- How to play with the reading and writing operations of blocking sockets?
猜你喜欢

Logstash error: cannot reload pipeline, because the existing pipeline is not reloadable
![leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]](/img/10/acd162c3adf9d6f14fa5a551dc0d25.png)
leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]

Operations related to sequence table

codeforces -- 4B. Before an Exam

Nc100 converts strings to integers (ATOI)

leetcode:241. 为运算表达式设计优先级【dfs + eval】

I spent tens of thousands of dollars to learn and bring goods: I earned 3 yuan in three days, and the transaction depends on the bill

【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告

Look at the sky at dawn and the clouds at dusk, and enjoy the beautiful pictures

Project deployment is not difficult at all!
随机推荐
工具箱之 IKVM.NET 项目新进展
腾讯黎巍:深耕“监管科技”,护航数字经济行稳致远
Project deployment is not difficult at all!
Nc100 converts strings to integers (ATOI)
R语言使用yardstick包的conf_mat函数计算多分类(Multiclass)模型在每个交叉验证(或者重采样)的每一折fold上的混淆矩阵、并使用summary输出每个fold的其它详细指标
Chain storage of binary tree
The sky is blue and misty
我花上万学带货:3天赚3元,成交靠刷单
Using burpsuite to capture app packages
有人碰到过这种情况吗,oracle logminer 同步的时候,clob字段的值丢失
leetcode:241. Design priority for operation expression [DFS + Eval]
【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告
R语言基于h2o包构建二分类模型:使用h2o.gbm构建梯度提升机模型GBM、使用h2o.auc计算模型的AUC值
Ansi/ul 94 VTM vertical burning test for thin materials
数论基础及其代码实现
Run PowerShell script prompt "because running script is prohibited on this system" solution
Ansible Playbook
MySQL的零拷贝技术
Topic 2612: the real topic of the 12th provincial competition of the Blue Bridge Cup in 2021 - the least weight (enumerating and finding rules + recursion)
Fundamentals of number theory and its code implementation