Author Chen Caihua article reprint exchange please contact [email protected]Copy the code

Recently, I learned the architecture design of ali’s senior technical expert Li Yunhua’s tutorial on sub-database and sub-table. I gained a lot and summarized it.

This paper mainly introduces the theory, basic architecture, complexity and common solutions of high performance database cluster.

Overview of sub-database and sub-table

Read/write separation Disperses the read/write operation pressure of the database, and disperses the storage pressure of the database and tables

Applicable scenario

Similar to read and write separation, separate database and table is an optimization scheme to be adopted after confirming that there is no other optimization space. So if the business is really growing fast, isn’t it going to be very soon? So why not design it from the start?

According to the “three principles” of architectural design (simplicity, suitability and evolution), a brief analysis is made:

First of all, the “if” here is actually a relatively low probability, do 10 business can survive a very good business, let alone rapid development, and the probability of winning the lottery. If we do architecture design in accordance with the scale of Taobao and wechat for each business, we will not only kill ourselves, but also kill our business.

Secondly, if the business really develops very quickly, it is not too late to carry out sub-database sub-table. Because the business develops well, the corresponding resource investment will increase, and more people and more money can be invested. Then the code and business complexity caused by the business branch library can be solved by adding people, and the cost problem can also be solved by increasing capital.

Business depots

A business table

Service table overview

Problems brought about

The vertical table

Increase the number of table operations

The level of table

  • Routing problem

  • Database operation problems

Implementation method

Similar to read and write separation, the specific implementation is also “program code encapsulation” and “middleware encapsulation”, but the specific implementation is more complex, because there are still to determine the table of specific operations in SQL, specific operations (such as count, order BY, group by, etc.), according to the specific operation to do different processing.

reference

Learn architecture from 0 — Li Yunhua

A Brief Discussion on High-performance Database Cluster — Read-write separation — Chen Caihua

Preliminary Study on architecture Design Method — Chen Caihua

Separate database and table, master and slave, Read and write Separation