当前位置:网站首页>Mysql database master-slave synchronization, consistency solution
Mysql database master-slave synchronization, consistency solution
2022-06-29 12:24:00 【A little dog】
MySQL Database master slave synchronization , Consistency solutions
Method 1 Semi-synchronous replication
Between asynchronous replication and synchronous replication , The master database will not return to the client immediately after executing the transaction submitted by the client ,
Instead, wait until at least one receives from the library and writes to redo log in , Will return to the client , As opposed to asynchronous replication , Semi-synchronous replication improves data security
- The principle of semi synchronous replication
The transaction is finished in the main database binlog after , You need to return a received... From the library , To return to the client
Make sure that after the transaction is committed binlog Transfer to at least one slave Library
There is no guarantee that this transaction will be applied from the database binlog
advantage : Make use of database native function , Relatively simple
shortcoming : The write request latency of the main library will increase , Throughput will decrease
Method 2 database middleware
- All read / write requests go through the database middleware , Usually, write requests go to the main database , Read request from library
Record all routes to the write library key, If in the window of master-slave synchronization ( hypothesis 500ms), There's a read request coming ,
At this time, the slave database may be old data , You need to key Read requests on are routed to the main database access
After the master-slave synchronization time is over , Corresponding key Read requests continue to be routed to the slave library
advantage : Can guarantee absolute consistency ,
shortcoming : The cost of database middleware is high
Method 3 Cache record write key Law
- Write requests
If key To write , It was recorded that cache in , Set the cache timeout for master-slave synchronization , such as 500ms
Then modify the master database
Read request
Check the cache first , Corresponding key There's no data
If there is , Description cache hits , This key A write operation has just occurred , At this point, you need to route the request to the main database to read the latest data
without , Description cache misses , Illustrate this key There has been no write operation recently , At this point, the request is routed to the slave Library , Continue read write separation
advantage : Relative to database middleware , Lower cost
shortcoming : To ensure consistency , Introduced cache Components , And when reading and writing the database, there are more cache operations
Please correct me if there is any mistake
边栏推荐
- 在校生的编程故事
- Interview shock 61: tell me about MySQL transaction isolation level?
- 模糊图片变清晰,一键双色图片,快速整理本地图片...这8个在线图片工具申请加入你的收藏夹!
- ArtBench:第一个类平衡的、高质量的、干净注释的和标准化的艺术品生成数据集
- GBase8s数据库INTO table 子句
- Gbase8s database into temp clause creates a temporary table to save query results.
- 百度云盘不限速下载大文件(2021-11亲测有效)
- 如何查看网站已经保存的密码
- 【JUC系列】同步工具类之ThreadLocal
- MySQL 主从复制原理以及流程
猜你喜欢
![[leetcode] 14. Longest public prefix](/img/3b/3388ce8382ad5caaaf0a42488da2f9.png)
[leetcode] 14. Longest public prefix

助力极致体验,火山引擎边缘计算最佳实践

亲测!Centos7部署PHP + Swoole

【LeetCode】14、最长公共前缀

什么是外链和内链?

《高难度谈话》突破谈话瓶颈,实现完美沟通

An interpretable geometric depth learning model for structure based protein binding site prediction

高校如何基于云原生构建面向未来的智慧校园?全栈云原生架构VS传统IT架构

Kyligence Zen, an intelligent indicator driven management and decision-making platform, is newly launched and is in limited internal testing

Unified exception reporting practice based on bytecode
随机推荐
Titanium dynamic technology: our Zadig landing Road
这个EMR-SparkSQL节点,他查询的表是不是ODPS的啊?
Codeforces Round #803 (Div. 2)
GBase8s数据库select有ORDER BY 子句
Numpy's ndarray array Foundation
Gbase8s database select has a having clause
Gbase8s database into table clause
力扣每日一题-第31天-1779.找到最近的有相同x或y坐标的点
Unified exception reporting practice based on bytecode
Imile uses Zadig's multi cloud environment to deploy thousands of times a week to continuously deliver global business across clouds and regions
How can colleges and universities build future oriented smart campus based on cloud native? Full stack cloud native architecture vs traditional IT architecture
揭秘百度智能测试在测试自动执行领域实践
How to view saved passwords of websites
Helping the ultimate experience, best practice of volcano engine edge computing
Installation and configuration of MariaDB
Matlab GUI realizes the function of clicking the button, opening the file dialog box and importing pictures
Li Kou daily question - day 31 -13 Maximum perimeter of triangle
ERP编制物料清单 金蝶
How to install oracle19c in Centos8
Jerry's about TWS pairing mode configuration [chapter]