Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is distributed database and the overall architecture of TIDB

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you what is the distributed database and the overall architecture of TIDB, the content is very detailed, interested friends can refer to, hope to be helpful to you.

TIDB is a distributed, strongly consistent and scalable relational database. At the beginning of TIDB design, it focuses on four key points of design.

1 horizontal expansion, horizontal expansion is the most basic requirement at the beginning of the design, by adding machines, storage and computing capabilities

2 High availability. As a distributed database, TIDB has many nodes. For node failure and database rolling upgrade, it is necessary to solve the problem of a small number of node failures.

3 ACID transactions, although some databases abandon SQL and transactions in order to store and process data more efficiently, transactions are very important in the transaction scenario in production. Another main reason is that if the problem of the transaction is not stored locally, but is solved by business or middleware, it is more difficult to be efficient.

4 SQL support, providing MYSQL support to make it easy to use the database as a whole

The following is a structure diagram of TIDB

The TIDB storage engine is a TIKV database storage engine, which is implemented with a hierarchical architecture.

1 transaction

2 MVCC

3 raft

4 local kv storage

Disaster tolerance and characteristics

Highly layered, the bottom layer is ROCKSDB, through raft to achieve high availability of data storage, the main reason for high layering is that it can switch layers more independently. Data is stored in the way of multiple copies, and strong consistency is carried out through raft. Among the multiple copies, only one leader and other nodes are follower, in which the values of leader and follower are not fixed. After the failure of leader, the role of follower will be changed to leader through the algorithm.

Raft itself supports strongly consistent multiple copies of a piece of data, how to slice distributed data and how to put different slices into different locations, which requires a slicing algorithm, slicing based on hash, or partitioning based on range, but because the database query will involve the possibility of a continuous value query, it is more reasonable to use range slicing. The storage space of KEY is segmented, mainly according to the threshold of KEY VALUE storage. The default 96MB is used for data segmentation.

The following figure shows the process of a node region from node 1 to node 4 in a multi-node.

The question is who dominates the control of the overall migration in the data migration, and the Placement Driver cluster dominates.

You can see the figure above. In addition, in the transaction model, PD's leader will provide a timestamp according to the time algorithm as the transaction label, with the overall design concept of decentralization. The design of optimistic locks before 3. 0 in TIDB does not lock data transactions, but locks them during commit. 3.0 provides pessimistic locks, similar to the lock design of traditional databases.

3 TIDB SQL engine

The following figure is an overall picture of the TIDB SQL layer.

The overall SQL processing flow, if it is calculating the COUNT, the TIDB PD learns that the data is in that region, and the region accumulates the data that meets the conditions according to the where condition, and finally each region aggregates its own sum to the TIDB SERVER and aggregates the SUM.

4. DDL is modified online, and TIDB designs the whole DDL operation according to the idea of f1-schema-change. You can refer to the following documents to sum up a few sentences.

1 give a time range to modify the DDL operation

2 in the DDL operation, each region provides two states, which can be deleted and writable.

3 the concept of lease, after the lease set in the system expires, the SCHEMA needs to be overloaded.

On what is the distributed database and the overall architecture of TIDB to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report