当前位置:网站首页>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 .
边栏推荐
- Simple Fibonacci (recursive)
- AI matting tool
- 阿霍的三个阶段
- Like the three foot platform
- First intention is the most important
- How can genetic testing help patients fight disease?
- The sky is blue and misty
- shell脚本导入存储过程到数据库
- Teach you to complete the actual battle of image classification hand in hand -- Image Recognition Based on convolutional neural network
- redis探索之缓存击穿、缓存雪崩、缓存穿透
猜你喜欢

Sleep quality today 79 points

Logstash error: cannot reload pipeline, because the existing pipeline is not reloadable

《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现

VM虚拟机配置动态ip和静态ip访问

【开发大杀器】之Idea

Use Net core access wechat official account development

Mobile note application
![[brain opening] west tide and going to the world series](/img/b2/444af296e170d19629800b3d4c50fa.jpg)
[brain opening] west tide and going to the world series

基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能

Operator-1初识Operator
随机推荐
leetcode:226. Flip binary tree [DFS flip]
redis探索之缓存击穿、缓存雪崩、缓存穿透
Ansible Playbook
leetcode:226. 翻转二叉树【dfs翻转】
编译调试Net6源码
"Analysis of 43 cases of MATLAB neural network": Chapter 40 research on prediction of dynamic neural network time series -- implementation of NARX based on MATLAB
有人碰到过这种情况吗,oracle logminer 同步的时候,clob字段的值丢失
使用BurpSuite对app抓包教程
R language uses conf of yardstick package_ The mat function calculates the confusion matrix of the multiclass model on each fold of each cross validation (or resampling), and uses the summary to outpu
【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告
微信模拟地理位置_伪装微信地理位置
6.30 simulation summary
请问flink mysql cdc 全量读取mysql某个表数据,对原始的mysql数据库有影响吗
Zero copy technology of MySQL
Queue operation---
阿霍的三个阶段
Chained storage of queues
The sky is blue and misty
How can genetic testing help patients fight disease?
Logstash error: cannot reload pipeline, because the existing pipeline is not reloadable