Cluster database load balancing method and device

By obtaining the available node information of the distributed database and adjusting the number of tasks according to the load, the problem of load imbalance after the data node is damaged in the distributed database cluster is solved, and load balancing and query efficiency are improved.

WO2024192872A1PCT designated stage expired Publication Date: 2024-09-26TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/095536
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-23
Filing Date
2023-05-22
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

In a distributed database cluster, when a data node is damaged, the query load easily becomes unbalanced, causing the number of CPU tasks and memory load on some nodes to double, increasing the pressure of read operations for data swapping in and out, and affecting query efficiency.

Method used

By obtaining the available data node information of the cluster database, the data execution plan is generated according to the user's query statement, and the number of tasks is adjusted according to the load of each available data node, and the multi-part sharding circular backup method is used to increase and decrease the number of tasks. Achieve load balancing.

Benefits of technology

When a data node is damaged, the task allocation is adjusted to achieve balanced load distribution, improve data query efficiency, avoid overloading of a single node, and ensure system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023095536_26092024_PF_FP
    Figure CN2023095536_26092024_PF_FP
Patent Text Reader

Abstract

The present application provides a cluster database load balancing method, comprising: obtaining available data node information of a cluster database; delivering, according to the available data node information, a data execution plan generated by each coordination point in the cluster database, according to a query statement of a user, to each available data node comprising: the coordination point determining a load status of each available data node according to the execution plan sent to each available data node; and determining, according to the load status, a quantity of tasks comprised in the execution plan delivered to each available data node. In the present application, a task is delivered according to different quantities of tasks of each data node. When the data node is damaged, load balancing of the data node can be implemented, and data query efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Cluster database load balancing method and device Technical Field

[0001] The present application relates to the field of distributed data query, and in particular to a cluster database load balancing method and a cluster database load balancing device. Background Art

[0002] Distributed databases are characterized by high availability, which is typically achieved through multiple replica shards. For example, when storing data, the data is divided into n primary shards, each of which is stored on a different data node. For each primary shard, one or more replica shards are prepared, each stored on a different data node from the primary shard. This prevents the replica shards from becoming unusable if a data node fails. When the cluster is functioning properly, queries can usually be satisfied using only the primary shard. The replica shards only need to synchronize data writes and keep the data consistent with the primary shard.

[0003] However, when a data node is damaged, the query statement needs to be calculated using the replica shard, which can easily lead to an unbalanced load on the data nodes.

[0004] For example, the cluster data shards are distributed as follows (the first shard is the primary shard and the second shard is the secondary shard):

[0005] Assuming node3 is damaged, the remaining nodes are as follows:

[0006] The current execution plan delivery logic: If the primary shard of shard 3 is damaged, each time it is sent to node 2 where the backup shard is located, the number of tasks on node 2 will double, which may become a bottleneck:

[0007] As can be seen from the above table, in the existing technology, when one or more data nodes in a distributed data cluster are damaged, the following problems may occur:

[0008] 1. The number of CPU tasks on one or more data nodes is doubled; the memory is doubled or increased as needed. If the cache is small, a large amount of data will be swapped in and out, increasing the pressure on reading data.

[0009] 2. The read data load of one or more data nodes will double, and the read operations due to data swapping in and out will also increase.

[0010] Summary of the Invention

[0011] The purpose of this application is to overcome the defects in the prior art and provide a cluster database load balancing method. This application also relates to a cluster database load balancing device.

[0012] This application provides a cluster database load balancing method, including:

[0013] Get the available data node information of the cluster database;

[0014] According to the available data node information, the data execution plan generated by each coordination point of the cluster database according to the user's query statement is distributed to each of the available data nodes, including:

[0015] The coordination point determines the load condition of each available data node according to the execution plan sent to each available data node;

[0016] The number of tasks included in the execution plan sent by each of the available data nodes is determined according to the load situation.

[0017] Optionally, determining the load of each available data node includes:

[0018] Based on the cyclic backup of multiple replica shards of the primary data shard, the coordination point records the number of tasks sent to each of the available data nodes.

[0019] Optionally, the multi-shard cyclic backup includes:

[0020] The number of tasks for each data node increases after each task is delivered, and the number of tasks for each available data node decreases after the task delivery is completed.

[0021] Optionally, in the multi-shard cyclic backup, the primary shards in any two of the data nodes or the secondary shards in any two of the data nodes are different.

[0022] Optionally, the execution plan includes: a query statement or a physical plan.

[0023] The present application also provides a cluster database load balancing device, comprising:

[0024] Collection module, used to obtain information about available data nodes in the cluster database;

[0025] A planning module is configured to distribute a data execution plan generated by each coordination point of the cluster database according to a user's query statement to each of the available data nodes based on the available data node information, including:

[0026] The coordination point determines the load condition of each available data node according to the execution plan sent to each available data node;

[0027] The number of tasks included in the execution plan sent by each of the available data nodes is determined according to the load situation.

[0028] Optionally, the planning module includes:

[0029] A determination unit, configured to determine the load condition of each available data node, comprising:

[0030] Based on the cyclic backup of multiple replica shards of the primary data shard, the coordination point records the number of tasks sent to each of the available data nodes.

[0031] Optionally, the multi-shard cyclic backup includes:

[0032] The number of tasks for each data node increases after each task is delivered, and the number of tasks for each available data node decreases after the task delivery is completed.

[0033] Optionally, in the multi-shard cyclic backup, the primary shards in any two of the data nodes or the secondary shards in any two of the data nodes are different.

[0034] Optionally, the execution plan includes: a query statement or a physical plan.

[0035] Advantages and benefits of this application:

[0036] The present application provides a cluster database load balancing method, comprising: obtaining available data node information of the cluster database; based on the available data node information, sending a data execution plan generated by each coordination point of the cluster database according to a user's query statement to each of the available data nodes, including: the coordination point judging the load condition of each available data node based on the execution plan sent to each of the available data nodes; and determining the number of tasks included in the execution plan sent to each of the available data nodes based on the load condition. By sending tasks based on the different number of tasks for each data node, the present application can achieve load balancing of data nodes and improve data query efficiency when a data node is damaged. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] FIG1 is a schematic diagram of the cluster database load balancing process in this application.

[0038] FIG2 is a schematic diagram of a cluster database load balancing device in this application. DETAILED DESCRIPTION

[0039] The present application is further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present application and implement it.

[0040] The following contents are all examples of specific implementation processes provided for detailed description of the technical solutions to be protected by this application. However, this application can also be implemented in other ways different from the descriptions herein. Those skilled in the art can, under the guidance of the concept of this application, use different technologies to implement this application. Therefore, this application is not limited to the specific embodiments below.

[0041] The present application provides a cluster database load balancing method, comprising: obtaining available data node information of the cluster database; based on the available data node information, sending a data execution plan generated by each coordination point of the cluster database according to a user's query statement to each of the available data nodes, including: the coordination point judging the load condition of each available data node based on the execution plan sent to each of the available data nodes; and determining the number of tasks included in the execution plan sent to each of the available data nodes based on the load condition. By sending tasks based on the different number of tasks for each data node, the present application can achieve load balancing of data nodes and improve data query efficiency when a data node is damaged.

[0042] FIG1 is a schematic diagram of the cluster database load balancing process in this application.

[0043] As shown in FIG1 , S101 obtains information about available data nodes of a cluster database;

[0044] The cluster database mentioned in this application refers to a distributed database. The distributed database (DDB) is a physically dispersed and logically centralized database system, which is a product of the combination of database technology and network.

[0045] The distributed database is equipped with multiple data nodes, each of which has the ability to independently process data tasks and is connected to each other through a network. Therefore, each data node in the distributed database processes data independently, but the distributed database composed of all data nodes is centrally managed.

[0046] In the present application, the data node is connected to one or more coordination points, and one of the coordination point functions is used to send an execution plan to the data node.

[0047] In the distributed database, there are two control types: centralized global control and decentralized global control. Centralized global control means distributed control is centralized on a single node, while decentralized global control means distributed control is distributed across various nodes. The nodes described as centralized on a single node or decentralized across various nodes are referred to as coordination points in this application.

[0048] In a distributed database, data throughput is very large, and a single data node can hardly support such a large data throughput, so the data needs to be split and stored on various data nodes. In this application, the data splitting is described as dividing the data into multiple primary shards.

[0049] One of the most important issues that distributed databases need to consider is the query problem. The dispersed stored data needs to be mapped to each data node through high-level queries, and finally the data is aggregated through the network to complete the query results. Since each data node is physically separated, it is necessary to obtain the available status of each data node in real time.

[0050] In the present application, the distributed database maintains the available status of each data node through the set consistency storage service, obtains the available status of each data node through the consistency storage service, and further obtains the available data node information.

[0051] As shown in FIG. 1 , in S102 , based on the available data node information, each coordination point of the cluster database sends a data execution plan generated according to the user's query statement to each of the available data nodes.

[0052] The coordination point is used to set the execution plan and send it to each of the data nodes. This application uses a cyclic backup method to perform data backup.

[0053] Specifically, when working with data, the data is first divided into multiple primary shards, and different primary shards are sent to different data nodes. Furthermore, the primary shard generates one or more copies, called secondary shards, and the secondary shards are stored in different data nodes from the primary shard.

[0054] The cyclic backup can be further described by Table 1:

[0055] Table 1

[0056] In Table 1, the master-slave shards are the master shards and the slave shards. As can be seen from Table 1, the characteristic of the cyclic backup is that the data shards in each data node are inconsistent.

[0057] Therefore, one way of the cyclic backup is that when data node 1 stores the first primary shard, it backs up the second secondary shard, and when data node 2 stores the second primary shard, it backs up the third secondary shard. Therefore, it can be expressed as follows:

[0058] Primary shard number = i

[0059] Secondary shard number = i + 1

[0060] Here, i represents the number of the data node, i∈(1,n), and when i=n, ​​the secondary shard=1.

[0061] When tasks are issued, the coordination point allocates them based on the characteristics of the cyclic backup to achieve load balancing. Specifically, based on the cyclic backup of multiple replicas of the primary data shard, the coordination point records the number of tasks issued to each available data node. The number of tasks per data node increases after each task is issued, and decreases after the task is issued. In other words, data input requires separate input to the primary and backup shards. When data is output, if no data nodes are damaged, the primary shard in each data node can be directly read.

[0062] The execution plan is sent to each of the available data nodes, including:

[0063] S103: The coordination point determines the load condition of each available data node according to the execution plan sent to each available data node.

[0064] S104 determines the number of tasks included in the execution plan sent by each of the available data nodes according to the load situation.

[0065] Specifically, under normal circumstances, the load of the data nodes is relatively balanced, but if a data node is damaged, the load is no longer balanced.

[0066] Based on this, the balancing method set in this application is to increase the number of tasks in a cyclic manner based on cyclic backup. Table 2 can show the process of the coordination point issuing tasks in this application:

[0067] Table 2

[0068] As can be seen from Table 2, the coordination point issued twice as many tasks to the second data node in SQL1, so it was judged that its load was large. In SQL2, no tasks were added to the second data node, but to the first data node. In SQL3, no tasks were added to the first and second data nodes, but to the third data node.

[0069] Calculation shows that the number of tasks for the first data node is 1+2+1=4, the number of tasks for the second data node is 2+1+1=4, and the number of tasks for the fourth data node is 1+1+2=4. This shows that the number of tasks for the damaged third node is evenly distributed among the first, second, and fourth data nodes, so the load is balanced.

[0070] When one node is damaged, load balancing can be achieved by adjusting which nodes the load is sent to. When multiple nodes are damaged, although complete balancing may not be achieved, partial adjustment can be achieved.

[0071] The present application also provides a cluster database load balancing device, which specifically includes a collection module and a planning module.

[0072] FIG2 is a schematic diagram of a cluster database load balancing device in this application.

[0073] As shown in FIG2 , the collection module 201 is used to obtain information about available data nodes in the cluster database;

[0074] The cluster database mentioned in this application refers to a distributed database. The distributed database (DDB) is a physically dispersed and logically centralized database system, which is a product of the combination of database technology and network.

[0075] The distributed database is equipped with multiple data nodes, each of which has the ability to independently process data tasks and is connected to each other through a network. Therefore, each data node in the distributed database processes data independently, but the distributed database composed of all data nodes is centrally managed.

[0076] In the present application, the data node is connected to one or more coordination points, and one of the coordination point functions is used to send an execution plan to the data node.

[0077] In the distributed database, there are two control types: centralized global control and decentralized global control. Centralized global control means distributed control is centralized on a single node, while decentralized global control means distributed control is distributed across various nodes. The nodes described as centralized on a single node or decentralized across various nodes are referred to as coordination points in this application.

[0078] In a distributed database, data throughput is very large, and a single data node can hardly support such a large data throughput, so the data needs to be split and stored on various data nodes. In this application, the data splitting is described as dividing the data into multiple primary shards.

[0079] One of the most important issues that distributed databases need to consider is the query problem. The dispersed stored data needs to be mapped to each data node through high-level queries, and finally the data is aggregated through the network to complete the query results. Since each data node is physically separated, it is necessary to obtain the available status of each data node in real time.

[0080] In the present application, the distributed database maintains the available status of each data node through the set consistency storage service, obtains the available status of each data node through the consistency storage service, and further obtains the available data node information.

[0081] As shown in FIG. 2 , the planning module 202 is configured to distribute the data execution plan generated by each coordination point of the cluster database according to the user's query statement to each of the available data nodes based on the available data node information.

[0082] The coordination point is used to set the execution plan and send it to each of the data nodes. This application uses a cyclic backup method to perform data backup.

[0083] Specifically, when working with data, the data is first divided into multiple primary shards, and different primary shards are sent to different data nodes. Furthermore, the primary shard generates one or more copies, called secondary shards, and the secondary shards are stored on different data nodes from the primary shard.

[0084] The cyclic backup can be further described by Table 1:

[0085] Table 1

[0086] In Table 1, the master-slave shards are the master shards and the slave shards. As can be seen from Table 1, the characteristic of the cyclic backup is that the data shards in each data node are inconsistent.

[0087] Therefore, one way of the cyclic backup is that when data node 1 stores the first primary shard, it backs up the second primary shard, and when data node 2 stores the second primary shard, it backs up the third primary shard. This can be expressed by the following formula:

[0088] Primary shard number = i

[0089] Secondary shard number = i + 1

[0090] Here, i represents the number of the data node, i∈(1,n), and when i=n, ​​the secondary shard=1.

[0091] When dispatching tasks, the coordination point allocates tasks based on the characteristics of the cyclic backup to achieve load balancing. Specifically, based on the cyclic backup of multiple replicas of the primary data shard, the coordination point records the number of tasks dispatched to each available data node. After each task dispatch, the task count for each data node is increased, and after the task dispatch is complete, the task count for each available data node is decreased. In other words, data input must be entered separately into the primary and backup shards. When data is output, if no data nodes are damaged, the primary shard in each data node can be directly read.

[0092] The execution plan is sent to each of the available data nodes, including:

[0093] The coordination point determines the load condition of each available data node according to the execution plan sent to each available data node.

[0094] The number of tasks included in the execution plan sent by each of the available data nodes is determined according to the load situation.

[0095] Specifically, under normal circumstances, the load of the data nodes is relatively balanced, but if a data node is damaged, the load is no longer balanced.

[0096] Based on this, the balancing method set in this application is to increase the number of tasks in a cyclic manner based on cyclic backup. Table 2 can show the process of the coordination point issuing tasks in this application:

[0097] Table 2

[0098] As can be seen from Table 2, the coordination point issued twice as many tasks to the second data node in SQL1, so it was judged that its load was large. In SQL2, no tasks were added to the second data node, but to the first data node. In SQL3, no tasks were added to the first and second data nodes, but to the third data node.

[0099] Calculation shows that the number of tasks for the first data node is 1+2+1=4, the number of tasks for the second data node is 2+1+1=4, and the number of tasks for the fourth data node is 1+1+2=4. This shows that the number of tasks for the damaged third node is evenly distributed among the first, second, and fourth data nodes, so the load is balanced.

[0100] When one node is damaged, load balancing can be achieved by adjusting which nodes the load is sent to. When multiple nodes are damaged, although complete balancing may not be achieved, partial adjustment can be achieved.

[0101] This application combines the characteristics of cyclic backup with the new execution plan distribution method set in the coordination point, so that when one or more data nodes of a distributed database are damaged, the load of the damaged data node can be evenly distributed to other data nodes to the greatest extent possible, thereby achieving the effect of balancing the load of data nodes and increasing the working efficiency of the distributed data system.

Claims

1. A cluster database load balancing method, characterized in that: include: Get the available data node information of the cluster database; According to the available data node information, the data execution plan generated by each coordination point of the cluster database according to the user's query statement is sent to each of the available data nodes, including: The coordination point determines the load condition of each available data node according to the execution plan sent to each of the available data nodes; The number of tasks included in the execution plan sent by each of the available data nodes is determined according to the load condition.

2. The cluster database load balancing method according to claim 1, characterized in that: Determining the load condition of each available data node includes: Based on the cyclic backup of multiple replica shards of the primary data shard, the coordination point records the number of tasks sent to each of the available data nodes.

3. The cluster database load balancing method according to claim 2, characterized in that: The multi-shard cyclic backup includes: The number of tasks for each data node increases after each task is delivered, and the number of tasks for each available data node decreases after the task is delivered.

4. The cluster database load balancing method according to claim 3, characterized in that: In the multi-shard circular backup, the primary shards in any two of the data nodes or the secondary shards in any two of the data nodes are different.

5. The cluster database load balancing method according to any one of claims 1 to 4, characterized in that: The execution plan includes: a query statement or a physical plan.

6. A cluster database load balancing device, characterized in that: include: The collection module is used to obtain the available data node information of the cluster database; A planning module is used to send a data execution plan generated by each coordination point of the cluster database according to the user's query statement to each of the available data nodes according to the available data node information, including: The coordination point determines the load condition of each available data node according to the execution plan sent to each of the available data nodes; The number of tasks included in the execution plan sent by each of the available data nodes is determined according to the load condition.

7. The cluster database load balancing device according to claim 6, characterized in that: The planning module includes: A judging unit, used for judging the load condition of each available data node, includes: Based on the cyclic backup of multiple replica shards of the primary data shard, the coordination point records the number of tasks sent to each of the available data nodes.

8. The cluster database load balancing device according to claim 7, characterized in that: The multi-shard cyclic backup includes: The number of tasks for each data node increases after each task is delivered, and the number of tasks for each available data node decreases after the task is delivered.

9. The cluster database load balancing device according to claim 8, characterized in that: In the multi-shard circular backup, the primary shards in any two of the data nodes or the secondary shards in any two of the data nodes are different.

10. The cluster database load balancing device according to any one of claims 6 to 9, characterized in that: The execution plan includes: a query statement or a physical plan.

Citation Information

Patent Citations

  • A database fragmentation execution method based on container resource allocation

    CN109271409A

  • Distributed database query segmentation method and device

    CN115718773A

  • Cluster database load balancing method and device

    CN115994037A

  • Dynamic self-reconfiguration of nodes in a processing pipeline

    US20180329956A1