当前位置:网站首页>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 .
边栏推荐
- Ansible相关内容梳理
- 木架的场景功能
- 简单斐波那契(递推)
- leetcode:226. Flip binary tree [DFS flip]
- [Maui] add click events for label, image and other controls
- 系统测试UI测试总结与问题(面试)
- Project deployment is not difficult at all!
- 【开发大杀器】之Idea
- Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
- How can genetic testing help patients fight disease?
猜你喜欢
Stack-------
shell脚本导入存储过程到数据库
Chapter 14 signals (IV) - examples of multi process tasks
leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]
leetcode:329. 矩阵中的最长递增路径【dfs + cache + 无需回溯 + 优雅】
"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
使用nvm管理nodejs(把高版本降级为低版本)
第十四章 信号(四)- 多进程任务示例
Look at the sky at dawn and the clouds at dusk, and enjoy the beautiful pictures
The popular major I chose became "Tiankeng" four years later
随机推荐
leetcode:226. 翻转二叉树【dfs翻转】
Project deployment is not difficult at all!
A hole in solder paste
Digital signal processing -- Design of linear phase (Ⅱ, Ⅳ) FIR filter (2)
ASTM D 3801 vertical burning test of solid plastics
王兴的无限游戏迎来“终极”一战
腾讯总考epoll, 很烦
天青色等烟雨
《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现
手把手教你完成图像分类实战——基于卷积神经网络的图像识别
[20220605] Literature Translation -- visualization in virtual reality: a systematic review
VS Code 设置单击打开新文件窗口,不覆盖前一个窗口
Operator-1初识Operator
数字信号处理——线性相位型(Ⅱ、Ⅳ型)FIR滤波器设计(2)
How can genetic testing help patients fight disease?
高薪程序员&面试题精讲系列118之Session共享有哪些方案?
Stack-------
我花上万学带货:3天赚3元,成交靠刷单
(mixed version 1) multiple TXT text to one table
Share several tools for designing exquisite circuit diagrams