A traffic control method, device and electronic equipment of a distributed database system

By dynamically adjusting the node time window capacity through the scheduler manager, the problem of insufficient task scheduling flow control in distributed database clusters is solved, achieving efficient resource utilization and system stability.

CN120030001BActive Publication Date: 2025-11-11PINGCAP XINGCHEN (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510511454.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-11-11
Estimated Expiration
2045-04-22

AI Technical Summary

Technical Problem

Existing technologies are insufficient for flow control in task scheduling within large-scale distributed database clusters, resulting in low system stability and resource utilization efficiency.

Method used

The scheduling manager dynamically adjusts the time window capacity of nodes and performs traffic control based on the waiting time and execution time of data migration tasks, avoiding node performance bottlenecks and achieving flexible traffic management.

Benefits of technology

It improves task execution efficiency, avoids resource waste and system delays, and enhances the stability and resource utilization of the distributed database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030001B_ABST
    Figure CN120030001B_ABST
Patent Text Reader

Abstract

This application provides a flow control method, apparatus, and electronic device for a distributed database system, relating to the field of distributed database technology. The method is applied to a distributed database system comprising multiple nodes and a scheduler. The method includes: when the scheduler determines that the current available capacity of the time window of the source node where the target primary shard resides is not less than the first capacity occupied by the task execution, it sends a data migration task to the source node. The source node executes the task and sends window capacity adjustment parameters, determined based on the data migration waiting time and execution time, to the scheduler. The scheduler adjusts the window capacity of the source node according to the window capacity adjustment parameters. Based on this method, dynamic adjustment of the time window capacity based on window capacity adjustment parameters is achieved, avoiding task overload on nodes and improving the flexibility of flow control and the stability of the distributed database cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and more specifically, to a flow control method, apparatus, and electronic device for a distributed database system. Background Technology

[0002] In large-scale distributed database clusters comprising multiple storage nodes, data migration between different storage nodes is a common operation, which can be achieved by transferring data snapshots between the storage nodes. Data migration consumes computing, storage, and bandwidth resources, thus requiring proper management. The storage node performing the data migration is called the data migration node.

[0003] In distributed database clusters, data migration tasks are one type of task that requires task scheduling. Task scheduling includes initiation and execution, and flow control of task scheduling helps improve the stability of large-scale distributed database clusters. However, the effectiveness of related technologies for flow control in task scheduling is still insufficient and needs improvement. Summary of the Invention

[0004] This application provides a flow control method, apparatus, electronic device, computer-readable storage medium, and computer program product for a distributed database system. To improve the flow control effect of task scheduling, the technical solution provided by this application is as follows:

[0005] According to one aspect of the embodiments of this application, a flow control method for a distributed database system is provided. The distributed database system includes multiple nodes and a scheduling manager. At least some of the multiple nodes include a primary shard, and the primary shard of each node has a corresponding secondary shard in other nodes.

[0006] The method is executed by the scheduling manager, and the method includes:

[0007] In response to meeting the data migration conditions, a data migration task is determined. Based on the amount of stored data in the target primary shard corresponding to the data migration task, a first capacity of the time window occupied by the source node where the target primary shard is located is determined. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, the current available capacity is subtracted from the first capacity, and the data migration task is sent to the source node. This allows the source node to send the data stored in the target primary shard of the source node to the destination node for synchronization based on the node identifier of the destination node carried in the data migration task. The target primary shard is the primary shard corresponding to the secondary shard in the node that meets the data migration conditions.

[0008] The source node receives window capacity adjustment parameters, which are determined by the source node based on the data migration waiting time and data migration execution time of the data migration task.

[0009] The window capacity of the time window corresponding to the source node is adjusted according to the window capacity adjustment parameters.

[0010] According to another aspect of the embodiments of this application, a flow control method for a distributed database system is provided. The distributed database system includes multiple nodes and a scheduler, and at least some of the multiple nodes include a primary shard. Each node's primary shard has a corresponding secondary shard in other nodes.

[0011] The method is executed by a first node, which is any one of the plurality of nodes, and the method includes:

[0012] In response to receiving a data migration task sent by the scheduling manager, the data stored in the target primary shard is sent to the target node for synchronization according to the node identifier of the target node carried in the data migration task;

[0013] Determine the data migration waiting time and data migration execution time for the data migration task;

[0014] The window capacity adjustment parameters are determined based on the data migration waiting time and the data migration execution time.

[0015] The window capacity adjustment parameters are sent to the scheduling manager so that the scheduling manager adjusts the window capacity of the time window corresponding to the first node according to the window capacity adjustment parameters.

[0016] The data migration task is sent by the scheduler in the following manner:

[0017] In response to the second node meeting the data migration conditions, a data migration task is determined, wherein the target primary shard is the primary shard corresponding to the secondary shard in the second node, and the source node receiving the data migration task is the first node;

[0018] Based on the amount of stored data in the target primary shard in the first node, determine the first capacity of the time window occupied by the first node for data migration;

[0019] When the current available capacity of the time window corresponding to the first node is not less than the first capacity, the data migration task is sent to the first node.

[0020] Optionally, the method further includes:

[0021] In response to receiving a successful data snapshot reception response from the destination node, a data deletion instruction is sent to the node that meets the migration conditions, based on the node identifier of the node that meets the migration conditions included in the data migration task. The data deletion instruction includes the shard identifier of the target primary shard.

[0022] According to another aspect of the embodiments of this application, a flow control method for a distributed database system is provided, the distributed database system including multiple nodes and a scheduler, at least some of the multiple nodes including a primary shard, and each node's primary shard having corresponding secondary shards in other nodes; the method includes:

[0023] The scheduling manager is used to determine the corresponding data migration task when it is determined that any node among the plurality of nodes meets the data migration conditions, and to determine the first capacity of the time window occupied by the source node where the target primary shard is located for data migration based on the amount of stored data of the target primary shard corresponding to the data migration task. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, the first capacity is subtracted from the current available capacity, and the data migration task is sent to the source node; wherein, the source node of the data migration task is the node where the target primary shard corresponding to any secondary shard among the nodes that meet the data migration conditions is located.

[0024] When the source node receives the data migration task sent by the scheduling manager, it sends the data stored in the target primary shard of the source node to the target node for synchronization according to the node identifier of the target node carried in the data migration task.

[0025] The source node is also used to determine the data migration waiting time and the data migration execution time, determine the window capacity adjustment parameters based on the data migration waiting time and the data migration execution time, and send the window capacity adjustment parameters to the scheduling manager.

[0026] The scheduling manager is also used to receive window capacity adjustment parameters sent by the source node, and adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameters.

[0027] According to another aspect of the embodiments of this application, a flow control device for a distributed database system is provided. The distributed database system includes multiple nodes and a scheduler, at least some of the multiple nodes include a primary shard, and each node's primary shard has corresponding secondary shards on other nodes. The device is applied to the scheduler, and the device includes:

[0028] A data migration module is used to determine a data migration task in response to meeting data migration conditions. Based on the amount of stored data in the target primary shard corresponding to the data migration task, it determines the first capacity of the time window occupied by the source node where the target primary shard is located for data migration. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, it subtracts the first capacity from the current available capacity and sends the data migration task to the source node. This allows the source node to send the data stored in the target primary shard of the source node to the destination node for synchronization, based on the node identifier of the destination node carried in the data migration task. The target primary shard is the primary shard corresponding to a secondary shard among the nodes that meet the data migration conditions.

[0029] The window capacity adjustment parameter receiving module is used to receive the window capacity adjustment parameters sent by the source node. The window capacity adjustment parameters are determined by the source node based on the data migration waiting time and data migration execution time of the data migration task.

[0030] The window capacity adjustment module is used to adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameters.

[0031] Optionally, the step of sending the data in the target primary shard storage of the source node to the destination node for synchronization is determined by the source node through the following method:

[0032] Generate a data snapshot of the target primary shard in the source node;

[0033] The data snapshot is sent to the destination node so that the destination node can synchronize the data stored in the target primary shard of the source node based on the data snapshot;

[0034] The data migration waiting time and data migration execution time of the data migration task are determined by the source node in the following way:

[0035] Record the first moment when the data migration task is received;

[0036] Record the second moment at which the data snapshot of the target primary shard in the source node begins to be generated;

[0037] The time difference between the second moment and the first moment is determined as the data migration waiting time;

[0038] Record the third moment of receiving a snapshot of the data sent by the destination node and the successful response;

[0039] The time difference between the third moment and the second moment is determined as the data migration execution time.

[0040] Optionally, the window capacity adjustment parameter is the difference between the data migration waiting time and the data migration execution time;

[0041] The window capacity adjustment module can be used to increase the window capacity of the time window corresponding to the source node when the window capacity adjustment parameter is positive, and to decrease the window capacity of the time window corresponding to the source node when the window capacity adjustment parameter is negative.

[0042] Optionally, the window capacity of the time window corresponding to each of the plurality of nodes includes capacities with at least two priorities;

[0043] The current available capacity of the time window corresponding to the source node is determined by the data migration module in the following way: determining the target priority of the data migration task; and taking the available capacity of the window capacity of the time window corresponding to the source node whose priority is not higher than the target priority as the current available capacity.

[0044] Optionally, the data migration module can be used to, if the target priority is higher than the lowest priority, subtract the capacity of each priority that is lower than the target priority in order of increasing priority, until the total capacity subtracted is equal to the first capacity.

[0045] According to another aspect of the embodiments of this application, a flow control device for a distributed database system is provided. The distributed database system includes multiple nodes and a scheduler, at least some of the multiple nodes include a primary shard, and each node's primary shard has corresponding secondary shards on other nodes. The device is applied to a first node, where the first node is any one of the multiple nodes. The device includes:

[0046] The data sending module is used to respond to receiving a data migration task sent by the scheduling manager, and send the data stored in the target primary shard to the target node for synchronization according to the node identifier of the target node carried in the data migration task;

[0047] The duration determination module is used to determine the data migration waiting time and data migration execution time of the data migration task;

[0048] The window capacity adjustment parameter determination module is used to determine the window capacity adjustment parameters based on the data migration waiting time and the data migration execution time.

[0049] A window capacity adjustment parameter sending module is used to send the window capacity adjustment parameters to the scheduling manager, so that the scheduling manager adjusts the window capacity of the time window corresponding to the first node according to the window capacity adjustment parameters;

[0050] The data migration task is sent by the scheduler in the following manner:

[0051] In response to the second node meeting the data migration conditions, a data migration task is determined, wherein the target primary shard is the primary shard corresponding to the secondary shard in the second node, and the source node receiving the data migration task is the first node;

[0052] Based on the amount of stored data in the target primary shard in the first node, determine the first capacity of the time window occupied by the first node for data migration;

[0053] When the current available capacity of the time window corresponding to the first node is not less than the first capacity, the data migration task is sent to the first node.

[0054] Optionally, the device further includes:

[0055] The data deletion module is used to respond to a successful data snapshot reception response sent by the destination node, and send a data deletion instruction to the node that meets the data migration conditions, based on the node identifier of the node that meets the migration conditions included in the data migration task. The data deletion instruction includes the shard identifier of the target primary shard.

[0056] According to another aspect of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method provided in any optional embodiment of the present application.

[0057] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method provided in any optional embodiment of this application.

[0058] According to one aspect of the embodiments of this application, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method provided in any optional embodiment of this application.

[0059] The beneficial effects of the technical solution provided in this application are: dynamic flow control of each node is achieved through time windows, avoiding performance bottlenecks and improving task execution efficiency. Specifically, the scheduler can determine whether a node has the capacity to execute a data migration task based on the current available capacity of the time window corresponding to the node and the capacity required for the node to execute the task, thus achieving flow control. The scheduler can also adjust the capacity of the time window corresponding to the node based on the window capacity adjustment parameters fed back by the node. Since the window capacity adjustment parameters are determined based on the node's data migration waiting time and data migration execution time, which reflect the node's task execution pressure, adjusting the window capacity corresponding to the node based on the window capacity adjustment parameters can achieve real-time and dynamic adjustment based on the node's pressure status. This effectively improves the flexibility of flow control, avoids the problem of wasted traffic resources due to excessively large window capacities, and also avoids the problem of slow task execution due to excessively small window capacities, which leads to reduced stability of the distributed database system. Attached Figure Description

[0060] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.

[0061] Figure 1 A schematic diagram of a distributed database system provided in an embodiment of this application;

[0062] Figure 2 A flowchart illustrating the flow control method for a distributed database system provided in this application embodiment;

[0063] Figure 3 A schematic diagram illustrating the interaction between the scheduling manager and each node provided in an embodiment of this application;

[0064] Figure 4 This application provides a schematic diagram of a data migration process as an embodiment of the present application.

[0065] Figure 5 This is a schematic diagram of another data migration process provided in an embodiment of this application;

[0066] Figure 6a , Figure 6b , Figure 6c , Figure 6d , Figure 6e and Figure 6f A schematic diagram illustrating the effect of an embodiment of this application;

[0067] Figure 7 A schematic diagram of a flow control device for a distributed database system provided in an embodiment of this application;

[0068] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0069] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.

[0070] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the element can be directly connected or coupled to the other element, or it can mean that the element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term, for example, “A and / or B” or “A, B” indicates implementation as “A,” or implementation as “B,” or implementation as “A and B.” When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items can refer to one, several or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2 and A3.

[0071] In distributed database clusters, the same data can exist in multiple different replicas (stored in shards). Migrating data between different nodes is a common operation when new data is added or nodes are added or removed. Furthermore, initiating and executing scheduling are usually asynchronous. Balancing the generation capacity of initiating scheduling with the consumption capacity of executing scheduling directly affects the execution speed and the impact on online services. To avoid slow scheduling generation affecting cluster stability and excessively fast scheduling affecting online services, flow control of scheduling generation speed is often necessary. Current solutions typically limit flow based on fixed values, which lacks flexibility and requires manual intervention. Alternatively, they may only limit storage space without fully considering the overall computing and bandwidth resources of the cluster, or they may limit flow at the data ingress and egress points rather than at the actual sender and receiver, resulting in poor flow control effectiveness.

[0072] This application provides a flow control method for a distributed database system. When a node meets data migration conditions, its data can be migrated to other nodes. For example, if a node is in a busy state, some of its data can be migrated to other nodes so that the scheduler can schedule other nodes to perform tasks, thereby balancing the task pressure among nodes and ensuring that no single node reaches a performance bottleneck. Furthermore, this application uses the available capacity of the time window corresponding to the source node that actually sends data for flow control, and adjusts the capacity of the time window corresponding to the source node based on the window capacity adjustment parameters fed back by the source node, avoiding manual intervention and improving the flexibility of flow control.

[0073] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of the embodiments of this application and the technical effects produced by the technical solutions of this application are described below through the description of several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed, or combined with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be described again.

[0074] Figure 1 A schematic diagram of the structure of a distributed database system to which the method provided in the embodiments of this application is applicable, such as... Figure 1 As shown, a distributed database system comprises multiple nodes and a scheduler. At least some of the nodes include primary shards, and each node's primary shard has corresponding secondary shards on the other nodes. The data stored in the secondary shards is a backup of the data stored in the primary shards. By configuring secondary shards, load balancing and high availability can be achieved across the nodes in the distributed database system.

[0075] Optionally, to improve utilization, the data to be stored can be divided into at least a number of sub-data based on the number of nodes in the distributed database system. The original data of a sub-data can be stored on one node. At least some of the nodes in the distributed database system can store the original data of the sub-data. The storage space in a node storing the original data of the sub-data can be called the primary shard of that sub-data. Backup data for each sub-data can be stored on at least one other node. The storage space in that at least one node storing the backup data of that sub-data is called the secondary shard of that sub-data. It is understood that the primary and secondary shards corresponding to the same sub-data should be on different nodes to ensure system disaster recovery capabilities.

[0076] For ease of description, for the same set of data, the node containing the primary shard will be referred to as the primary node in the following description, and the node containing the secondary shard will be referred to as the backup node or secondary node. Figure 1 In the example shown, the distributed database system includes nodes 1-4, and the scheduler includes managers 1-3. Clients interact with each node via Remote Procedure Call (RPC) to send data processing requests, such as data read / write requests. The nodes in the system can communicate with each other. The scheduler is used for task scheduling in the distributed database system. The distributed database system may include only one scheduler or a cluster of managers; this embodiment does not impose any limitations. For ease of explanation, this embodiment will be described using a single scheduler.

[0077] exist Figure 1 In this architecture, to easily distinguish between primary and secondary shards, shards whose names consist only of letters are primary shards, while those whose names include numbers are secondary shards. For example, shard A in node 1 is the primary shard, and shard A1 in node 2 and shard A2 in node 4 are secondary shards of shard A. Similarly, shard C in node 1 is the primary shard, and shard C1 in node 2 and shard C2 in node 3 are secondary shards of shard C. Shard D in node 2 is the primary shard, and shard D1 in node 1 and shard D2 in node 4 are secondary shards of shard D. Shard B in node 3 is the primary shard, and shard B1 in node 2 and shard B2 in node 4 are secondary shards of shard B. Finally, shard E in node 4 is the primary shard, and shard E1 in node 3 and shard E2 in node 1 are secondary shards of shard E.

[0078] Optionally, for each primary shard, the primary shard and its slave shards form a consensus group (RaftGroup). The shards in a consensus group are managed by the Raft consensus algorithm to ensure the consistency of the data stored in each shard. For example, shard A, shard A1, and shard A2 form a Raft Group, and node 1 synchronizes data to shard A1 and shard A2 through shard A.

[0079] Figure 2 This is a flowchart illustrating a flow control method for a distributed database system provided in an embodiment of this application. The method is applied to a distributed database system and includes steps S201-S202, which are executed by a scheduling manager.

[0080] Figure 3 This is a schematic diagram illustrating the interaction between the scheduling manager and each node provided in an embodiment of this application, such as... Figure 3 As shown. For ease of explanation, the embodiments of this application are combined with Figure 3 The interaction process between the scheduling manager and each node is explained in sections S201 to S202.

[0081] Figure 3 It includes a scheduler, source nodes, and destination nodes. The source node is the node that receives the data migration task sent by the scheduler, and the destination node is the node that receives the data stored in the main shard sent by the source node and performs synchronization.

[0082] S201: In response to meeting the data migration conditions, a data migration task is determined. Based on the amount of stored data in the target primary shard corresponding to the data migration task, the first capacity of the time window occupied by the source node where the target primary shard is located is determined. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, the current available capacity is subtracted from the first capacity, and the data migration task is sent to the source node so that the source node sends the data stored in the target primary shard of the source node to the destination node for synchronization according to the node identifier of the destination node carried in the data migration task; wherein, the target primary shard is the primary shard corresponding to the slave shard in the node that meets the data migration conditions.

[0083] In a distributed database system, each node can send heartbeat information to the scheduler at a preset period. This heartbeat information may include the shard identifier of each shard in the node, the node's own load status, such as the CPU utilization and storage space utilization. The scheduler receives the heartbeat information sent by each node and determines whether the node meets the data migration conditions based on the node's own load status in the heartbeat information. When a node meets the data migration conditions, the scheduler can determine the data migration task. The data migration conditions can be set as needed, and this embodiment does not limit them.

[0084] Optionally, the data migration conditions include one or more sub-conditions, and each sub-condition may include one or more specific conditions. Meeting the data migration conditions can mean meeting any of the sub-conditions. This application embodiment does not limit which specific conditions are included in the data migration conditions. The data migration conditions can be pre-configured in the scheduling manager according to actual application needs. The scheduling manager can determine whether data migration is needed in the system based on the data migration conditions. For example, sub-conditions may be: a node is in a busy state, a node needs to release storage space, a node has a fault, or a node is a hot node, where a hot node can be a node frequently accessed by clients.

[0085] Whether a node needs to release storage space can be determined based on the storage utilization rate of nodes including shards. For example, if the storage utilization rate of a node including shards reaches 95%, the node needs to release storage space. Similarly, whether a node including shards is busy can be determined by the number of pending tasks on that node. If the number of pending tasks on a node including shards exceeds a preset number, then that node is busy.

[0086] When determining a data migration task, the scheduler can identify the destination node. This destination node may be a node that does not meet the data migration conditions; this embodiment does not impose such limitations. The data migration task may include the identifier and indication information of the target node. The indication information may include the shard identifier of the target primary shard and the node identifier of the node that meets the migration conditions.

[0087] The scheduler can also determine whether a node is capable of executing a data migration task. If the determination result is that the node is capable of executing a data migration task, the data migration task is sent to the node. This application embodiment does not limit the execution order of determining the data migration task and determining whether a node is capable of executing the data migration task.

[0088] For ease of explanation, nodes that meet the data migration conditions are referred to as intermediate nodes. It should be noted that the data eligible for migration refers to the data stored in the shards of the intermediate nodes. This application does not limit which specific shard of data in the intermediate nodes needs to be migrated; at least one shard of data in the intermediate nodes can be migrated. For example, the migration condition can be determined based on the usage frequency of the data stored in the shards. For instance, if the data migration condition is a storage space release condition, the usage frequency of the data stored in each shard of the intermediate node can be determined, sorted, and the shard with the lowest usage frequency can be selected for migration.

[0089] Because shards and primary shards follow the Raft mechanism, when data needs to be migrated from a shard, the actual execution of the data migration operation is carried out by the node containing the target primary shard corresponding to the shard. Therefore, the scheduler can identify the target shard for data migration from intermediate nodes, and then, based on the consensus group of that target shard, determine the node containing the target primary shard, designating it as the source node. The source node is used to send the data stored in the target primary shard corresponding to the shard to be migrated from the shard to the destination node.

[0090] The scheduling manager determines whether a data migration task can be executed based on the source node. Specifically, the heartbeat information may include the amount of data stored in the primary shard. Since the amount of data stored in the secondary shard is the same as that in the primary shard, this heartbeat information can be sent by the node containing the primary shard corresponding to the secondary shard. The scheduling manager can determine the first capacity of the time window occupied by the source node for data migration based on the amount of data stored in the primary shard within the source node. Specifically, the first capacity can be determined according to a preset ratio between the amount of stored data and the capacity of the occupied time window. For example, a ratio of 10:1 indicates that when the amount of stored data is 100MB, the first capacity is 10.

[0091] The time window refers to a flow control mechanism that counts and limits data migration tasks within a preset time period. When the set threshold is exceeded, the scheduler will take corresponding measures, such as rejecting new data migration tasks, delaying processing, or triggering an alarm mechanism.

[0092] Window capacity refers to the number of data migration tasks that can be executed concurrently within a preset time period. Available window capacity is the number of data migration tasks that the nodes corresponding to the time window can execute concurrently. Current available window capacity refers to the number of data migration tasks that the nodes corresponding to the time window can execute concurrently at the current moment.

[0093] When the currently available window capacity is less than the window capacity, it means that at the current moment, the node corresponding to the time window is executing a certain amount of data migration tasks. Understandably, while the node corresponding to the time window is executing data migration tasks, the scheduler can deduct a portion of the currently available window capacity—that is, subtract the first capacity from the current available capacity—to indicate that a portion of the currently available window capacity is occupied. This reflects the number of data migration tasks being executed by the node corresponding to the time window. Once the data migration tasks are completed, the scheduler can release the previously occupied portion of the currently available window capacity for the next data migration task.

[0094] The scheduler can also determine the current available capacity of the time window corresponding to the source node. Then, by comparing the current available capacity with a first capacity, it determines whether the source node can execute the data migration task. Specifically, if the current available capacity is not less than the first capacity, it indicates that the source node is capable of executing the data migration task. Therefore, the scheduler can send a data migration task to the source node. This data migration task includes the node identifier of the destination node and the node identifiers of nodes that meet the data migration conditions. If the current available capacity is less than the first capacity, it indicates that the source node is performing too many data migration tasks, consuming significant bandwidth, CPU, and disk I / O (Input / Output) resources, and cannot execute the data migration task. In this case, the scheduler can re-determine the current available capacity according to a preset time period and compare it with the first capacity until the current available capacity is not less than the first capacity. Then, it sends a data migration task to the first node (source node), so that the first node, based on the node identifier of the destination node carried in the data migration task, sends the data stored in the target primary shard to the destination node for backup. Here, the first node can be any one of multiple nodes in the distributed database system.

[0095] In this process, the source node receiving the data migration task is the first node. The node that meets the data migration conditions is the second node (intermediate node). Therefore, the target primary shard is the primary shard corresponding to the secondary shard in the second node. The scheduling manager, in response to the second node meeting the data migration conditions, determines the data migration task and, based on the amount of data stored in the target primary shard in the first node, determines the first capacity of the time window occupied by the first node for data migration. When the current available capacity of the time window corresponding to the first node is not less than the first capacity, the scheduling manager sends the data migration task to the first node.

[0096] For the first node, in response to receiving a data migration task from the scheduler, it sends the data stored in the target primary shard to the target node according to the node identifier of the target node carried in the data migration task, so that the target node can synchronize the data stored in the target primary shard. The first node can generate a file to be sent by means of data compression, generating data snapshots, etc., and then send the file to be sent to the target node.

[0097] The destination node receives the data stored in the target primary shard sent by the first node and performs synchronization.

[0098] During the data migration process described above, since the data stored in the target shard is the same as the data stored in the target master shard, and the target shard and the target master shard follow the Raft mechanism, the node that actually sends the data stored in the shard is the source node, not the intermediate node. Therefore, the object that determines whether a node has the ability to migrate data is the source node where the target master shard is located, so as to implement rate limiting on the party that actually sends the data stored in the shard and improve the flow control effect.

[0099] Furthermore, the available capacity of the time window corresponding to the source node directly reflects the data migration task pressure on that source node. When the data migration task pressure on the source node is high, the computing and bandwidth resources used are greater, and the available capacity is reduced. Therefore, flow control based on the available capacity of the time window corresponding to the source node is more effective. This avoids the problem of poor flow control effect caused by rate limiting based on the available storage space of the source node. This is because the available storage space of the source node is not necessarily related to the amount of computing and bandwidth resources currently used by the source node. For example, if the source node is executing a large number of data migration tasks, it may have a lot of available storage space, but it may be using a lot of computing and bandwidth resources. If more data migration tasks are still scheduled for the source node, the efficiency of the data migration tasks will be low, and the source node may become a bottleneck in the distributed database system. Therefore, rate limiting based on the available storage space of the source node is less effective.

[0100] S202: Receive the window capacity adjustment parameter sent by the source node. The window capacity adjustment parameter is determined by the source node based on the data migration waiting time and data migration execution time of the data migration task. Adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameter.

[0101] For the sake of consistent naming and ease of description, the first node will be called the source node.

[0102] Specifically, the source node can also determine the data migration waiting time and data migration execution time of the data migration task; based on the data migration waiting time and data migration execution time, it determines the window capacity adjustment parameters; and sends the window capacity adjustment parameters to the scheduler so that the scheduler can adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameters.

[0103] The data migration wait time can be the time taken for the source node to generate the data transmission file. For example, if the source node obtains the data transmission file through file compression, the data migration wait time can be defined as the first start time after receiving the data migration task sent by the scheduler, the first end time after compressing the data in the primary shard storage to obtain the data transmission file, and the time interval between the first start time and the first end time. The data migration execution time is the time taken to send the data transmission file to the destination node. The second start time is the moment when the data transmission file can be sent, and the second end time is the moment when the destination node receives the data transmission file. Since the source node cannot determine when the destination node will receive the data transmission file, the second end time can be defined as the moment when the source node receives the data snapshot successfully received from the destination node, and the time interval between the second start time and the second end time is the data migration execution time.

[0104] The source node can determine the difference between the data migration waiting time and the data migration execution time to obtain the window capacity adjustment parameter. It can also assign different weights to the data migration waiting time and the data migration execution time, and obtain the difference as the window capacity adjustment parameter. This application embodiment does not limit this.

[0105] The scheduler adjusts the window size of the time window corresponding to the source node based on the window capacity adjustment parameter, thus achieving flow control over the source node. This is because the data migration waiting time and data migration execution time reflect the pressure on the source node during the two stages of data migration. Generally, if the data migration waiting time is too long, it indicates that the source node is in a state of high computing resource consumption. In this case, if the data migration execution time is short, a data migration task can be scheduled for the source node, resulting in a shorter data migration delay. Conversely, if the data migration waiting time is short, it indicates that the source node is in a state of low computing resource consumption. In this case, if the data migration execution time is long, a data migration task will not be scheduled for the source node to avoid the problem of long data migration delays.

[0106] This application embodiment allows for dynamic adjustment of the window capacity of the time window corresponding to the source node through window capacity adjustment parameters. For example, increasing or decreasing the available capacity of the time window corresponding to the source node can prevent the window capacity from being set too small, which would lead to insufficient resource utilization and waste of resources. It can also prevent the window capacity from being set too large, which would add too much load to the distributed database system and cause increased latency. Furthermore, it avoids the problem of not being able to flexibly adjust the window capacity to adapt to different scenarios and requiring manual intervention due to the use of a fixed window capacity value.

[0107] It's important to note that the source node is the node that sends the data stored in the target primary shard. After successful transmission, it does not delete the data stored in its own target primary shard. In other words, for the source node, data migration actually refers to data transmission, that is, sending the data stored in its target primary shard to other nodes for synchronization. The actual data migration is relative to intermediate nodes; that is, intermediate nodes may need to perform deletion operations on the data stored in the target shard.

[0108] Specifically, if the data migration condition is to satisfy the storage space release condition, after the data stored in the target primary shard is sent to the destination node for synchronization, the data stored in the original slave shard corresponding to the target primary shard in the node that satisfies the data migration condition is deleted.

[0109] In response to receiving a successful data snapshot reception response from the destination node, the source node sends a data deletion instruction to the nodes that meet the migration conditions, based on the node identifiers of the nodes that meet the migration conditions included in the data migration task. The data deletion instruction includes the shard identifier of the target primary shard.

[0110] Nodes that meet the migration conditions determine the target slave shard in the same consensus group as the target master shard based on the shard identifier of the target master shard included in the data deletion instruction, and delete the data stored in the target slave shard.

[0111] It should be noted that, in this embodiment of the application, the participating nodes in the data migration include intermediate nodes (nodes that meet the data migration conditions), source nodes (nodes where the target master shard corresponding to the target slave shard is located), and destination nodes. The intermediate nodes do not send the data stored in the target slave shard, but can delete the data stored in the target slave shard. The source nodes can send the data stored in the target master shard to the destination nodes for synchronization, but do not delete the data stored in the target master shard. The destination nodes receive the data stored in the target master shard and synchronize it. The three nodes work together to complete the data migration task.

[0112] Figure 4 This application provides a schematic diagram of a data migration process, as shown in the embodiments. Figure 4 As shown.

[0113] The scheduler sends the data migration task to the source node. It can also subtract a first capacity from the current available capacity, i.e., occupying a portion of the source node's available capacity within its corresponding time window. The size of this occupied portion is equal to the first capacity, resulting in the remaining available capacity. The source node receives and sends the data stored in the target primary shard to the destination node, which then performs data synchronization. Afterward, a data snapshot reception success response is sent to the source node. Upon receiving this, the source node sends a data deletion command to intermediate nodes and a data migration success command to the scheduler. The intermediate nodes receive the data deletion command and, based on the target primary shard's shard identifier included in the command, delete the data stored in the target secondary shard corresponding to the target primary shard. Upon receiving the data migration success command from the source node, the scheduler can adjust the remaining available capacity (update available capacity) to obtain the current available capacity, which is the window capacity released by the first capacity, thus changing the remaining available capacity to the capacity before it was occupied.

[0114] For example, if the current available capacity before occupancy is 30, the remaining available capacity is 20, and the first capacity is 10, and the scheduling manager receives a data migration success instruction from the source node, it can adjust the remaining available capacity from 20 to 30 by the amount of the first capacity, thus obtaining the current available capacity before occupancy.

[0115] Since the data migration condition requires releasing storage space, the intermediate node can release its storage space after deleting the data from the target shard storage. Deleting data only after the data in the target primary shard storage of the source node has been sent to the destination node for synchronization is to avoid reducing the data redundancy capability of the distributed database system and affecting its stability if the data in the target primary shard storage of the source node fails to be successfully sent to the destination node for synchronization.

[0116] If the data migration conditions are met in addition to the storage space release conditions, the intermediate node may or may not delete the data from the target shard storage, which can be set as needed.

[0117] Regarding step S201, the source node can also perform data migration and achieve data synchronization by generating and sending a snapshot. Specifically, the source node generates a data snapshot of the target primary shard in the source node; it then sends this data snapshot to the destination node, so that the destination node can synchronize the data stored in the target primary shard of the source node based on the data snapshot.

[0118] In addition, the data migration waiting time and data migration execution time of the data migration task are determined by the source node in the following ways: recording the first moment when the data migration task is received; recording the second moment when the data snapshot of the target primary shard in the source node begins to be generated; determining the time difference between the second moment and the first moment as the data migration waiting time; recording the third moment when the data snapshot reception response sent by the destination node is received; and determining the time difference between the third moment and the second moment as the data migration execution time.

[0119] Of course, the destination node can also include in the successful data snapshot reception response that it has received the data stored in the target primary shard sent by the source node at the fourth moment. Then the source node can determine the time difference between the fourth moment and the second moment as the data migration execution time.

[0120] Figure 5 This is a schematic diagram of another data migration process provided in an embodiment of this application, such as... Figure 5 As shown.

[0121] The sending end is the source node, the migrating-out end is the intermediate node, and the migrating-in end is the destination node. The scheduling manager issues a schedule to the sending end, which generates a data snapshot of the target primary shard and sends the snapshot to the migrating-in end. The migrating-in end synchronizes the data stored in the target primary shard by the sending end based on the snapshot. The sending end can also record the first moment of receiving the schedule from the scheduling manager, the second moment of the start of data snapshot generation, and the third moment of receiving a successful response from the migrating-in end regarding the data snapshot. Based on the first, second, and third moments, the sending end determines the window capacity adjustment parameters for traffic feedback and sends these parameters to the scheduling manager. The scheduling manager dynamically adjusts the available capacity of the sending end's time window based on these parameters, enabling flexible traffic control.

[0122] The source node can determine the data migration waiting time as the time difference between the second and first time points, and the data migration execution time as the time difference between the third and second time points. Based on the data migration waiting time and the data migration execution time, a window capacity adjustment parameter is determined. This window capacity adjustment parameter can be the difference between the data migration waiting time and the data migration execution time. The specific formula for the window capacity adjustment parameter is as follows:

[0123]

[0124]

[0125]

[0126] in, Adjust parameters for window size. The window capacity adjustment parameter is the sum of the data migration waiting time and the data migration execution time. It can be any of the expressions on the right side of the above equation.

[0127] Since the originating end is not necessarily the sending end when the target migrates data from the shards, this application embodiment directly performs flow control on the snapshot of the generated data and the snapshot of the sent data, that is, performs flow control on the task scheduling of the data sending end. Since the task scheduling is already based on the feedback mechanism of the duration of each stage of data migration at the sending end, there is no need to impose more restrictions on the inbound end.

[0128] If the window capacity adjustment parameter is the difference between the data migration waiting time and the data migration execution time, then the scheduler adjusts the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameter, including: when the window capacity adjustment parameter is positive, increasing the window capacity of the time window corresponding to the source node; when the window capacity adjustment parameter is negative, decreasing the window capacity of the time window corresponding to the source node.

[0129] When the window capacity adjustment parameter is positive, it indicates that the data migration waiting time is longer than the data migration execution time. This means that most of the time is spent on data migration execution, the source node has the capacity to send more snapshots, and the data migration latency is relatively low. Therefore, by increasing the window capacity, the source node can execute more data migration tasks, improving the data processing efficiency of the distributed database system. When the window capacity adjustment parameter is negative, it indicates that the data migration waiting time is shorter than the data migration execution time. This means that the source node spends most of its time sending data during data migration, the source node is in a busy state, and the data migration latency is relatively long. The source node should not receive more data migration tasks. By reducing the window capacity of the time window corresponding to the source node, the scheduling of data migration tasks for that source node can be slowed down.

[0130] It is understood that the traffic feedback mechanism in this application embodiment is determined based on the duration of data snapshot generation and transmission. The actual pressure on the source node can be inferred from the snapshot generation and transmission duration. In other words, the traffic feedback mechanism is determined based on the pressure on the source node's processing tasks, making traffic control more accurate. The newly added time window is used to limit the number of concurrent tasks on the source node. That is, the total size of the sliding window is dynamically adjusted based on the traffic feedback from the current snapshot transmission. When the time window corresponding to the source node has no available capacity, it indicates that the source node is executing a large number of concurrent data migration tasks, and task scheduling to that source node is stopped.

[0131] It should be noted that reducing or increasing window capacity refers to reducing or increasing the available capacity of the time window.

[0132] Regarding step S201, different tasks have varying degrees of importance. For example, some tasks are scheduled to address heat dissipation issues, i.e., by redistributing the load to balance the task pressure across nodes and prevent any single node from becoming a system performance bottleneck. These data migration tasks have a significant impact on the stability of the distributed database system and should be executed first. Other data migration tasks are scheduled simply to free up space, having a smaller impact on the stability of the distributed database system and can be executed later. Therefore, different data migration tasks can have different priorities, which can be determined based on the data migration conditions met by the nodes. The correspondence between data migration conditions and data migration task priorities can be set as needed.

[0133] For example, if the data migration task meets the condition that the intermediate node is busy, then the priority of the data migration task is set to high priority, i.e., first priority. If the data migration task meets the condition that the intermediate node is released, then the priority of the data migration task is set to low priority, i.e., second priority. When the data migration task simultaneously meets multiple sub-conditions of the data migration conditions, such as simultaneously meeting the conditions that the node is busy and the node's storage space is released, then the priority of the task corresponding to the sub-condition with the higher priority is selected as the priority setting for the data migration task. Continuing with the above example, the first priority can be selected as the priority of the data migration task.

[0134] In addition, the window capacity of the time window also has priorities. Specifically, for each of the multiple nodes, the window capacity of the time window corresponding to that node includes at least two priorities; the current available capacity of the time window corresponding to the source node is determined by: determining the target priority of the data migration task; and using the available capacity of the time window corresponding to the source node with a priority no higher than the target priority as the current available capacity.

[0135] If the window capacity of a time window has two priorities, low priority and high priority, generally speaking, the window capacity of low priority is higher than that of high priority. This is because non-urgent data migration tasks account for a large proportion in a distributed database system, and therefore, there are more low priority data migration tasks.

[0136] For example, the total window capacity of the time window is 100, of which the low-priority window capacity is 80 and the high-priority window capacity is 20.

[0137] Because data migration tasks have priorities, and time window capacities also have priorities, to ensure that the priorities of data migration tasks match the priorities of the current available capacity within the time window, the scheduler can first determine the target priority of the data migration tasks when determining the current available capacity of the time window corresponding to the source node. This allows the scheduler to determine the current available capacity that matches the target priority. The scheduler can use the available capacity within the time window corresponding to the source node whose priority is not higher than the target priority as the current available capacity. That is, the scheduler can use the available capacity within the time window corresponding to the source node whose priority is equal to the target priority as the current available capacity, and it can also use the sum of the available capacities within the time window corresponding to the source node whose priority is lower than or equal to the target priority as the current available capacity.

[0138] For example, the data migration task has a priority (target priority) of second priority and a first capacity of 20. The time window capacity has priorities of first priority, second priority, and third priority, with first priority being higher than second priority, and second priority being higher than third priority. Specifically, the available capacity for first priority is 30, the available capacity for second priority is 20, and the available capacity for third priority is 10.

[0139] Therefore, the scheduler can use the available capacity of 20 (second priority) as the current available capacity of the time window corresponding to the source node, for subsequent comparison with the first capacity. Alternatively, it can use the available capacity of 30 (first priority) as the current available capacity of the time window corresponding to the source node, or it can use the sum of the available capacity of the second priority and the available capacity of the first priority as the current available capacity of the time window corresponding to the source node.

[0140] In practical applications, high-priority data migration tasks are more important than low-priority tasks and have a greater impact on the distributed database system. Therefore, high-priority data migration tasks need to be executed first. Setting different priorities for time windows can prevent low-priority data migration tasks from occupying all the currently available capacity of the time window, forcing higher-priority data migration tasks to wait and causing them to experience significant delays. In other words, setting different priorities for time windows ensures that high-priority data migration tasks are processed promptly, reducing processing latency. Prioritizing high-priority data migration tasks prevents low-priority tasks from consuming excessive bandwidth resources, thereby improving the resource utilization efficiency of the distributed database system.

[0141] In this embodiment of the application, optionally, subtracting the first capacity from the current available capacity includes: if the target priority is higher than the lowest priority, for the capacity of each priority that is lower than the target priority, subtracting the capacity of each priority in order of increasing priority, until the total subtracted capacity is equal to the first capacity.

[0142] It should be noted that the currently available capacity may include currently available capacity with different priorities. You can choose to occupy the capacity with a priority no higher than the target priority. Specifically, you can occupy the lowest priority capacity first, which can improve the utilization rate of the window capacity and thus improve the resource utilization rate of the distributed database system.

[0143] Using the example above, the priority (target priority) of the data migration task is as follows: Second priority, first capacity 20; first priority, available capacity 30; second priority, available capacity 20; third priority, available capacity 10. The scheduler can preferentially occupy 20% of the first priority's available capacity of 30. If the first capacity is 40, then it can occupy 10% of the first priority's available capacity of 30 and the second priority's available capacity of 20, for a total occupied available capacity of 40, which is the first capacity.

[0144] Figure 6a , Figure 6b , Figure 6c , Figure 6d , Figure 6e and Figure 6f This is a schematic diagram illustrating the effect of an embodiment of this application, such as... Figures 6a-6f As shown.

[0145] Figure 6a , Figure 6c and Figure 6e The diagrams illustrate the number of scheduling tasks generated at different times during capacity expansion, based on the default settings, the method provided in this application embodiment, and the method without rate limiting. The horizontal axis represents time, and the vertical axis represents the number of operations per minute. Figure 6b , Figure 6d ,and Figure 6fThis diagram illustrates the latency of a distributed database system during scaling up, assuming default settings, the method provided in this application embodiment, and a method without rate limiting. The latency is caused by backend data migration and foreground real-time load. The horizontal axis represents the latency type, including P999 latency, P99 latency, P95 latency, and P80 latency, while the vertical axis represents the latency time. For example, in a distributed database system with 3 nodes, scaling up to 6 nodes and then down to 3 nodes improves the speed of performing specific operations by nearly 3 times compared to the default configuration. Compared to no flow control, the latency of performing specific operations is reduced by nearly half. These specific operations may include any one or more of the following: CRUD operations on data.

[0146] This application provides a flow control device for a distributed database system, such as... Figure 7 As shown, the distributed database system includes multiple nodes and a scheduler. At least some of the nodes include a primary shard, and each node's primary shard has corresponding secondary shards on other nodes. The device is applied to the scheduler. The flow control device 70 of the distributed database system includes: a data migration module 701, a window capacity adjustment parameter receiving module 702, and a window capacity adjustment module 703, wherein:

[0147] Data migration module 701 is used to determine a data migration task in response to meeting data migration conditions. Based on the amount of stored data in the target primary shard corresponding to the data migration task, it determines the first capacity of the time window occupied by the source node where the target primary shard is located for data migration. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, it subtracts the first capacity from the current available capacity and sends the data migration task to the source node. This allows the source node to send the data stored in the target primary shard of the source node to the destination node for synchronization, based on the node identifier of the destination node carried in the data migration task. The target primary shard is the primary shard corresponding to the secondary shard among the nodes that meet the data migration conditions.

[0148] The window capacity adjustment parameter receiving module 702 is used to receive the window capacity adjustment parameters sent by the source node. The window capacity adjustment parameters are determined by the source node based on the data migration waiting time and data migration execution time of the data migration task.

[0149] The window capacity adjustment module 703 is used to adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameters.

[0150] Optionally, the step of sending the data in the target primary shard storage of the source node to the destination node for synchronization is determined by the source node through the following method:

[0151] Generate a data snapshot of the target primary shard in the source node;

[0152] The data snapshot is sent to the destination node so that the destination node can synchronize the data stored in the target primary shard of the source node based on the data snapshot;

[0153] The data migration waiting time and data migration execution time of the data migration task are determined by the source node in the following way:

[0154] Record the first moment when the data migration task is received;

[0155] Record the second moment at which the data snapshot of the target primary shard in the source node begins to be generated;

[0156] The time difference between the second moment and the first moment is determined as the data migration waiting time;

[0157] Record the third moment of receiving a snapshot of the data sent by the destination node and the successful response;

[0158] The time difference between the third moment and the second moment is determined as the data migration execution time.

[0159] Optionally, the window capacity adjustment parameter is the difference between the data migration waiting time and the data migration execution time;

[0160] The window capacity adjustment module 703 can be used to increase the window capacity of the time window corresponding to the source node when the window capacity adjustment parameter is positive, and to decrease the window capacity of the time window corresponding to the source node when the window capacity adjustment parameter is negative.

[0161] Optionally, the window capacity of the time window corresponding to each of the plurality of nodes includes capacities with at least two priorities;

[0162] The current available capacity of the time window corresponding to the source node is determined by the data migration module 701 in the following way: determining the target priority of the data migration task; and taking the available capacity of the window capacity of the time window corresponding to the source node whose priority is not higher than the target priority as the current available capacity.

[0163] Optionally, the data migration module 701 can be used to, if the target priority is higher than the lowest priority, subtract the capacity of each priority that is lower than the target priority in order of increasing priority, until the total capacity subtracted is equal to the first capacity.

[0164] According to another aspect of the embodiments of this application, a flow control device for a distributed database system is provided. The distributed database system includes multiple nodes and a scheduler, at least some of the multiple nodes include a primary shard, and each node's primary shard has corresponding secondary shards on other nodes. The device is applied to a first node, where the first node is any one of the multiple nodes. The device includes:

[0165] The data sending module is used to respond to receiving a data migration task sent by the scheduling manager, and send the data stored in the target primary shard to the target node for synchronization according to the node identifier of the target node carried in the data migration task;

[0166] The duration determination module is used to determine the data migration waiting time and data migration execution time of the data migration task;

[0167] The window capacity adjustment parameter determination module is used to determine the window capacity adjustment parameters based on the data migration waiting time and the data migration execution time.

[0168] A window capacity adjustment parameter sending module is used to send the window capacity adjustment parameters to the scheduling manager, so that the scheduling manager adjusts the window capacity of the time window corresponding to the first node according to the window capacity adjustment parameters;

[0169] The data migration task is sent by the scheduler in the following manner:

[0170] In response to the second node meeting the data migration conditions, a data migration task is determined, wherein the target primary shard is the primary shard corresponding to the secondary shard in the second node, and the source node receiving the data migration task is the first node;

[0171] Based on the amount of stored data in the target primary shard in the first node, determine the first capacity of the time window occupied by the first node for data migration;

[0172] When the current available capacity of the time window corresponding to the first node is not less than the first capacity, the data migration task is sent to the first node.

[0173] Optionally, the device further includes:

[0174] The data deletion module is used to respond to a successful data snapshot reception response sent by the destination node, and send a data deletion instruction to the node that meets the data migration conditions, based on the node identifier of the node that meets the migration conditions included in the data migration task. The data deletion instruction includes the shard identifier of the target primary shard.

[0175] The apparatus in this application embodiment can execute the method provided in this application embodiment, and its implementation principle is similar, and it has corresponding technical effects. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For a detailed functional description of each module of the apparatus, please refer to the description in the corresponding method shown above, which will not be repeated here.

[0176] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the method provided in any optional embodiment of this application.

[0177] In one alternative embodiment, an electronic device is provided, such as Figure 8 As shown, Figure 8 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.

[0178] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0179] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0180] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0181] The memory 4003 is used to store computer programs that execute embodiments of the present disclosure, and is controlled by the processor 4001 to execute them. The processor 4001 is used to execute the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0182] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.

[0183] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0184] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.

[0185] The above description is only an optional implementation of some implementation scenarios of this disclosure. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this disclosure without departing from the technical concept of the embodiments of this application also fall within the protection scope of the embodiments of this application.

Claims

1. A flow control method for a distributed database system, characterized in that, The distributed database system includes multiple nodes and a scheduling manager. At least some of the multiple nodes include a primary shard, and each node's primary shard has a corresponding secondary shard in other nodes. The method is executed by the scheduling manager, and the method includes: In response to meeting the data migration conditions, a data migration task is determined. Based on the amount of stored data in the target primary shard corresponding to the data migration task, a first capacity of the time window occupied by the source node where the target primary shard is located is determined. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, the current available capacity is subtracted from the first capacity, and the data migration task is sent to the source node. This allows the source node to send the data stored in the target primary shard of the source node to the destination node for synchronization based on the node identifier of the destination node carried in the data migration task. The target primary shard is the primary shard corresponding to the secondary shard in the node that meets the data migration conditions. The source node receives window capacity adjustment parameters, which are determined by the source node based on the data migration waiting time and data migration execution time of the data migration task. The window capacity of the time window corresponding to the source node is adjusted according to the window capacity adjustment parameters.

2. The method according to claim 1, characterized in that, The step of sending the data stored in the target primary shard of the source node to the destination node for synchronization includes: Generate a data snapshot of the target primary shard in the source node; The data snapshot is sent to the destination node so that the destination node can synchronize the data stored in the target primary shard of the source node based on the data snapshot; The data migration waiting time and data migration execution time of the data migration task are determined by the source node in the following way: Record the first moment when the data migration task is received; Record the second moment at which the data snapshot of the target primary shard in the source node begins to be generated; The time difference between the second moment and the first moment is determined as the data migration waiting time; Record the third moment of receiving a snapshot of the data sent by the destination node and the successful response; The time difference between the third moment and the second moment is determined as the data migration execution time.

3. The method according to claim 1 or 2, characterized in that, The window capacity adjustment parameter is the difference between the data migration waiting time and the data migration execution time; The step of adjusting the window size of the time window corresponding to the source node according to the window size adjustment parameter includes: When the window capacity adjustment parameter is positive, the window capacity of the time window corresponding to the source node is increased; When the window capacity adjustment parameter is negative, the window capacity of the time window corresponding to the source node is reduced.

4. The method according to claim 1, characterized in that, The window capacity of the time window corresponding to each of the plurality of nodes includes capacities with at least two priorities. The current available capacity of the time window corresponding to the source node is determined in the following way: Determine the target priority of the data migration task; The available capacity within the time window corresponding to the source node whose priority is not higher than the target priority is taken as the current available capacity.

5. The method according to claim 4, characterized in that, The step of subtracting the first capacity from the current available capacity includes: If the target priority is higher than the lowest priority, for the capacity of each priority that is lower than the target priority, the capacity of each priority is subtracted in order from low to high priority until the total subtracted capacity equals the first capacity.

6. The method according to claim 1, characterized in that, If the data migration condition is a storage space release condition, after the data stored in the target primary shard is sent to the destination node for synchronization, the data stored in the original slave shard corresponding to the target primary shard in the node that meets the data migration condition is deleted.

7. A flow control method for a distributed database system, characterized in that, The distributed database system includes multiple nodes and a scheduling manager. At least some of the multiple nodes include a primary shard, and each node's primary shard has a corresponding secondary shard in other nodes. The method is executed by a first node, which is any one of the plurality of nodes, and the method includes: In response to receiving a data migration task sent by the scheduling manager, the data stored in the target primary shard is sent to the target node for synchronization according to the node identifier of the target node carried in the data migration task; Determine the data migration waiting time and data migration execution time for the data migration task; The window capacity adjustment parameters are determined based on the data migration waiting time and the data migration execution time. The window capacity adjustment parameters are sent to the scheduling manager so that the scheduling manager adjusts the window capacity of the time window corresponding to the first node according to the window capacity adjustment parameters. The data migration task is sent by the scheduler in the following manner: In response to the second node meeting the data migration conditions, a data migration task is determined, wherein the target primary shard is the primary shard corresponding to the secondary shard in the second node, and the source node receiving the data migration task is the first node; Based on the amount of stored data in the target primary shard in the first node, determine the first capacity of the time window occupied by the first node for data migration; When the current available capacity of the time window corresponding to the first node is not less than the first capacity, the data migration task is sent to the first node.

8. A flow control method for a distributed database system, characterized in that, The distributed database system includes multiple nodes and a scheduling manager. At least some of the multiple nodes include a primary shard, and each node's primary shard has a corresponding secondary shard in other nodes. The method includes: The scheduling manager is used to determine the corresponding data migration task when it is determined that any node among the plurality of nodes meets the data migration conditions, and to determine the first capacity of the time window occupied by the source node where the target primary shard is located for data migration based on the amount of stored data of the target primary shard corresponding to the data migration task. When the current available capacity of the time window corresponding to the source node is not less than the first capacity, the first capacity is subtracted from the current available capacity, and the data migration task is sent to the source node; wherein, the source node of the data migration task is the node where the target primary shard corresponding to any secondary shard among the nodes that meet the data migration conditions is located. When the source node receives the data migration task sent by the scheduling manager, it sends the data stored in the target primary shard of the source node to the target node for synchronization according to the node identifier of the target node carried in the data migration task. The source node is also used to determine the data migration waiting time and the data migration execution time, determine the window capacity adjustment parameters based on the data migration waiting time and the data migration execution time, and send the window capacity adjustment parameters to the scheduling manager. The scheduling manager is also used to receive window capacity adjustment parameters sent by the source node, and adjust the window capacity of the time window corresponding to the source node according to the window capacity adjustment parameters.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method according to any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 8.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data migration method and related device

    CN115480711A

  • Capacity reduction method and device of distributed storage system, electronic equipment and medium

    CN118626563A