Logo
Read/Write Splitting

Read/Write Splitting #

Scenarios

With the growth of business volume, many applications will encounter the bottleneck of database throughput. It is difficult for a single database to carry a large number of concurrent queries and modifications. Currently, the database cluster with primary-secondary configuration has become an effective scheme. Primary-secondary configuration, that is, the master database is responsible for transactional operations such as data writing, modification and deletion, and the slave database is responsible for the database architecture of query operation. The database with master-slave configuration can limit the row lock brought by write operation to the master database, and support a large number of queries through the slave database, so as to greatly improve the performance of the application. In addition, the multi master and multi slave database configuration can be adopted to ensure that the system is still available even if the data node is down or even in the case of physical damage to the database.

The read/write splitting can seprately route query and write operations of different users to diffrent databases, so as to improve the read and write performance of the database. Read write splitting supports load balancing strategy, which can distribute requests evenly to different database nodes.

Prerequisites

Take DBPlusEngine-Proxy as an example, download and unzip the proxy, refer to the following configuration, configure the corresponding configuration file in the conf directory, and then start the proxy.

Configuration Example

config-readwrite-splitting.yaml

rules:
- !READWRITE_SPLITTING
  dataSources:
    pr_ds:
      writeDataSourceName: write_ds
      readDataSourceNames: [read_ds_0, read_ds_1]
      loadBalancerName: weight_lb
  loadBalancers:
    weight_lb:
      type: WEIGHT
      props:
        read_ds_0: 2
        read_ds_1: 1

Relevant Reference

Readwrite-splitting