当前位置:网站首页>MySQL cache solution problem solving
MySQL cache solution problem solving
2022-07-19 05:22:00 【HjasnJH】
As mentioned earlier mysql Caching scheme for , Put the reading pressure on redis
Under normal circumstances , There is absolutely no problem with the cooperation between the two
Cache penetration
Suppose a data redis non-existent , mysql There is no such thing as ,⽽ And ⼀ Try to read straight ? Cache penetration , The data is finally compressed ⼒
Still piled up in mysql, May cause mysql Overwhelmed ⽽ collapse ;
solve
1. Find out mysql non-existent , take redis Set to <key, nil> Set expiration time Next visit key When No longer visit
mysql Easy to cause redis Cache a lot ⽆ Effective data ;
2. The bloon filter , take mysql Which already exists key, Write ⼊ The bloon filter , Nonexistent direct pass fall ;
Cache breakdown
Cache breakdown Some data redis No, , however mysql Yes ; At the moment when ⼤ Concurrent requests for such data , It also causes mysql
too ⼤;
solve
1. Lock
Get the lock when requesting data , If successful , Operation , Acquisition failure , Then sleep ⼀ Period of time (200ms) Get it again
take ; To be successful , Then release the lock
⾸ First reading redis, non-existent , read mysql, There is , Write redis key Lock of
The whole process ⾛ End , Just let me ⾯ Server access
2. It will be very hot key, Set not to expire
Cache avalanche
Express ⼀ For a while , Cache set failure (redis⽆ mysql Yes ), Cause all requests to ⾛mysql, It's possible to bring down the database ,
Disable the entire service ;
solve
1. If the cache database goes down , Cause all data to flow to mysql;
Mining ⽤⾼ can ⽤ The cluster of ⽅ case , Like sentinel mode 、 cluster Pattern ;
2. If you set the same expiration time , Cause cache set invalidation ;
Set random expiration value or other mechanism to stagger failure ;
3. If the system restarts , Cause the cached data to disappear ;
Short restart time , redis Turn on persistence ( Expired information is also persisted ) Just ⾏ 了 ; Restart time ⻓ Guide the thermal data in advance
⼊redis among ;
边栏推荐
猜你喜欢

使用Echars实现水滴状、环形图、分割图、堆叠、组织架构图、地图轮廓等图表

UML(用例图,类图,对象图,包图)

Router loopback port experiment

Nacos configuration management

Installation and fast use of Mongo DB stand-alone version

redis 源码分析 动态字符串实现(sds)

Teach you to reproduce log4j2 nuclear weapon level vulnerability hand in hand

CityEngine 三维管道建模教程

基于libco的协程实现6 libcurl的同步接口的实现方案

vscode终端无法使用解决的办法
随机推荐
Cesium geojson数据的添加与移除
cookie是否有效时间限定?如何设置cookie?手把手教你设置
ArcGIS point cloud (XYZ) data to DEM
Excel导入长数据末尾变000
OpenDDS的QoS和自定义QoS(校时TimingQosPolicy)
BUUCTF 杂项——二维码
Cesium bind mouse events and remove mouse events
【Es6】详细解说Set ,Array的常用对象及其他方法(完整版)
The principle and local storage of the throttle valve of the rotation chart are summarized
[ES6] explain in detail the common objects and other methods of set and array (full version)
聊聊redis分布式锁的8大坑
ArcMap 创建常量栅格并镶嵌至新栅格
How to deal with the mismatch between subtitle files and video files
Applet cloud development upload pictures to cloud storage
2.6.2 内存泄漏
es6新增-字符串部分
Applet editor rich text editing and rich text parsing
聊聊写代码的20个反面教材
运维安全要了解的二三事
2020-11-10