Database Split: Split vertical and horizontal split six principles

 

In fact, before the split data is to first do the preparatory work, and only then began to split the data, I talk about what needs to be done before the split:

  1.  The first step: a distributed cache redis, memcached and so reduce the read operation of the database.
  2.  Step 2: If after using caching, database access is still very large amount, consider a database read and write separation principle.
  3.  The third step: When we use the separate read and write cache, the pressure is still very large database of time, which requires the use to split the database.

Split database principle: that is, refers to certain conditions, in accordance with a dimension, we will store the same data in a database stored in a plurality of databases dispersed (host) in order to achieve the above dispersion in one database (host) load .

The first step in the preferred vertical split

A database is composed of many tables, each table corresponds to a different service, the vertical segmentation refers to the table according to the service classification, the above distributed to different databases, such pressure will share data or to different library above .

For example, the mid-end database Taobao started by business vertical splits: splits on business transactions database, user database, product database, store databases.

Vertical split

advantage:

1. After the split the business a clear split rules are clear.

2. integrate or expand easily between systems.

3. Data maintenance is simple.

Disadvantages:

Table 1. The part of the business can not join, can only be resolved by way of an interface, increases the complexity of the system.

2. Each business is limited by the presence of different single database performance bottlenecks, easy to expand data with improved performance.

3. transaction processing complex.

Step two: followed by the split level

A typical scene split level is well-known sub-library sub-table.

After single bottleneck encountered vertical split, horizontal split may be used. With respect to the vertical resolution are distinguished: the vertical split is split into different tables of different databases, and the horizontal resolution is to split the same table to a different database.

Relative to the vertical split, horizontal split data tables do not classified, but according to certain rules of a field is dispersed into a plurality of banks, each table contains part of the data. In simple terms, we can cut the level of the data points are understood to be in accordance with the data line segmentation, is to cut some of the rows in the table assigned to a database, while the other cut some lines and assigned to other databases .

Sub-library sub-table routing rules need to involve SQL database corresponding to the main library prepared, for example: a TDDL Taobao designed to solve these problems, a configuration rule applied only to the corresponding side, there is no invasion of the design of the application side .

水平拆分,总之,一般先分库,如果分库后查询仍然慢,于是按照分库的思想开始做分表的工作数据库采用分布式数据库(所有节点的数据加起来才算是整体数据),文件系统采用分布式文件系统任何强大的单一服务器都满足不了大型系统持续增长的业务需求,数据库读写分离随着业务的发展最终也将无法满足需求,需要使用分布式数据库及分布式文件系统来支撑。

总结,数据库拆分原则:

阿里P8架构师谈:架构设计之数据库垂直、水平拆分六大原则

1.优先考虑缓存降低对数据库的读操作。

2.再考虑读写分离,降低数据库写操作。

3.最后开始数据拆分,切分模式: 首先垂直(纵向)拆分、再次水平拆分

4.首先考虑按照业务垂直拆分。

5.再考虑水平拆分:先分库(设置数据路由规则,把数据分配到不同的库中)

6.最后再考虑分表,单表拆分到数据1000万以内。

Guess you like

Origin www.cnblogs.com/windpoplar/p/11973205.html