Ali P8 architects talk: database schema design of vertical, 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:

 

The first step: a distributed cache redis, memcached and so reduce the read operation of the database. Step 2: If after using caching, database access is still very large amount, consider a database read and write separation principle. 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 advantages: 1. Split the service clear clear split rule. 2. integrate or expand easily between systems. 3. Data maintenance is simple. Disadvantages: 1 part of the business table 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 .

 

Split level, in short, usually the first sub-libraries, if the sub-database queries still slow, so in accordance with the idea of ​​sub-library sub-table started work distributed database using database (data from all nodes together are considered the overall data), file the system uses any powerful single-server distributed file systems can not meet the continued growth in large-scale systems business requirements, database read and write separation with business development eventually will be unable to meet demand, require the use of distributed database and distributed file system support .

 

Summary, database split principles:

 

 

 

1. give priority to reducing the cache read operation of the database.

 

2. consider separate read and write, the write operation to reduce database.

 

3. Finally start data split, the split mode: First, a vertical (longitudinal) split, horizontal split again.

 

4. Consider first vertical split according to the service.

 

The horizontal resolution consider: first sub-libraries (data routing rules provided, the data assigned to the different libraries)

 

6. Finally, consider sub-table, to split the data within a single table 10 million.

 

Excellent knowledge Institute (youzhixueyuan.com) IT human promotion and pay rise Advanced station, BAT director experience sharing platform. Share BAT: interview subject, architect, CTO advanced dry!

Guess you like

Origin blog.csdn.net/winnershili/article/details/90691048