当前位置:网站首页>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 .
边栏推荐
- 工具箱之 IKVM.NET 项目新进展
- 有人碰到过这种情况吗,oracle logminer 同步的时候,clob字段的值丢失
- Eurake partition understanding
- 用.Net Core接入微信公众号开发
- Using burpsuite to capture app packages
- Fundamentals of number theory and its code implementation
- leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]
- 单点登录SSO与JWT好文整理
- codeforces -- 4B. Before an Exam
- flinkcdc要实时抽取oracle,对oracle要配置什么东西?
猜你喜欢

王兴的无限游戏迎来“终极”一战

Operations related to sequence table

使用nvm管理nodejs(把高版本降级为低版本)

Ikvm of toolbox Net project new progress
![[brain opening] west tide and going to the world series](/img/b2/444af296e170d19629800b3d4c50fa.jpg)
[brain opening] west tide and going to the world series

VS Code 设置单击打开新文件窗口,不覆盖前一个窗口

【脑洞大开】《西潮》及《走向世界丛书》

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

Share several tools for designing exquisite circuit diagrams

第十四章 信号(四)- 多进程任务示例
随机推荐
R language builds a binary classification model based on H2O package: using H2O GBM build gradient hoist model GBM, use H2O AUC value of AUC calculation model
编译调试Net6源码
简单斐波那契(递推)
GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021
Router.use() requires a middleware function but got a Object
6.30 simulation summary
Application of stack -- bracket matching problem
A hole in solder paste
Fatal error: execution: there is no such file or directory
Topic 1004: the story of cows (recursion)
Compile and debug net6 source code
Exploration and practice of inress in kubernetes
数据库之MHA高可用集群部署及故障切换
The popular major I chose became "Tiankeng" four years later
《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现
腾讯总考epoll, 很烦
软件测试中功能测试流程
天青色等烟雨
Three stages of aho
数字信号处理——线性相位型(Ⅱ、Ⅳ型)FIR滤波器设计(2)