当前位置:网站首页>Mysql database: read write separation
Mysql database: read write separation
2022-06-29 22:44:00 【Full stack programmer webmaster】
One 、 The principle of separation of reading and writing :
1、 Realization principle :
The separation of reading and writing solves , data Library write operations , Affect the efficiency of the query , Suitable for scenarios where reading is far greater than writing . The implementation of read-write separation is based on master-slave replication , The master database uses master-slave replication to synchronize the changes of its own data to the slave database cluster , Then the master database is responsible for handling write operations ( Of course, you can also perform read operations ), From the database is responsible for processing read operations , Can't write . And according to the pressure , Deploy multiple slave databases to improve the speed of read operations , Reduce the pressure on the primary database , Improve the overall performance of the system .
2、 The reason why read-write separation improves performance :
(1) Add physical server , Load sharing ;
If we have 1 Lord 3 from , Suppose now 1 In minutes 10 The article writing ,150 Read . that ,1 Lord 3 From is equal to a total of 40 The article writing , And the total number of reads doesn't change , So on average, each server undertakes 10 Write and 50 Read ( The main library does not undertake the read operation ). therefore , Although the writing has not changed , But the read is greatly spread , Improved system performance . in addition , When the read is allocated , And indirectly improve the write performance . therefore , Overall performance improved , That is, the machine and bandwidth are exchanged for performance .
(2) The master and the slave are only responsible for their own writing and reading , A great deal of relief X Lock and S Lock contention ;
(3) Configurable from library MyISAM engine , Improve query performance and save system overhead ;
(4) Another major function of master-slave replication is to increase redundancy , Improve availability , When a database server goes down, it can restore service as fast as possible by adjusting another slave database .
3、Mysql The implementation of reading, writing and writing :
(1) Based on the internal implementation of program code :
In the code according to select 、insert Route classification , This kind of method is also the most widely used in the current production environment . The advantage is better performance , Because the program is implemented in code , There's no need to add extra hardware , The disadvantage is that it needs developers to implement , Operation and maintenance personnel have no way to start .
(2) Based on the intermediate agent layer :
The agent is generally between the application server and the database server , After receiving the request from the application server, the proxy database server forwards it to the back-end database according to the judgment , There are the following representative agent layers .
①mysql_proxy.mysql_proxy yes Mysql An open source project of , Through its own lua The script goes on sql Judge . ②Atlas. By qihoo 360, Web Platform Department infrastructure team development and maintenance based on MySQL Data middle tier project of the protocol . It's in mysql-proxy 0.8.2 Based on version , It's optimized , Added some new features .360 For internal use Atlas Running mysql Business , It carries billions of read and write requests every day . Support transactions and stored procedures . ③Amoeba. It is used by Chen Siru, an employee of Alibaba group java Language development , Alibaba group puts its users in the production environment , But it doesn't support things and stored procedures .
After the above simple comparison , Not all applications can implement read / write separation in program code , Like some big ones java application , If the separation of reading and writing is implemented in the program code, the code will be greatly changed , therefore , Applications like this generally consider using a proxy layer to implement .
Two 、 The construction of separation of reading and writing :
The steps for setting up read / write separation , You can read these two blogs :
https://blog.csdn.net/starlh35/article/details/78735510
https://blog.csdn.net/justdb/article/details/17331569
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/100074.html Link to the original text :https://javaforall.cn
边栏推荐
- 为什么在局域网(ERP服务器)共享文件夹上拷贝文件时导致全局域英特网断网
- 工业细节都是钱和时间砸出来的
- 关于深度学习的概念理解(笔记)
- qt5.14.2连接ubuntu20.04的mysql数据库出错
- 這個flink cdc可以用在做oracle到mysql的,增量同步嗎
- 英语没学好到底能不能做coder,别再纠结了先学起来
- Underlying principles of file operations (file descriptors and buffers)
- 从零实现深度学习框架——RNN从理论到实战【实战】
- If you master these 28 charts, you will no longer be afraid to be asked about TCP knowledge during the interview
- How to use filters in jfinal to monitor Druid for SQL execution?
猜你喜欢

Huawei's software testing director with 7 years' experience, several suggestions for all students who want to switch to software testing
为什么在局域网(ERP服务器)共享文件夹上拷贝文件时导致全局域英特网断网
![[multithreading] how to implement timer by yourself](/img/a9/dd9489c7a0028dd9d3a6dae9a71deb.png)
[multithreading] how to implement timer by yourself

Hezhou air32f103cbt6 development board hands-on Report

把数组排成最小的数_数组中的逆序对(归并统计法)_数字在升序数组中出现的次数_丑数(剑指offer)

Online text digit recognition list summation tool

5 - 1 Analyse de vulnérabilité du système

With the rise of China's database, Alibaba cloud lifeifei: China's cloud database has taken the lead in various mainstream technological innovations abroad

Basic use of Nacos configuration center

从零实现深度学习框架——RNN从理论到实战【实战】
随机推荐
qt5.14.2连接ubuntu20.04的mysql数据库出错
LeetCode85+105+114+124
2022 (第五届)GIS软件技术大会开幕,GIS、IT将加速融合
Kubernetes architecture that novices must know
Processing of error b6267342 reported by AIX small machine in production environment
static关键字续、继承、重写、多态
0. grpc environment setup
The details of industry are all made by money and time
5-1系统漏洞扫描
mysql备份数据库linux
Realizing deep learning framework from zero -- RNN from theory to practice [practice]
Huawei's software testing director with 7 years' experience, several suggestions for all students who want to switch to software testing
Arrange the array into the smallest number_ Reverse pairs in an array (merge Statistics)_ Number of occurrences of a number in an ascending array_ Ugly number (Sword finger offer)
Use the leader election mechanism in kubernetes to complete your own ha application
Realizing deep learning framework from zero -- LSTM from theory to practice [theory]
Conceptual understanding of deep learning (notes)
Qt5.14.2 error connecting to the MySQL database of Ubuntu 20.04
The correct method for Navicat to connect to mysql8.0 (valid for personal testing)
#第三天
26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me