当前位置:网站首页>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
边栏推荐
猜你喜欢

ArcMap creates a constant grid and tessellates it into a new grid

Applet cloud development upload pictures to cloud storage

Implementation of synchronization interface of 6 libcurl based on libco

Applet editor rich text editing and rich text parsing

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

Wechat applet cloud development and use method-1

单臂路由配置

Use echars to realize water drop, ring, segmentation, stacking, organization chart, map outline and other charts

Data visualization

第一个智能合约程序Faucet.sol
随机推荐
ECS deployment web project
线上软件测试培训机构柠檬班与iTest.AI平台达成战略合作
指针进阶简单总结
Addition and removal of cesium geojson data
Easypoi之excel模板导出
Pat class B 1002: write this number
es6新增-字符串部分
Pat class B 1017: a divided by B
The first smart contract program faucet sol
Easypoi excel simple export
2.6.2 memory leakage
Wechat applet cloud development and use method-1
Leetcode53. maximum subarray and
js 原生对象加属性
Mapbox loads local offline terrain
Two methods of obtaining URL parameters and various methods of obtaining location objects
实习项目1-个性化主页配置
基于PaddleOCR解决文本检测训练模型与inference模型预测效果不一致的问题
Data visualization
vscode终端无法使用解决的办法