Logo
Data Sharding

Data Sharding #

Scenarios

In the context of the current Internet era, business data shows a rapid growth trend. In the case of the storage and access of massive data, there are many problems in the solution of single node storage of traditional relational database. It is difficult to meet the scenario of massive data in terms of performance, availability and operation and maintenance cost. Data sharding can split the data in a single database into multiple databases or tables according to a certain dimension, so as to improve performance and availability.

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-sharding.yaml

rules:
- !SHARDING
  tables: 
    t_order: 
      databaseStrategy: 
        standard: 
          shardingColumn: user_id
          shardingAlgorithmName: database_inline
      tableStrategy:
        standard: 
          shardingColumn: order_id
          shardingAlgorithmName: table_inline

  shardingAlgorithms:
    database_inline:
      type: INLINE
      props:
        algorithm-expression: ds_${user_id % 2}
    table_inline:
      type: INLINE
      props:
        algorithm-expression: t_order_${order_id % 2}

Relevant Reference

Sharding