Query load balancing method for distributed storage systems
By adopting the follower data query mechanism and cost evaluation routing strategy in the distributed storage system to dynamically select query nodes, the load balancing problem under the Raft algorithm is solved, and efficient resource utilization and system performance improvement are achieved.
Patent Information
- Application Number
- CN202210942370.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-08
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-08-08
AI Technical Summary
Existing distributed storage systems based on a single Raft algorithm have system load balancing problems. Storage resources are easily concentrated on some nodes, and client data processing traffic is completed by a single Leader node, causing the computing resources of other nodes to be idle and affecting system performance.
A data query routing strategy based on the follower data query mechanism and cost evaluation is adopted. By analyzing the resources consumed during the query process, the appropriate follower node is dynamically selected for data query to achieve load balancing and ensure data consistency and resource utilization.
It effectively improves the query load capacity of the system, makes full use of the computing resources of the follower nodes, improves system performance, and improves the overall performance of the system while maintaining data consistency.
Smart Images

Figure CN115378947B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer data query and storage, and in particular relates to a query load balancing method for a distributed storage system. Background Art
[0002] In the face of the demand for massive data storage, distributed storage systems can connect a large number of cheap PC servers through the network to provide storage services as a whole, breaking through the scalability and performance bottlenecks of single-machine storage, and have therefore been widely studied. Due to abnormal situations such as storage server node failures and network partitions, distributed storage systems are often designed to store data redundantly in multiple copies. When a node fails, data can be read from other copies to achieve fault tolerance. Replicas are the only means of fault tolerance in distributed storage systems, but due to the existence of multiple copies, how to ensure consistency between copies is the key to designing distributed systems.
[0003] The data consistency algorithm Raft is simple and easy to understand, and can effectively meet the data consistency requirements. However, the distributed storage system based on the single Raft algorithm still has the problem of system load balancing. Its storage resources are easy to concentrate on some nodes, and the client data processing traffic is completed by a single leader node. The computing resources of other nodes are always idle. The performance upper limit of the cluster depends on the data processing rate of the leader node in a single Raft cluster. During the query process, the query operation only interacts with the leader node. Although the follower node stores data, it cannot provide query services. Therefore, under the premise of maintaining data consistency, using the follower node to perform data query operations will greatly improve the query load capacity of the system and effectively utilize the computing resources of the follower node.
[0004] Therefore, it is very important to realize load-aware migration according to the resource situation of storage devices and balance the resource utilization of each device during the expansion and contraction of storage devices and data reading and writing, which is very important for improving the performance of distributed storage systems. Summary of the invention
[0005] The present invention aims at the problems existing in the prior art and provides a query load balancing method for a distributed storage system. Based on the follower data query mechanism, a data query routing strategy based on cost evaluation is designed. By analyzing the resources consumed in the query process, query nodes are dynamically selected to complete data query. Among them, the follower data query mechanism is: the query request concentrated on the leader is transferred to the follower node to execute data query; the data query routing strategy based on cost evaluation is: the communication overhead of each storage node currently stored is collected for dynamic cost evaluation, and the most suitable follower node is selected to execute the follower data query, so as to balance the computing resources of the nodes.
[0006] In order to achieve the above purpose, the technical solution adopted by the present invention is: a query load balancing method for a distributed storage system, based on a follower data query mechanism, a data query routing strategy based on cost evaluation is designed, and query nodes are dynamically selected by analyzing the resource consumption of the query process to complete data query;
[0007] The follower data query mechanism is: load transfer of query requests concentrated on the leader to the follower node to execute data query;
[0008] The data query routing strategy based on cost evaluation is: collecting the communication overhead of each storage node currently storing the data to perform dynamic cost evaluation, and selecting the most appropriate follower node to execute the follower data query.
[0009] As an improvement of the present invention, the follower data query mechanism specifically includes the following steps:
[0010] S1: Follower node accepts client data query request;
[0011] S2: The follower node initiates a log information verification request to the leader node. The request is to ensure that the follower node remains consistent with the leader's data when the states of the nodes in the cluster are constantly switching.
[0012] S3: The leader node confirms its own leadership status to other follower nodes, and responds to the follower with log information after obtaining authentication. The leader confirms its own leadership role by actively broadcasting heartbeat information to the follower nodes, and feeds back the CommitIndex of the current cluster to the follower nodes that request log information verification;
[0013] S4: The follower node receives the feedback information, executes the query operation and responds to the client after confirming that it has the latest data. The feedback information only includes the log information CommitIndex.
[0014] As another improvement of the present invention, the data query routing strategy based on cost evaluation specifically includes the following steps:
[0015] S1', statistical data query cost information: data query cost information statistics are performed by calculating the data size of each key-value pair in the data storage range partition;
[0016] S2', determining parameters: according to the data query cost information obtained by statistics in step S1', determining the constant factors affecting the cost evaluation, and calculating the parameters of the routing algorithm; the constant factors affecting the cost evaluation are computer hardware information;
[0017] S3', calculate the query operation cost: according to the data query routing strategy based on cost evaluation, calculate the query operation cost of each node, the query operation cost is the time consumption of the data processing process between the node and the storage layer;
[0018] S4', determine the destination node: determine the query route according to the operation cost value of step S3', and select a suitable destination node for data query according to the cost evaluation result of each node, that is, select a suitable follower node.
[0019] Compared with the prior art, the technical advantages of the present invention are:
[0020] (1) The load balancing method provided by the distributed storage system proposes a follower data query mechanism for the query process. The follower actively requests the leader to verify the log information. The leader confirms its own status by actively broadcasting, thereby providing data validity guarantee for subsequent data queries.
[0021] (2) When the follower node executes a data query, it verifies the log information with the leader node and confirms that its own data is in the latest state with minimal communication overhead, thereby increasing the system query load while achieving strong data consistency.
[0022] (3) Based on the follower query mechanism, a load balancing strategy that dynamically adapts to the usage of system resources is designed according to the relevant characteristics and parameters of computer hardware and network communication. This strategy fully utilizes the computing resources and storage resources of each node in the distributed system and effectively improves system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a flow chart of the steps of the follower data query mechanism in the method of the present invention;
[0024] Figure 2 It is a flow chart of the steps of the data query routing strategy based on cost evaluation in the method of the present invention;
[0025] Figure 3It is a structural framework flow chart of the follower data query mechanism in the method of the present invention;
[0026] Figure 4 It is a statistical diagram of range partition histogram information provided in Example 2 of the present invention;
[0027] Figure 5 This is a comparison chart of the performance of three data query methods: single leader query mechanism, follower data query mechanism, and cost evaluation-based data query routing strategy when the size of a single data is 1KB;
[0028] Figure 6 This is a comparison chart of the performance of three data query methods: single leader query mechanism, follower data query mechanism, and cost-evaluation-based data query routing strategy when the size of a single data is 5KB. DETAILED DESCRIPTION
[0029] The present invention will be further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0030] Example 1
[0031] A query load balancing method for distributed storage systems is designed based on the follower data query mechanism and a data query routing strategy based on cost evaluation. By analyzing the resources consumed by the query process, query nodes are dynamically selected to complete data queries.
[0032] The follower data query mechanism is: load transfer of query requests concentrated on the leader to the follower node to execute data query. This method can be applied to many data reading scenarios of distributed storage systems based on the Raft algorithm to maintain data consistency, solving the problem that Raft protocol data query is concentrated on the leader node.
[0033] Follower data query method, such as Figure 3 As shown in the figure, by sending query requests to the Follower nodes, the query load of the Leader is shared; when the Follower receives the query request from the client, it initiates a log submission verification request to the Leader; the Leader returns the current submitted log number to the Follower; after verifying that the local submitted log number is greater than or equal to the Leader, the Follower executes the query request and returns the query result to the client. Figure 1 As shown, the follower data query mechanism specifically includes the following steps:
[0034] Step S1: The follower node accepts the client's data query request, and does not impose any restrictions on the receiving method of the data query request;
[0035] Step S2: The follower node initiates a log information verification request to the leader node;
[0036] The follower obtains the log information CommitIndex of the cluster's committed data from the leader node of the current cluster. This request is to ensure that the follower node maintains consistency with the leader's data when the status of each node in the cluster is constantly switching, and to ensure the correctness of the data returned to the client;
[0037] Step S3: The leader node confirms its own leader status to other follower nodes, and responds to the followers with log information after obtaining authentication;
[0038] The switching of cluster status may cause the re-election, and the role of the leader node may change. Therefore, after receiving the verification request of the follower's log information CommitIndex, the leader actively broadcasts heartbeat information to the follower node to confirm its own leader role and ensure data consistency. After obtaining the response information of the majority of nodes, the leader node confirms its own leader role and then feeds back the current cluster CommitIndex to the follower node that requested log information verification;
[0039] Step S4: The follower node receives the feedback information, executes the query operation and responds to the client after confirming that it has the latest data;
[0040] The feedback information only contains the log information CommitIndex, so the communication overhead between the leader and the follower is extremely small. After obtaining the log information, the follower compares it with the log information of its own stored data. If the local CommitIndex is greater than or equal to the CommitIndex of the leader node, it can be confirmed that its own node has the latest data and can perform query operations, read the target data from the disk and respond to the client.
[0041] A query load balancing method for distributed storage systems, wherein a data query routing strategy based on cost evaluation is to establish a data query operation cost evaluation model, select a suitable target node according to the query time cost, and perform load balancing of the query operation, such as Figure 2 As shown, the steps specifically include:
[0042] Step S1', statistical data query cost information:
[0043] Through the partition information management design in the data storage, the data query cost information statistics are performed, and the formula used to calculate the data size of each key-value pair in the range partition is as follows:
[0044]
[0045] averageSize is used to indicate the average data size of each key-value pair;
[0046] range total Used to indicate the total size of data that the current partition is responsible for;
[0047] range keys Used to indicate the number of key-value pairs stored in the current partition;
[0048] Table 1 below shows the performance parameters of commonly used hardware in computer architecture. It can be seen from the table that the speed of CPU and memory processing data is dozens or even thousands of times faster than that of network and disk IO. Therefore, the processing time of data in CPU and memory can be ignored. The cost of disk and network time consumption during data query is evaluated, and a specific node selection algorithm for query is given.
[0049] Table 1 Common hardware performance parameters
[0050]
[0051] Step S2', determining parameters: according to the data query cost information obtained by statistics in step S1', determining the constant factors affecting the cost evaluation, and calculating the routing algorithm parameters;
[0052] In this embodiment, some computer hardware information is selected as constant factors for the final cost evaluation algorithm, and information such as network consumption transmitted between different nodes is calculated as algorithm parameters for routing selection.
[0053] Step S3', calculate the query operation cost: according to the data query routing strategy based on cost evaluation, calculate the query operation cost of each node, the query operation cost is the time consumption of the data processing process between the node and the storage layer;
[0054] In this example, the data query processing flow is completed by the computing node agent, and the query results are responded to the client, so only the time consumed by the data processing process between the node and the storage layer can be calculated. The time consumption evaluation formulas for the computing node to query data through the leader node and follower node of the Raft cluster are shown in the following formulas.
[0055]
[0056]
[0057] Query Leader It is used to indicate the total time consumed by the query through the leader node.
[0058] Query FollowerIt is used to indicate the total time consumed by querying through follower nodes.
[0059] Cost C-L Used to indicate the network consumption of the computing node and the Leader transmission;
[0060] Cost L-C Used to indicate the network consumption of the Leader and the computing nodes;
[0061] Cost C-F Used to indicate the network consumption between computing nodes and followers;
[0062] Cost F-C Used to indicate the network consumption between Follower and computing node;
[0063] Result Size Used to indicate the estimated size of the query result set;
[0064] It is used to indicate the latency consumption of the query result set during the transmission between the leader and the computing node;
[0065] Used to indicate the latency consumption of the query result set during the transmission process between the follower and the computing node.
[0066] Cost F-L Used to indicate the network consumption of Leader nodes and Follower nodes;
[0067] λ is used to represent the consumption of disk reading data;
[0068] When evaluating the cost, the parameter values of each parameter need to be obtained. The specific acquisition method is as follows:
[0069] Cost C-L / Cost L-C Cost C-F / Cost F-C , take the method of periodic polling to obtain the estimated value. Redis supports the PING command for testing node connectivity. When the computing layer sends this command to the specified storage layer node, the storage node will not transfer it to the Raft algorithm process for processing, but will directly respond to the computing layer node to detect the connectivity between the computing node and the storage node. The computing node roughly estimates the network transmission consumption with each node in the storage layer by calculating the time difference between the issuance of the PING command and the receipt of the response, and saves it through the Map data structure. In order to dynamically evaluate the size of this value, the user can set the interval of periodic polling. The smaller the time interval, the more accurately the evaluation value can describe the transmission time between nodes.
[0070] Result Size Each Range Leader in the storage layer node will periodically send heartbeats to the scheduling layer to synchronize the current Range status information, including the amount of stored data and the number of key-value pairs in each Range. If the scheduling layer detects that the Range statistics have changed, it will be synchronized to the computing node. The computing node uses the B-tree to maintain all Ranges in the cluster. When querying data, it can quickly locate the Range corresponding to the primary key by searching the B-tree, and estimate the size of the result set data of its query operation based on the Range statistics.
[0071] Cost F-L , the present invention uses an estimation method to obtain the transmission delay between the Follower node and the Leader node. When the storage layer node is started, the node label information, including location, computer room, and rack, needs to be configured. If two nodes are located in different computer rooms, their Cost F-L The value range is 15-50ms. If the two nodes are located in the same computer room, the value can be 0.1-0.25ms.
[0072] The query cost of the leader node is calculated in the formula For example, there are many factors that affect the estimation result of this parameter, including network bandwidth, network congestion, and the distance between the sending and receiving nodes. Size (MB) of data blocks at a bandwidth of Band net The time consumption for transmission in the network is calculated as shown in the following formula:
[0073]
[0074] However, in actual network transmission, the above calculation method is not accurate. For example, the transmission delay between a LAN Gigabit network and an inter-city Gigabit network is more than ten times different. Network congestion and transmission distance must also be considered. Therefore, this section introduces a correction factor to make the estimated result as close to the actual value as possible. The calculation method is shown in the following formula:
[0075]
[0076] In order to dynamically calculate the transmission consumption of data in the network, Cost L-C As a real test value, its value will change in real time with network usage. σ is the introduced correction factor, and its value range is between (0.1, 1), which is selected according to the actual situation.
[0077] λ, the value is related to the storage node disk type and the amount of query data. Disk types can be divided into solid-state drives (SSDs) and mechanical hard disks (HDDs). The data reading speeds of different models of the same product also vary. The evaluation formula for λ is shown in the following formula, where ν read Indicates the read rate of the disk. The disk read rate is usually marked at the factory, and the value can also be obtained through read and write tests.
[0078] λ=result Size * read
[0079] S4', determine the destination node: determine the query route according to the operation cost value of step S3', and select a suitable destination node for data query according to the cost evaluation result of each node, that is, select a suitable follower node.
[0080] After determining the appropriate follower node, the data query is executed according to the follower data query mechanism. Based on the follower data query mechanism, this method formulates a load balancing strategy that dynamically adapts to the system resource usage, fully utilizes the computing resources and storage resources of each node in the distributed system, and effectively improves the system performance.
[0081] Example 2
[0082] The difference between this embodiment and embodiment 1 is that in step S1' of the data query routing strategy based on cost evaluation, the statistical method of describing the data size of each key-value pair can also be used, such as Figure 4 As shown in the figure, there are 4 histogram blocks, each histogram represents a Range, the length of the horizontal axis represents the number of key-value pairs contained in the Range, and the length of the vertical axis represents the amount of data stored in the current Range. To simplify the model, it is assumed that the amount of data stored in each Range is 64MB, but the number of key-value pairs stored is different, so the average value of the key-value pair data in each Range partition can be calculated. According to the above analysis, the information statistics method based on Range has finer granularity and more accurate data statistics information than scanning the entire disk data for mean estimation.
[0083] Test Case
[0084] Three storage nodes were deployed in this test case. After the node was started, 200,000 pieces of data were written, with a total data volume of about 200MB. The performance indicators of the GET instruction under the single leader query mechanism (Leader Based), follower query mechanism (Follower Read) and cost-based routing selection method CostBased were verified.
[0085] The experimental results are as follows Figure 5As shown. When the concurrency is small, the leader node can better cope with the throughput demand, and the follower query mechanism has the worst performance. Since the current test environment is deployed in a local area network, the network delay during the test is not the main factor affecting the system throughput. The choice of reading from the follower causes additional network overhead. Although the cost evaluation-based routing selection method can calculate the query cost, the query cost calculation process requires program locking, which has a certain impact on performance. When the concurrency increases, the leader load increases, resulting in a performance bottleneck. Reading data from the follower node can improve the system throughput, so the OPS is higher. Figure 6 The experimental results of the case where the single data volume is 5KB are shown. Similar to 1KB, when the number of concurrent connections is small, the performance of the follower query mechanism is the worst, followed by the cost evaluation-based routing selection method, and the single leader query mechanism method is the best. However, as the number of concurrent connections increases, since the single data is larger at this time, more resources are consumed on the leader node, so the follower query mechanism and the cost evaluation-based routing selection method can effectively improve system performance.
[0086] Through experiments under two different data sizes, it can be concluded that the data query load balancing method based on cost evaluation can comprehensively calculate the data query cost of each node in the Raft cluster and select the appropriate node for query operations. This method can be balanced under both the single leader query mechanism and the follower query mechanism, and has good performance under different concurrency sizes.
[0087] It should be noted that the above content merely illustrates the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications all fall within the protection scope of the claims of the present invention.
Claims
1. A query load balancing method for a distributed storage system, characterized in that: Based on the follower data query mechanism, a data query routing strategy based on cost evaluation is designed. By analyzing the resources consumed during the query process, query nodes are dynamically selected to complete data query. The follower data query mechanism is: load transfer of query requests concentrated on the leader to the follower node to execute data query; specifically including: S1: Follower node accepts client data query request; S2: The follower node initiates a log information verification request to the leader node. The request is to ensure that the follower node remains consistent with the leader's data when the states of the nodes in the cluster are constantly switching. S3: The leader node confirms its own leadership status to other follower nodes, and responds to the follower with log information after obtaining authentication. The leader confirms its own leadership role by actively broadcasting heartbeat information to the follower nodes, and feeds back the CommitIndex of the current cluster to the follower nodes requesting log information verification; S4: The follower node receives the feedback information, executes the query operation and responds to the client after confirming that it has the latest data. The feedback information only includes the log information CommitIndex; The data query routing strategy based on cost evaluation is: collecting the communication overhead of each storage node currently stored to perform dynamic cost evaluation, and selecting the most appropriate follower node to execute the follower data query; specifically including: S1', statistical data query cost information: data query cost information statistics are performed by calculating the data size of each key-value pair in the data storage range partition; S2', determining parameters: according to the data query cost information obtained by statistics in step S1', determining the constant factors affecting the cost evaluation, and calculating the parameters of the routing algorithm; the constant factors affecting the cost evaluation are computer hardware information; S3', calculate the query operation cost: according to the data query routing strategy based on cost evaluation, calculate the query operation cost of each node, the query operation cost is the time consumption of the data processing process between the node and the storage layer; S4', determine the destination node: determine the query route according to the operation cost value of step S3', and select a suitable destination node for data query according to the cost evaluation result of each node, that is, select a suitable follower node.
2. The query load balancing method for a distributed storage system according to claim 1, characterized in that: In step S4 of the follower data query mechanism, after receiving the feedback information, the follower node compares it with the log information of its own stored data. If the local CommitIndex is greater than or equal to the CommitIndex of the leader node, it can be confirmed that its own node has the latest data, execute the query operation, read the target data and respond to the client.
3. The query load balancing method for a distributed storage system according to claim 2, characterized in that: The data size of each key-value pair in the data storage range partition is calculated as follows: Among them, averageSize is used to represent the average size of the data of each key-value pair; range total Used to indicate the total size of the data that the current partition is responsible for; range keys Used to indicate the number of key-value pairs stored in the current partition.
4. The query load balancing method for a distributed storage system according to claim 3, characterized in that: The data size of each key-value pair in the data storage range partition is calculated through histogram information. Each histogram represents a Range, and the length of the horizontal axis represents the number of key-value pairs contained in the Range, and the length of the vertical axis represents the amount of data stored in the current Range. According to the different numbers of stored key-value pairs, the average value size of the key-value pair data in each Range partition can be calculated.
5. The query load balancing method for a distributed storage system according to claim 3 or 4, characterized in that: In step S3', the time consumption of the data processing process between the node and the storage layer through the leader node and follower node of the Raft cluster is calculated as follows: Among them, Query Leader Used to indicate the total time consumed by the leader node to query; Follower Used to indicate the total time consumed by querying through follower nodes; Cost C-L Used to represent the network consumption of the computing node and the leader; Cost L-C Used to represent the network consumption of the leader and the computing node; Cost C-F Used to represent the network consumption of the computing node and the follower transmission; Cost F-C Used to indicate the network consumption of the follower and the computing node transmission; result Size Used to indicate the estimated size of the query result set; Cost F-L It is used to represent the network consumption of the leader node and the follower node; λ is used to represent the consumption of disk reading data; Used to indicate the latency consumption of the query result set during the transmission between the leader and the computing node; Used to indicate the latency consumption of the query result set during the transmission process between the follower and the computing node.
6. The query load balancing method for a distributed storage system according to claim 5, characterized in that: The network consumption value Cost transmitted between the node and the leader C-L , the network consumption value Cost of the transmission between the leader and the computing node L-C , the network consumption value Cost of the transmission between nodes and followers C-F , the network consumption value Cost of the transmission between the follower and the computing node F-C All data are obtained by periodic polling; The network consumption value of the leader node and the follower node Cost F-L If the two nodes are located in different computer rooms, their Cost F-L The value range is 15-50ms. If the two nodes are located in the same computer room, the value is 0.1-0.25ms.
7. The query load balancing method for a distributed storage system according to claim 6, characterized in that: The consumption value λ of disk reading data is related to the storage node disk type and the amount of query data, specifically: λ=result Size *n read Among them, ν read Indicates the disk read rate.
