当前位置:网站首页>2: Why read write separation
2: Why read write separation
2022-07-28 06:05:00 【Performer】
1: Why should the database be read and write separated
The systematic application of Internet is a Read more and write less Application , For example, in the e-commerce system , The number of product browsing is more than that of placing an order . The bearing pressure of the database is high , Mainly caused by these read requests , So can we separate the read operation from the write operation , Let all read requests fall on the database dedicated to reading , All write operations fall into the database specially responsible for writing , The data from the write library is synchronized to the read Library , This ensures that all data modifications can be read , Get... From the reading library , The architecture of the system is shown in the figure :

If the system has more read requests , Several more readers can be deployed , In this way, the read requests can be shared equally among multiple read Libraries , Reduce the pressure on each library . But when writing data , The data should fall in a certain , And the only write library . Above picture , Our writing library has only one , Of course you can deploy multiple write Libraries , But how to segment data is a very important problem , At present, only one write library is taken as an example , such as : When the merchant publishes goods , Put the data of this commodity on the write library , meanwhile , The write library synchronizes this data to two read Libraries , When buyers browse goods on the website , The commodity data will be read from the reading library , As for which library to fetch data from , It depends on the current routing of this request .
2: Advantages and disadvantages of read-write separation
advantage :
- Split a large number of read operations from the database , Let the read operation read data from a dedicated read database , It greatly relieves the access pressure of the database , It also greatly improves the response speed of data .
shortcoming :
- Data is written from to the database , To fetch from the database , The read-write separation architecture has one more synchronous operation , What is the operation time of synchronization , If the delay is too large, will it affect the system , What if the synchronization hangs ? for example : Order list page of e-commerce personal Center , The function is very simple , Just get the order data , Just show it on the page , But when you do it , Orders and order related data are retrieved from the reading library , This includes payment status , This user sensitive field . At a certain time of day , Suddenly received a large number of complaints from users , Said the user had paid , But the status of the order is still unpaid , Go to the database to query , It is found that the order status is unpaid , No problem . For the sake of insurance , Go to the warehouse and check this order , It is found that the order status of writing library is indeed paid , This is over. , The data extracted from the write library and the read library are inconsistent , The root of the problem is Synch hung up
- When synchronization hangs up , Or when the synchronization delay is relatively large , The data of write library and read library are inconsistent , This data is inconsistent , Whether the user can accept , Of course, the inconsistency of order payment status is unacceptable , Can other business scenarios be accepted ? This requires specific analysis of different business scenarios
3: Applicable scenarios of read-write separation
Some business scenarios that do not require high real-time data , Consider using read-write separation . However, scenes that require high real-time data , For example, order payment status , It is still not recommended to use read-write separation , Or when you're writing a program , Read data honestly from the write library , If you do data synchronization , Your network latency should be 5ms within , This requires a very high network environment , As you can ping Check out other machines in your network , See if you can meet this standard , If your network environment is good , Meet the requirements , Then there is no problem using read-write separation , The data is synchronized to the library in almost real time , No delay at all .
Separation of reading and writing , When you use it , We should start from the business , See if your business is suitable for using read-write separation , Each technology architecture has its own advantages and disadvantages , No good , Only suitable or not , Only an architecture suitable for business is a good architecture
边栏推荐
- Addition, deletion and modification of data processing; constraint
- mysql 触发器
- 发售预告:7月22日“大暑”发售,【传统国风廿四节气】夏季发售完毕。
- 微信小程序手机号正则校验规则
- 数字藏品成文旅产业新热点
- Flink CDC (Mysql为例)
- MySQL view, stored procedure and stored function
- 记录下在线扩容服务器遇到的问题 NOCHANGE: partition 1 is size 419428319. it cannot be grown
- Flink CDC (MySQL as an example)
- mysql视图,存储过程与存储函数
猜你喜欢
随机推荐
Distributed cluster architecture scenario optimization solution: distributed ID solution
4个角度教你选小程序开发工具?
How digital library realizes Web3.0 social networking
接口防重复提交
Assembly packaging
微信小程序开发费用制作费用是多少?
分布式集群架构场景优化解决方案:分布式调度问题
1:为什么数据库要分库分表
ModuleNotFoundError: No module named ‘pip‘
小程序制作小程序开发适合哪些企业?
Flume installation and use
mysql 触发器
Chapter 8 aggregate function
记某淘宝客软件分析拿库思路
XML parsing entity tool class
ModuleNotFoundError: No module named ‘pip‘
Two methods of covering duplicate records in tables in MySQL
MarsNFT :个人如何发行数字藏品?
如何选择小程序开发企业
Trino function tag








