A method and device for load balancing of distributed database system

By optimizing the load balancing strategy, combining load pressure and storage node processing capabilities, and using machine learning to estimate load IO traffic, the problems of load imbalance and unstable pressure in the existing technology are solved, and the high-load scenario of the distributed database system is improved. performance and stability.

CN116991580BActive Publication Date: 2024-09-13上海沄熹科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310934592.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-27
Publication Date
2024-09-13
Estimated Expiration
2043-07-27

AI Technical Summary

Technical Problem

The load balancing strategy of the existing distributed database system only considers the QPS indicator and data volume balance, and fails to effectively balance the processing power and historical pressure of the storage node, resulting in unstable load pressure, and possible pressure concentration when the node is retired or down. and resource waste issues.

Method used

By optimizing the target selection rules for moving in and out of range copies, combined with load pressure, storage node processing capabilities and historical load data, machine learning algorithms are used to fit future load IO traffic curves, and load balancing scheduling business statistics are expanded to avoid load concentration. , improve the stability and accuracy of load balancing.

Benefits of technology

It achieves improved read and write performance in high load pressure scenarios, avoids load pressure jitter and resource waste, and ensures the stability and reliability of the distributed database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116991580B
    Figure CN116991580B
Patent Text Reader

Abstract

The present invention discloses a method and device for load balancing of a distributed database system, which belongs to the field of distributed database technology. The method optimizes the sorting rules of hot data. The index information required by the sorting rules includes: load pressure index set data, storage node processing capacity index set data; historical load data; statistical information of newly added load balancing scheduling services; and priority sorting of candidate queues of migration out of range copies and migration into target storage nodes for the information data. The present invention can achieve efficient load balancing of the system by optimizing the selection rules for migration in and out of range copy targets, thereby improving the read and write performance of the distributed database system under high load pressure scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of distributed databases, and in particular to a method and device for load balancing of a distributed database system. Background Art

[0002] Load balancing is one of the factors that must be considered in the design of distributed system architecture. It usually refers to evenly distributing requests / data to multiple operation units for execution. Common Internet distributed architectures are divided into client layer, reverse proxy nginx layer, site layer, service layer, and data layer. Each layer has a different strategy for load balancing implementation:

[0003] Load balancing from the client layer to the reverse proxy layer is achieved through "DNS polling";

[0004] Load balancing from the reverse proxy layer to the site layer is achieved through "nginx";

[0005] Load balancing from the site layer to the service layer is achieved through the "service connection pool";

[0006] When balancing the load at the data layer, we need to consider two points: "data balance" and "request balance". Common methods include "range level splitting" and "hash level splitting".

[0007] The existing load balancing implementation of the distributed database KaiwuDB is based on range horizontal segmentation. KaiwuDB will first build a key based on the user data table, and logically divide it horizontally into multiple shards according to the key value range, called Range. There will be multiple replicas under each Range (the number of replicas can be configured), and the replicas are distributed on different cluster nodes. With the help of the Raft protocol, strong consistency synchronization is performed, solving the high availability and fault tolerance at the partition level while achieving load balancing by scheduling the position of the range. To achieve load balancing, the KaiwuDB background service will repeatedly perform range splitting and range migration.

[0008] Range splitting: The master node of the range calculates the appropriate key as the splitting point, initiates the split through the raft protocol, and updates the range metadata to achieve the range splitting. The newly split range node inherits the node distribution of the replica of its parent range. The range itself will not balance the load, but the range splitting will produce a more fine-grained range. The KaiwuDB balanced scheduling algorithm migrates the range to disperse the read and write traffic to other nodes, thereby achieving the effect of horizontal expansion and load balancing.

[0009] Range migration: The migration process first adds a new replica B to the replica's Raft Group; then replays the log to make the new replica B consistent with the primary replica data; after synchronization is complete, the Range metadata is updated and the source replica A is deleted. With the migration of the range, the load pressure moves from node A to node B, thereby achieving load balancing.

[0010] In summary, KaiwuDB's existing load balancing strategy is based on the load pressure of the range and is implemented by splitting and migrating the range. The existing implementation has the following shortcomings:

[0011] 1. The load pressure condition for range splitting and migration is only the QPS indicator, which is only effective for query scenario pressure feedback;

[0012] 2. The data distribution of range replicas is balanced, which only considers the balance of data volume but not the processing capacity of storage nodes;

[0013] 3. Load balancing only considers historical pressure. Migration may result in the concentrated transfer of pressure to an idle node, causing a sudden increase in node pressure and fluctuations in the load pressure balancing process.

[0014] 4. When a storage node is retired or down, load balancing must also be considered when completing the replication. Otherwise, a chain reaction may occur, such as concentrated pressure on a certain storage node, backlog of node playback logs, excessive memory usage, and node OOM. This may lead to a domino effect that causes nodes to be killed one by one by the system. Summary of the invention

[0015] The technical task of the present invention is to address the above shortcomings and provide a method and device for load balancing of a distributed database system, which can achieve efficient load balancing of the system by optimizing the selection rules of migration-in and migration-out range replica targets, thereby improving the read and write performance of the distributed database system under high load pressure scenarios.

[0016] The technical solution adopted by the present invention to solve its technical problem is:

[0017] A method for load balancing of a distributed database system optimizes the sorting rules of hot data. The index information required by the sorting rules includes: load pressure index set data, storage node processing capacity index set data; historical load data; and statistical information of newly added load balancing scheduling services.

[0018] Prioritize the candidate queues of the information data to migrate out of the range copy and into the target storage node,

[0019] The priority of migrating out the hotspot data range copy is calculated according to the sorting rules of the hotspot data range copy. The calculation rules are as follows: the comprehensive index value is calculated for the same attribute and is compared in order of priority:

[0020] The index ranking of the load attribute is: value × weight = comprehensive index value. The higher the value, the hotter the range data is.

[0021] The index ranking of resource attributes: value × weight = comprehensive index value. The higher the value, the tighter the resources of the node where the range data is located, and the more urgent the need to migrate the range replica.

[0022] Indicator ranking of business attributes: the net outflow of ranges and a high success rate indicate that the feasibility of range migration is higher;

[0023] The priority of the target storage node is calculated according to the sorting rule of the target node. The calculation rule is: the comprehensive index value of the same attribute is calculated and compared in order of priority:

[0024] The index ranking of resource attributes: value × weight = comprehensive index value. The higher the index, the more abundant the resources are, and it is suitable for new replicas to migrate in, and it can be used as the target node.

[0025] The index ranking of the load attribute is: value × weight = comprehensive index value. The higher the value, the hotter the range data is.

[0026] In terms of business attribute indicator sorting, the higher the net inflow of range replicas and the higher the success rate, the higher the feasibility of the node as a migration target node.

[0027] This method improves the selection rules of storage nodes during load balancing scheduling, expands the evaluation indicators of storage node resources, read and write pressure and performance, and optimizes the load balancing scheduling of distributed systems. For storage read and write services, the current state of storage nodes and the estimated pressure of future storage nodes are comprehensively considered to select the copy location of newly written data and the access copy of read services, maximizing the relief of the competition for resources caused by business pressure.

[0028] Preferably, the load pressure indicator set data includes: QPS, WPS, QPS and WPS of the business load being prepared for migration recorded in the statistical information, and the pressure peak value of the future load IO flow curve fitted according to the statistical information.

[0029] Load pressure condition indicators include real-time load indicators such as QPS (query-per-second) and WPS (write-per-second), as well as pressure handling capacity indicators such as the number of CPU cores and performance of the machine where the node is located, and the hard disk capacity and disk speed indicators of the storage node. Multiple indicators can more comprehensively determine whether the load of the current storage node needs to be diverted.

[0030] Preferably, the storage node processing capacity indicator set, the set elements include: storage node cache capacity, amount of stored data, number of schedulable threads, number of CPU cores and busyness of the machine where the node is located, memory usage percentage of the machine where the node is located, and remaining capacity and busyness of the node storage path hard disk.

[0031] Preferably, the historical load data includes the read and write data access volume, QPS / WPS peak, number of active ranges, and number of active replicas in the past 1h / 1min / 1s. The load processing status of each storage node in the historical stage is recorded, and the load IO flow curve in the next hour is estimated using a machine learning algorithm to provide more reliable suggestions for the election of the migration target node.

[0032] Furthermore, new statistical information is added to record historical load data and fit the future load IO traffic curve. The future load IO traffic curve fitting algorithm uses a multinomial function to fit the IO traffic curve. The data of the past 24 hours are trained based on the Bayesian method and the minimum likelihood function, and the IO traffic curve of the next 12 hours is predicted. In order to improve the estimation accuracy of the IO traffic curve, data training and curve fitting updates are performed periodically at intervals of 12 hours.

[0033] Preferably, the statistical information of the newly added load balancing scheduling service includes the number and amount of data migrated in and out of the range in the past 1 hour / 1 minute, the migration success rate, and the average time for responding to migration in and out.

[0034] Increase the statistical information of the load balancing scheduling service to avoid the intermediate load pressure being concentrated on one or several nodes, making the load balancing process more stable and reducing the jitter of the storage node load pressure.

[0035] Preferably, the sorting rules of the hot data range are as shown in Table 1-1 below:

[0036] Table 1-1

[0037] property Indicator name Priority Value Weight load QPS (queries processed per second) high QPS actual statistics 0.5 load WPS (write requests per second) high WPS actual statistics 0.3 load QPS to be relocated high QPS estimated statistics 0.05 load WPS to be moved out high WPS estimated statistics 0.10 load Future IO traffic peak high Fitting curve QPS+WPS value 0.05 resource Storage node space usage middle Occupied / Total Capacity 0.4 resource CPU busyness of the machine where the node is located middle CPU busyness 0.2 resource Hard disk busyness middle Disk statistics util 0.2 resource Memory usage of the machine where the node is located middle Used memory / Total memory 0.2 business range quantity net inflow Low The number of ranges moved in and out - business Migration success rate Low Successful migration / requested migration 1

[0038] The sorting rules of the migration target nodes are shown in Table 1-2 below:

[0039] Table 1-2

[0040]

[0041]

[0042] Preferably, for the selection of the target of the range to be migrated out / the target of the node to be migrated in, based on the calculation rule, 5 candidate targets, 3 candidate targets and 1 candidate target are retained in sequence, so as to determine the final target of the range to be migrated out / the target of the node to be migrated in.

[0043] Preferably, the statistical information update includes:

[0044] The statistical information of the historical load data of the storage node does not need to be updated. It can be obtained by accessing the system metric when obtaining relevant indicator information. This part of the data can be calculated and processed through the statistical information stored by the KaiwuDB time series engine;

[0045] Load business statistics information can be recorded by adding a statistical structure to the data structure provided by the original metric interface. It is updated when a range copy of a hot spot to be migrated is selected in the storage node or a raft request is received to process the range copy to be migrated.

[0046] The present invention also claims protection for a distributed database system load balancing device, which is used to implement the above-mentioned distributed database system load balancing method.

[0047] Compared with the prior art, the method and device for load balancing of a distributed database system of the present invention have the following beneficial effects:

[0048] This method expands the set of load pressure evaluation indicators to support load balancing in more pressure scenarios. It is no longer limited to query scenarios. Load balancing can be achieved in various load scenarios such as data writing, node addition, and rebalancing after node deletion.

[0049] This method adds new statistical information to record the load processing status of each storage node in the historical stage, and uses machine learning algorithms to train historical data to fit the load IO flow curve in the next hour, and empowers load balancing scheduling for storage nodes that are migrated in and out, thereby improving the cost-effectiveness of load balancing scheduling;

[0050] This method adds statistical information of load balancing scheduling services, takes the business pressure of the ongoing migration into account in the load pressure of the storage node, and serves as an evaluation of the future node load pressure. This can effectively avoid blind spots for other load balancing schedulers before and after the migration, and avoid the jitter of the node pressure curve caused by everyone using one or several nodes as the optimal migration in and out nodes in unexpected situations.

[0051] This method can not only more effectively reduce the read and write pressure of high-load pressure nodes, but also the migration nodes with idle business and better performance can complete the range replica migration faster. Fast and effective range migration can reduce the writing of additional replica data.

[0052] This method is based on the existing business process. The range splitting, migration and other interfaces do not need to be modified and are fully compatible with existing applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 It is a schematic diagram of a method for implementing load balancing of a distributed database system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The present invention will be further described below in conjunction with specific embodiments.

[0055] An embodiment of the present invention provides a method for load balancing of a distributed database system, which optimizes the sorting rules of hot spot data. The index information required by the sorting rules includes: load pressure index set data, storage node processing capacity index set data; historical load data; and statistical information of newly added load balancing scheduling services.

[0056] Load pressure condition indicators, including real-time load indicators such as QPS (query-per-second) and WPS (write-per-second), as well as pressure handling capacity indicators such as the number of CPU cores and performance of the node's machine, the storage node's hard disk capacity and disk speed indicators. Multiple indicators can more comprehensively determine whether the current storage node's load needs to be diverted;

[0057] Added statistical information to record the load processing status of each storage node in the historical stage, and used machine learning algorithms to estimate the load IO flow curve in the next hour, providing more reliable suggestions for the election of migration target nodes;

[0058] Increase the statistical information of the load balancing scheduling service to avoid the intermediate load pressure being concentrated on one or several nodes, making the load balancing process more stable and reducing the jitter of the storage node load pressure.

[0059] The ultimate goal is to improve the read and write performance of distributed database systems under high load pressure scenarios through fast and effective load balancing.

[0060] The specific implementation is as follows:

[0061] Whether it is lease balancing or replica balancing, it is necessary to obtain the hot data range and sort it. This method optimizes the sorting rules of hot data.

[0062] The index information required for the optimized sorting rules includes: load pressure index set data, storage node processing capacity index set data;

[0063] Based on the existing QPS, the load pressure indicator set is expanded to include: QPS, WPS, QPS and WPS of the business load that is being prepared for migration recorded in the statistical information, and the pressure peak value of the future load IO flow curve fitted according to the statistical information;

[0064] The storage node processing capacity indicator set includes: storage node cache capacity, amount of stored data, number of schedulable threads, number of CPU cores and busyness of the node machine, memory usage percentage of the node machine, remaining capacity and busyness of the node storage path hard disk, etc.

[0065] Historical load data includes the read and write data access volume, QPS / WPS peak, number of active ranges, number of active replicas, etc. within the past hour / minute / second.

[0066] The future load IO traffic curve fitting algorithm uses a multinomial function to fit the IO traffic curve, trains the data of the past 24 hours based on the Bayesian method and the minimum likelihood function, and predicts the IO traffic curve for the next 12 hours. To improve the accuracy of the IO traffic curve estimation, we periodically perform data training and curve fitting updates every 12 hours.

[0067] Load business statistics include the number of range replicas and data volume migrated in and out within the past hour or minute, the migration success rate, and the average response time for migration in and out.

[0068] (1) The sorting rules for hot data ranges are as follows:

[0069] Table 1-1

[0070]

[0071]

[0072] Calculation rules: The comprehensive index value of the same attribute is calculated and compared in order of priority:

[0073] The index ranking of the load attribute is: value × weight = comprehensive index value. The higher the value, the hotter the range data is.

[0074] The index ranking of resource attributes: value × weight = comprehensive index value. The higher the value, the tighter the resources of the node where the range data is located, and the more urgent the need to migrate the range replica.

[0075] In terms of business attribute indicator sorting, the higher the net outflow of ranges and the higher the success rate, the higher the feasibility of migrating range copies.

[0076] (2) The sorting rules for the target nodes are as follows:

[0077] Table 1-2

[0078] property Indicator name Priority Value Weight load QPS (queries processed per second) high QPS actual statistics 0.3 load WPS (write requests per second) high WPS actual statistics 0.5 load QPS to be relocated high QPS estimated statistics 0.05 load WPS to move in high WPS estimated statistics 0.10 load Future IO traffic peak high Fitting curve QPS+WPS value 0.05 resource Storage node space idle rate high Remaining capacity / total capacity 0.4 resource CPU idleness of the machine where the node is located high Number of CPUs*100-CPU busyness 0.2 resource Hard disk idle time high 1- Disk statistics util 0.2 resource Memory idle rate of the node's machine high Remaining memory / Total memory 0.2 business range quantity net outflow Low The number of ranges moved in and out - business Migration success rate Low Successful migration / requested migration 1

[0079] Calculation rules: The comprehensive index value of the same attribute is calculated and compared in order of priority:

[0080] The index ranking of resource attributes is: value * weight = comprehensive index value. The higher the index, the more abundant the resources are, and it is suitable for new replicas to migrate in, and it can be used as the target node.

[0081] The index ranking of the load attribute is: value * weight = comprehensive index value. The higher the value, the hotter the range data is.

[0082] In the ranking of business attribute indicators, the higher the net inflow of ranges and the higher the success rate, the higher the feasibility of the node as a migration target node.

[0083] The selection of the target of the range to be migrated out / the target of the node to be migrated in is based on the calculation rules (1) and (2) above. The resource attribute indicators, load attribute indicators, and business attribute indicators are used to retain 5, 3, and 1 candidate targets respectively, and the final target of the range to be migrated out / the target of the node to be migrated in is determined.

[0084] Statistical information update: The historical load data statistics of the storage node do not need to be updated. They can be obtained by accessing the system metric when obtaining relevant indicator information. This part of the data can be obtained by calculating and processing the statistics stored by the KaiwuDB time series engine. The load business statistics can be recorded by adding a statistical structure to the store instance structure based on the data structure provided by the original metric interface. It is updated when the storage node selects a range copy to be migrated or receives a raft request to process the range copy to be migrated.

[0085] This method can more accurately select appropriate hotspot data for migration by evaluating and analyzing more load pressure evaluation indicators and combining the processing capacity of storage nodes, and ensure that the target node can effectively handle this part of the load pressure. At the same time, machine learning algorithms are introduced to estimate and feedback the effectiveness of load balancing and node load, so as to achieve flexible changes in the load pressure of each node in the entire cluster system and load balancing between nodes, and improve the performance stability and reliability of distributed databases under high-load scenarios.

[0086] The embodiment of the present invention further provides a device for load balancing of a distributed database system, and the device is used to implement the method for load balancing of a distributed database system described in the above embodiment.

[0087] Through the above specific implementations, those skilled in the art can easily implement the present invention. However, it should be understood that the present invention is not limited to the above specific implementations. On the basis of the disclosed implementations, those skilled in the art can arbitrarily combine different technical features to achieve different technical solutions.

[0088] Except for the technical features described in the specification, all other technical features are known technologies to those skilled in the art.

Claims

1. A method for load balancing of a distributed database system, characterized in that: Optimize the sorting rules of hot data range copies. The index information required by the sorting rules includes: load pressure index set data, storage node processing capacity index set data; historical load data; and statistical information of the newly added load balancing scheduling service; Prioritize the candidate queues for migrating information data out of range copies and into target storage nodes. The sorting rules for hot data range copies are shown in Table 1-1: Table 1-1 The priority of migrating out the hotspot data range copy is calculated according to the sorting rules of the hotspot data range copy. The calculation rules are as follows: the comprehensive index value is calculated for the same attribute and is compared in order of priority: The index ranking of the load attribute is: value × weight = comprehensive index value. The higher the value, the hotter the range data is. The index ranking of resource attributes: value × weight = comprehensive index value. The higher the value, the tighter the resources of the node where the range data is located, and the more urgent the need to migrate the range replica. Indicator ranking of business attributes: the higher the net outflow of ranges and the higher the migration success rate, the higher the feasibility of migrating range replicas; The sorting rules of the migration target storage nodes are shown in Table 1-2 below: Table 1-2 The priority of the target storage node is calculated according to the sorting rule of the target storage node. The calculation rule is: the comprehensive index value of the same attribute is calculated and compared in order of priority: The index ranking of resource attributes: value × weight = comprehensive index value. The higher the index, the more abundant the resources are, and it is suitable for new replicas to migrate in, and it can be used as the target node. The index ranking of the load attribute is: value × weight = comprehensive index value. The higher the value, the hotter the range data is. Indicator sorting of business attributes: the higher the net inflow of ranges and the higher the migration success rate, the higher the feasibility of the node as the migration target storage node.

2. A method for load balancing of a distributed database system according to claim 1, characterized in that: The load pressure indicator set data includes: QPS, WPS, QPS and WPS of the business load being prepared for migration recorded in the statistical information, and the pressure peak value of the future load IO flow curve fitted according to the statistical information.

3. A method for load balancing of a distributed database system according to claim 1 or 2, characterized in that: The storage node processing capacity indicator set includes the following elements: storage node cache capacity, amount of stored data, number of schedulable threads, number of CPU cores and busyness of the machine where the node is located, memory usage percentage of the machine where the node is located, and remaining capacity and busyness of the node storage path hard disk.

4. A method for load balancing of a distributed database system according to claim 3, characterized in that: The historical load data includes the read and write data access volume, QPS / WPS peak, number of active ranges, and number of active replicas in the past 1 hour / 1 minute / 1 second.

5. A method for load balancing of a distributed database system according to claim 4, characterized in that: Statistics record historical load data and fit the future load IO traffic curve. The future load IO traffic curve fitting algorithm uses a polynomial function to fit the IO traffic curve. It trains the data of the past 24 hours based on the Bayesian method and the minimum likelihood function, and predicts the IO traffic curve of the next 12 hours. Data training and curve fitting updates are performed periodically every 12 hours.

6. A method for load balancing of a distributed database system according to claim 4, characterized in that: The statistical information of the newly added load balancing scheduling service includes the number and data volume of range replicas migrated in and out in the past 1 hour / 1 minute, the migration success rate, and the average time to respond to migration in and out.

7. A method for load balancing of a distributed database system according to claim 1 or 6, characterized in that: For the selection of the range replica to be migrated out / the target storage node to be migrated in, based on the calculation rules, 5 candidate targets, 3 candidate targets and 1 candidate target are retained in turn, so as to determine the final range replica to be migrated out / the target storage node to be migrated in.

8. A method for load balancing of a distributed database system according to claim 7, characterized in that: Statistics updates include: The statistical information of the historical load data of the storage node does not need to be updated. It can be obtained by accessing the system metric when obtaining relevant indicator information. This part of the data can be calculated and processed through the statistical information stored by the KaiwuDB time series engine; The load business statistics information is based on the data structure provided by the original metric interface. A statistical structure is added to the store instance structure to record it. It is updated when a range copy of a hot spot to be migrated is selected in the storage node or a raft request is received to process the range to be migrated.

9. A device for load balancing of a distributed database system, characterized in that: The device is used to implement the method for load balancing of a distributed database system as described in any one of claims 1 to 8.