当前位置:网站首页>MySQL cache strategy and solution
MySQL cache strategy and solution
2022-07-19 05:22:00 【HjasnJH】
mysql Master-slave replication of

1、 Main library Master node , Accept additions from the client 、 Delete 、 Change request , adopt IO-thread Write to binlog
2、 Slave Library slave node , Request to read the binlog, adopt IO-thread Write local relay log( relay logs )
3、 Pass through the library sql-thread Read relay-log, And implement the additions, deletions and modifications .
mysql Separation of reading and writing

among , Read by reading from the node , Writes are written through the master node and synchronized to the slave node , Read and write separation is achieved
Why mysql Caching scheme for ?
1、 Read more and write less , The access speed of memory is the same as that of disk 10 ten thousandfold ( Order of magnitude magnification ), Memory access speed ⼤ About 100ns,⽽⼀ Secondary disk access ⼤ About 10ms; visit mysql The number of times the disk is accessed during is the same as b+ Treelike ⾼ Degree correlation ;
2. ⼀ like ⼤ Some items ⽬ in , Database read operations are write operations 10 About times ;
The buffer layer plays a good role in improving the reading performance
Cache layer scheme
Use hot data redis Cache and backup the database , Transfer hot read operations to the cache database
It can solve the problem of reading performance .
The cache layer is introduced , How to solve the problem of consistency ?
From the following situations :
1、mysql No, , The cache has
2、mysql Yes , The cache has , But inconsistent
3、mysql Yes , The cache does not
According to business scenarios , Look at our requirements for consistency :
The final consistency solution
If the project wants to achieve final consistency , Our solutions :
read : Read cache first , Cache has return , If not, read mysql, To write redis
Write :1、 direct writing mysql, wait for mysql Synchronize to redis
2、 Write cache first redis, Set timeout , To write mysql, Final mysql Synchronize to redis.
Strong consistency solutions
read : Read cache first , There is a direct return to the cache , Cache does not exist , visit mysql obtain , To write redis
Write : So let's delete the cache , To write mysql, wait for mysql Synchronize to cache .
The plan above , Assume :mysql The final data source .
Synchronization scheme

git clone https://gitee.com/mirrors/go-mysql-transfer.gitgo-mysql-transfer Realize to mysql Data synchronization to redis
边栏推荐
- Opendds QoS and custom QoS (timing, timingqospolicy)
- What are the B domain, m domain and O domain
- 第一个智能合约程序Faucet.sol
- Redis 源码分析-数据结构及实现(字典dict)
- How to deal with the mismatch between subtitle files and video files
- Three methods for cesium to obtain the longitude and latitude at the mouse click
- Submit the uniapp form (input, radio, picker) to get the parameter value
- es6新增-函数部分
- Flex flexible layout
- Cesium 获取鼠标点击处经纬度的三种方法
猜你喜欢
![[AI] action recognition using simple neural network -- Based on coco key points](/img/67/cd6be6e070fb5d4d44ee043ebd7fac.png)
[AI] action recognition using simple neural network -- Based on coco key points

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

ArcGIS point cloud (XYZ) data to DEM

Wechat applet cloud development and use method-1

ArcGIS 点云(xyz)数据转DEM

Beginner's Guide to learning penetration testing

字幕文件与视频文件对不上的处理方式

微信小程序5-基础加强(没写完)

Router loopback port experiment

Buuctf miscellaneous - QR code
随机推荐
Ucharts chart, pie chart, bar chart and line chart are used in uniapp
web3js开发技术
MapBox 加载本地离线地形
H5页面使用js生成二维码
Redis source code analysis - data structure and Implementation (Dictionary dict)
云服务器部署WEB项目
Cesium BIND Mouse Events and remove Mouse Events
Buuctf miscellaneous - QR code
Markdown notes and related shortcut keys of typora
Pat class B 1017: a divided by B
Web3js development technology
Use echars to realize water drop, ring, segmentation, stacking, organization chart, map outline and other charts
【AI】利用简单神经网络做动作识别——基于coco关键点
Flex flexible layout
Switch user mode, privileged mode, global mode, port mode
Redis source code analysis 3 implementation of discontinuous traversal
Flex弹性布局
mysql的锁
<script>标签内容详解
STL container -- basic operation of map