Database horizontal scaling and vertical scaling
in Internet applications, databases are often the common medium in which we store and access data. With the increase of load, the requirement of database read and write performance is often a big challenge. In this case, we can consider the database-related replication mechanism to improve the performance of read and write. Due to the general use of a write-and-read replication mechanism (write master synchronization to multiple slaves), this mechanism is often flawed. First of all, it relies on the ratio of read and write, if there are too many operations, the master often becomes the bottleneck of performance, which makes the data synchronization delay of the slaves become larger, thus greatly consumes the CPU resources, and causes inconsistent data to affect the user's experience.
This time we should consider the use of the Database sharding (shard) mechanism, which we say that the sharding mechanism is not a database software ancillary functions, but a relatively simple software concept. In general, we divide the sharding mechanism into horizontal expansion (scale-out, or scale-out) and vertical expansion in two ways. Specifically what is the horizontal and vertical expansion of a database? Let's take the following example to illustrate this.
For example, we now have two tables: User Information table product order Form
The horizontal split scheme, that is, does not modify the database table structure, by splitting the data in the table to achieve the purpose of sharding:
1) Use User ID to do hash, decompose database, use User ID in accessing database to do route.
2) The Product order form is divided into two tables according to the placed and not placed orders.
General Horizontal split the union operation may be used when querying the database.
Vertical split Scenario: detach the table and table, or modify the table structure to split some columns according to the difference in Access.
1) Place the user Information table in a database server and place the product order table in a database server.
2) The main code in the User Information table (usually the user ID) and some common information into a table, the main code and the less commonly used information to the other table, which leads to the general query data may be used when the join operation.
In the design of the database, we focus more on the ability of the database to scale horizontally.
Horizontal and vertical scaling of databases