A cluster service load balancing strategy method based on consistent hashing algorithm

CN116860444BActive Publication Date: 2026-10-27国网福建省电力有限公司营销服务中心 +3
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310818757.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-05
Publication Date
2026-10-27
Estimated Expiration
2043-07-05

AI Technical Summary

Technical Problem

[0004]针对现有技术存在的不足,本发明提供了一种基于一致哈希算法的集群服务负载均衡策略方法,能够将服务器细分为终端设备以及前置机,通过对终端设备以及前置机进行一致哈希运算后,对终端设备分配一致哈希节点,对前置机分配哈希段,再对数据进行一致哈希运算后为其分配终端设备,前置机通过获取哈希段内的终端设备的数据进行处理,达到集群服务负载均衡的目的,同时,在负载分配完成后实时监测终端设备以及前置机的负载峰值,根据负载峰值调整服务器内终端设备以及前置机的数量,以解决现有的服务器负载分配技术还存在对服务器负载分析不足以及负载分配运算较慢,导致服务器处理数据的效率不足的问题

Benefits of technology

[0053]本发明的有益效果:本发明通过将服务器细分为终端设备以及前置机,并建立哈希环,通过一致哈希算法为终端设备分配哈希节点,并为前置机分配哈希段,前置机通过获取哈希段内包含的终端设备的上报数据进行处理,达到集群服务负载均衡的目的,提高了服务器负载分配的合理性以及均衡性;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116860444B_ABST
    Figure CN116860444B_ABST
Patent Text Reader

Abstract

The application provides a cluster service load balancing strategy method based on a consistent hash algorithm, relates to the technical field of server load distribution, and comprises the following steps: step S1, calculating a consistent hash value of a terminal device; step S2, calculating a virtual hash value of the terminal device; step S3, constructing a consistent hash ring; step S4, calculating a Key value of reported data; step S5, sending the reported data to a front-end processor corresponding to a hash segment for processing; step S6, establishing a load database and inputting load conditions of a current time period; and step S7, changing a cluster service operation mode according to the load conditions. The application is used to solve the problems that the existing server load distribution technology is insufficient in server load analysis and slow in load distribution operation, and the efficiency of server data processing is insufficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of server load distribution technology, and in particular to a cluster service load balancing strategy technology based on a consistent hashing algorithm. Background Technology

[0002] Server load balancing technology refers to the technique of distributing user requests across multiple servers to improve system performance and reliability by having them handle the requests together. The purpose of load balancing technology is to achieve balanced utilization of resources and avoid system crashes or slow operation caused by excessive load on a single server. Common load balancing technologies include DNS-based load balancing, hardware-based load balancing, software-based load balancing, content-based load balancing, and session-based load balancing.

[0003] Existing server load balancing technologies typically calculate server load using hash algorithms and then directly send data to the server for processing. This results in a large computational load and slow processing speed. Furthermore, existing server load balancing technologies neglect to analyze the actual server load after load balancing, potentially leading to excessively high server load and reduced data processing efficiency. These technologies also suffer from insufficient server load analysis and slow load balancing calculations, resulting in inefficient data processing. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a cluster service load balancing strategy method based on consistent hashing algorithm. This method subdivides servers into terminal devices and front-end machines. After performing consistent hashing on the terminal devices and front-end machines, consistent hash nodes are assigned to the terminal devices, and hash segments are assigned to the front-end machines. Then, consistent hashing is performed on the data, and terminal devices are assigned to them. The front-end machines process the data from the terminal devices within the hash segments, achieving cluster service load balancing. Simultaneously, after load allocation, the peak load of the terminal devices and front-end machines is monitored in real time, and the number of terminal devices and front-end machines within the server is adjusted based on the peak load. This addresses the problems of insufficient server load analysis and slow load allocation calculation in existing server load allocation technologies, leading to inefficient server data processing.

[0005] To achieve the above objectives, the present invention provides a cluster service load balancing strategy method based on a consistent hashing algorithm, comprising the following steps:

[0006] Step S1: Name and number several terminal devices, label them as terminal names, and calculate the consistent hash value of each terminal device using a consistent hash algorithm;

[0007] Step S2: Configure additional names for terminal devices and configure virtual nodes for several terminal devices using a virtual hash algorithm;

[0008] Step S3: Construct a consistent hash ring and distribute the terminal devices within the consistent hash ring; allocate a certain number of hash segments to the front-end machine;

[0009] Step S4: Obtain the reported data, calculate the Key value of the reported data using a consistent hash algorithm, and store the reported data into the terminal device according to the Key value;

[0010] Step S5: Send the stored data in the terminal device to the front-end machine corresponding to the hash segment where the terminal device is located for data processing;

[0011] Step S6: Establish a load database and enter the load information for the current time period;

[0012] Step S7: Read the load database, analyze the load situation for the time period, and change the cluster service operation mode based on the analysis results.

[0013] Further, step S1 includes the following sub-steps:

[0014] Step S101: Name and number several terminal devices, and mark them as terminal names;

[0015] Step S102: Calculate the consistent hash value for each terminal device using a consistent hash algorithm;

[0016] The consistent hash algorithm is configured as follows: H = Hash(M) % 232; where H is the consistent hash value, M is the terminal name of the terminal device, and Hash is the hash operator.

[0017] Further, step S2 includes the following sub-steps:

[0018] Step S201: Configure an additional name for the terminal device and mark it as a virtual name;

[0019] Step S202: Calculate the virtual hash value of the virtual name using a virtual hash algorithm;

[0020] The virtual hash algorithm is configured as follows: Hx = Hash(Mx) % 232; where Hx is the virtual hash value, Mx is the virtual name of the terminal device, and Hash is the hash operator.

[0021] Further, step S3 includes the following sub-steps:

[0022] Step S301: Construct a consistent hash ring;

[0023] Step S302: Obtain the consistent hash value of the terminal device and place the device node of the terminal device at the hash ring node with the same consistent hash value in the consistent hash ring;

[0024] Step S303: Obtain the virtual hash value of the terminal device, and place the virtual node of the terminal device at the hash ring node in the consistent hash ring that has the same virtual hash value;

[0025] Step S304: Obtain the number of front-end machines and mark it as the number of front-end machines;

[0026] Step S305, using the formula Calculate the number of hash nodes allocated to each front-end machine, where Ds is the number of hash nodes and T is the number of front-end machines;

[0027] Step S306: Number the front-end machines and allocate hash segments to them in ascending order of their numbers. Each hash segment contains hash loops, and the number of hash loops is equal to the number of hash loops.

[0028] Further, step S4 includes the following sub-steps:

[0029] Step S401: Receive the reported data and number the reported data;

[0030] Step S402: Calculate the Key value of the reported data using a data hash algorithm;

[0031] The data hash algorithm is configured as Key = Hash(O) % 232; where Key is the Key value of the reported data and O is the number of the reported data.

[0032] Step S403: Obtain the Key value, increase the Key value. If the Key value is greater than 232, adjust the Key value to zero and continue to increase it until the Key value is equal to the consistent hash value of a certain terminal device.

[0033] Step S404: Store the reported data corresponding to the Key value into a terminal device with the same consistent hash value as the Key value.

[0034] Further, step S5 includes the following sub-steps:

[0035] Step S501: Detect the distribution of consistent hash values ​​in the hash segment;

[0036] Step S502: Obtain the terminal device corresponding to the consistent hash value contained in the hash segment corresponding to the front-end machine;

[0037] Step S503: Connect the front-end machine and the terminal device, obtain the data stored in the terminal device, and perform data processing.

[0038] Further, step S6 includes the following sub-steps:

[0039] Step S601: Establish the load database;

[0040] Step S602: Using a first time threshold as a time period, record the load data of each terminal device and the front-end machine. The load data includes the peak load of the terminal and the peak load of the front-end machine.

[0041] Further, step S7 includes the following sub-steps:

[0042] Step S701: Read the load database to obtain the peak terminal load and peak front-end load within the current time period;

[0043] Step S702: Compare the terminal load peak value with the first terminal load threshold and the second terminal load threshold. If the terminal load peak value is less than or equal to the first terminal load threshold, output a terminal load too low signal; if the terminal load peak value is greater than the first terminal load threshold and less than or equal to the second terminal load threshold, output a terminal load normal signal; if the terminal load peak value is greater than the second terminal load threshold, output a terminal load too high signal.

[0044] Step S703: If the output terminal load is too low, remove the backup terminal from the cluster server and redistribute the reported data; if the output terminal load is normal, maintain the number of terminal devices in the cluster server; if the output terminal load is too high, add a backup terminal to the cluster server, calculate its consistent hash value and virtual hash value, and re-analyze the terminal devices allocated to the reported data; after processing, obtain the terminal load peak value and analyze it until the output terminal load is normal.

[0045] Step S704: Compare the peak load of the front-end processor with the first front-end processor load threshold and the second front-end processor load threshold. If the peak load of the front-end processor is less than or equal to the first front-end processor load threshold, output a front-end processor load too low signal; if the peak load of the front-end processor is greater than the first front-end processor load threshold and less than or equal to the second front-end processor load threshold, output a front-end processor load normal signal; if the peak load of the front-end processor is greater than the second front-end processor load threshold, output a front-end processor load too high signal.

[0046] In step S705, if the output front-end load signal is too low, the standby front-end in the cluster server is removed and the hash segment is redistributed; if the output front-end load signal is normal, the number of front-ends in the cluster server is maintained; if the output front-end load signal is too high, a standby front-end is added to the cluster server and the hash segments of all front-ends are redistributed until the output front-end load signal is normal.

[0047] Furthermore, it also includes step S8, which includes the following sub-steps:

[0048] Step S801: Identify the load characteristics of each service cluster by reading the load database;

[0049] Step S802: Index the corresponding family configuration information from the pre-built family topology library according to the load characteristics and the topology relationship of the service cluster. The family configuration information includes different terminal family types and the number of each terminal family type.

[0050] Step S803: Configure the load terminals into different terminal family types according to the family configuration information. The terminal family type includes a parent type, an elder brother type, and a younger brother type. The parent type is configured to prioritize processing tasks outside the service cluster. The elder brother type is set according to the parent type and is configured to prioritize processing tasks distributed by the parent type. A load balancing algorithm is configured between the younger brother types. The load balancing algorithm is used to balance the tasks between the younger brother types.

[0051] Step S804: Configure different encryption levels in the hash segment for the load terminals corresponding to the parent type, elder brother type, and younger brother type.

[0052] Furthermore, in step S803, a first conversion condition and a second conversion condition are also configured. When there is a load terminal of type 1 in the service cluster that meets the first conversion condition, the terminal family type of the load terminal is converted to the type 2 with a preset first conversion time. When there is a load terminal of type 2 in the service cluster that meets the second conversion condition, the terminal family type of the load terminal is converted to the type 1 with a preset second conversion time.

[0053] The beneficial effects of the present invention are as follows: The present invention subdivides the server into terminal devices and front-end machines, establishes a hash ring, allocates hash nodes to terminal devices and hash segments to front-end machines through a consistent hash algorithm, and processes the reported data of terminal devices contained in the hash segments, thereby achieving the purpose of cluster service load balancing and improving the rationality and balance of server load distribution.

[0054] This invention sets a virtual name for the terminal device and calculates the virtual hash node of the terminal device using a consistent hash algorithm. The advantage is that it can reduce the amount of computation in load analysis when distributing reported data and improve the timeliness of server load analysis.

[0055] This invention establishes a load database, records load data for the current time period, and analyzes whether the load is too high by measuring the peak load of terminals and the peak load of front-end machines. It then adjusts the number of terminal devices and front-end machines in the server in real time, thereby improving the accuracy of server load analysis and the rationality of load allocation.

[0056] Advantages of additional aspects of the invention will be set forth in part in the detailed description of the invention below, and in part will be obvious from the description or may be learned by practice of the invention. Attached Figure Description

[0057] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0058] Figure 1 This is a partial flowchart of the method of the present invention. Detailed Implementation

[0059] To make the technical means, creative features, objectives and effects of this invention easier to understand, the invention will be further described below in conjunction with specific embodiments.

[0060] This invention provides a cluster service load balancing strategy method based on consistent hashing algorithm. It can subdivide servers into terminal devices and front-end machines. After performing consistent hashing on the terminal devices and front-end machines, consistent hashing nodes are assigned to the terminal devices, and hash segments are assigned to the front-end machines. Then, consistent hashing is performed on the data, and terminal devices are assigned to them. The front-end machines process the data from the terminal devices within the hash segments, achieving the goal of cluster service load balancing. Simultaneously, after load allocation, the peak load of the terminal devices and front-end machines is monitored in real time, and the number of terminal devices and front-end machines within the server is adjusted according to the peak load. This addresses the problems of insufficient server load analysis and slow load allocation calculation in existing server load allocation technologies, leading to inefficient server data processing.

[0061] Please see Figure 1 The cluster service load balancing strategy method includes steps S1, S2, S3, S4, S5, S6 and S7.

[0062] Step S1 involves naming and numbering several terminal devices, labeling them as terminal names, and calculating the consistent hash value for each terminal device using a consistent hash algorithm. Step S1 includes the following sub-steps:

[0063] Step S101: Name and number several terminal devices, and mark them as terminal names;

[0064] Step S102: Calculate the consistent hash value for each terminal device using a consistent hash algorithm;

[0065] The consistent hash algorithm is configured as follows: H = Hash(M) % 232; where H is the consistent hash value, M is the terminal name of the terminal device, and Hash is the hash operator;

[0066] In practice, the hash operator uses the MD2 hash algorithm. The terminal names are Node1, Node2, Node3, Node4 and Node5. The consistent hash values ​​of the terminal devices are calculated by the consistent hash algorithm as 1900019712, 2952790016, 696254464, 4026531840 and 1258291200 respectively.

[0067] Step S2 involves configuring additional names for the terminal devices and configuring virtual nodes for several terminal devices using a consistent hash algorithm. Step S2 includes the following sub-steps:

[0068] Step S201: Configure an additional name for the terminal device and mark it as a virtual name;

[0069] Step S202: Calculate the virtual hash value of the virtual name using a virtual hash algorithm;

[0070] The virtual hash algorithm is configured as follows: Hx = Hash(Mx) % 232; where Hx is the virtual hash value, Mx is the virtual name of the terminal device, and Hash is the hash operator;

[0071] In the specific implementation, the virtual names are set as Node1#1, Node2#1, Node3#1, Node4#1 and Node5#1 respectively. The virtual hash values ​​calculated by the virtual hash algorithm are 1145044992, 3321888768, 1136656384, 2231369728 and 2573205504 respectively.

[0072] Step S3: Construct a consistent hash ring and distribute the terminal devices within the consistent hash ring; allocate a certain number of hash segments to the front-end machine; Step S3 includes the following sub-steps:

[0073] Step S301: Construct a consistent hash ring;

[0074] In specific implementation, the consistent hash ring is a closed loop formed by connecting 0 and (2^32)-1 in the number space from 0 to (2^32)-1.

[0075] Step S302: Obtain the consistent hash value of the terminal device and place the device node of the terminal device at the hash ring node with the same consistent hash value in the consistent hash ring;

[0076] Step S303: Obtain the virtual hash value of the terminal device, and place the virtual node of the terminal device at the hash ring node in the consistent hash ring that has the same virtual hash value;

[0077] In specific implementation, if the consistent hash value of Node1 is 1900019712, then the device node of Node1 will be connected to the hash ring node with hash value of 1900019712 within the consistent hash ring; if the virtual hash value of Node1#1 is 1145044992, then the virtual node of Node1#1 will be connected to the hash ring node with hash value of 1145044992 within the consistent hash ring.

[0078] Step S304: Obtain the number of front-end machines and mark it as the number of front-end machines;

[0079] Step S305, using the formula Calculate the number of hash nodes allocated to each front-end machine, where Ds is the number of hash nodes and T is the number of front-end machines;

[0080] Step S306: Number the front-end machines and allocate hash segments to the front-end machines in ascending order of their numbers. Each hash segment contains hash ring points, and the number of hash ring points is equal to the number of hash ring points.

[0081] In specific implementation, if the number of front-end machines T is 5, then the number of hash link points Ds is calculated to be 858993459, and the calculation result is rounded to the nearest integer. If the front-end machine numbers are G1, G2, G3, G4 and G5, then the hash segment allocated to G1 is [0, 858993459], the hash segment allocated to G2 is (858993459, 1717986918], the hash segment allocated to G3 is (1717986918, 2576980377], the hash segment allocated to G4 is (2576980377, 3435973836], and the hash segment allocated to G5 is (3435973836, 4294967296].

[0082] Step S4: Obtain the reported data, calculate the Key value of the reported data using a consistent hash algorithm, and store the reported data into the terminal device according to the Key value; Step S4 includes the following sub-steps:

[0083] Step S401: Receive the reported data and number the reported data;

[0084] Step S402: Calculate the Key value of the reported data using a data hash algorithm;

[0085] The data hash algorithm is configured as Key = Hash(O) % 232; where Key is the Key value of the reported data and O is the number of the reported data.

[0086] Step S403: Obtain the Key value, increase the Key value. If the Key value is greater than 232, adjust the Key value to zero and continue to increase it until the Key value is equal to the consistent hash value of a certain terminal device.

[0087] Step S404: Store the reported data corresponding to the Key value into a terminal device with the same consistent hash value as the Key value;

[0088] In practice, if the reported data number is Object1, the Key value is calculated to be 1803550720 through the data hash algorithm. The Key value is increased. When the Key value increases to 1900019712, it is equal to the consistent hash value of the terminal device Node1. Then the reported data Object1 is stored in the terminal device Node1.

[0089] Step S5 involves sending the stored data from the terminal device to the front-end machine corresponding to the hash segment where the terminal device is located for data processing. Step S5 includes the following sub-steps:

[0090] Step S501: Detect the distribution of consistent hash values ​​in the hash segment;

[0091] Step S502: Obtain the terminal device corresponding to the consistent hash value contained in the hash segment corresponding to the front-end machine;

[0092] Step S503: Connect the front-end machine and the terminal device, obtain the data stored in the terminal device, and perform data processing;

[0093] In specific implementation, the consistent hash value of terminal device Node1 is 1900019712, which belongs to the hash segment (1717986918, 2576980377). Therefore, the reported data Object1 is uploaded to the front-end machine G3 for data processing.

[0094] Step S6: Establish a load database and enter the load information for the current time period; Step S6 includes the following sub-steps:

[0095] Step S601: Establish the load database;

[0096] Step S602: Using the first time threshold as a time period, record the load data of each terminal device and the front-end machine. The load data includes the peak load of the terminal and the peak load of the front-end machine.

[0097] In practice, the first time threshold is set to 1 hour, the peak load of the input terminal is 0.42, and the peak load of the front-end machine is 0.54.

[0098] Step S7: Read the load database, analyze the load situation over a time period, and change the cluster service operation mode based on the analysis results; Step S7 includes the following sub-steps:

[0099] Step S701: Read the load database to obtain the peak terminal load and peak front-end load within the current time period;

[0100] Step S702: Compare the terminal load peak value with the first terminal load threshold and the second terminal load threshold. If the terminal load peak value is less than or equal to the first terminal load threshold, output a terminal load too low signal; if the terminal load peak value is greater than the first terminal load threshold and less than or equal to the second terminal load threshold, output a terminal load normal signal; if the terminal load peak value is greater than the second terminal load threshold, output a terminal load too high signal.

[0101] Step S703: If the output terminal load is too low, remove the backup terminal from the cluster server and redistribute the reported data; if the output terminal load is normal, maintain the number of terminal devices in the cluster server; if the output terminal load is too high, add a backup terminal to the cluster server, calculate its consistent hash value and virtual hash value, and re-analyze the terminal devices allocated to the reported data; after processing, obtain the terminal load peak value and analyze it until the output terminal load is normal.

[0102] In specific implementation, the first terminal load threshold is set to 0.20, the second terminal load threshold is set to 0.60, the terminal load peak value is obtained as 0.42, and the front-end load peak value is 0.54. Then, by comparison, it is found that the terminal load peak value is greater than the first load threshold and less than the second load threshold. Then, a terminal load normal signal is output to maintain the number of terminal devices in the cluster server.

[0103] Step S704: Compare the peak load of the front-end processor with the first front-end processor load threshold and the second front-end processor load threshold. If the peak load of the front-end processor is less than or equal to the first front-end processor load threshold, output a front-end processor load too low signal; if the peak load of the front-end processor is greater than the first front-end processor load threshold and less than or equal to the second front-end processor load threshold, output a front-end processor load normal signal; if the peak load of the front-end processor is greater than the second front-end processor load threshold, output a front-end processor load too high signal.

[0104] Step S705: If the output front-end load is too low, remove the standby front-end in the cluster server and reallocate the hash segment; if the output front-end load is normal, maintain the number of front-ends in the cluster server; if the output front-end load is too high, add a standby front-end to the cluster server and reallocate the hash segments of all front-ends until the output front-end load is normal.

[0105] In practice, the first front-end load threshold is set to 0.3 and the second front-end load threshold is 0.7. If the peak load of the front-end is greater than the first front-end load threshold but less than the second front-end load threshold, a normal front-end load signal is output to maintain the number of front-end servers in the cluster.

[0106] It also includes step S8, which includes the following sub-steps:

[0107] Step S801: Identify the load characteristics of each service cluster by reading the load database. The load database can obtain the historical load situation of each load terminal. First, a processing curve function is generated based on the load capacity of each terminal. Then, the load margin waveform is calculated by comparing the waveform corresponding to the historical load situation. The load margin waveform is then divided into intervals, and the effective duration corresponding to each load interval is counted. The corresponding load characteristics are generated by the ratio of the effective duration of different intervals. Then, the load characteristics of the entire service cluster are calculated using the same logic, and the advantages of using the cluster method can be obtained.

[0108] Step S802: Based on the load characteristics, index the corresponding family configuration information from the pre-built family topology library in the service cluster topology relationship. The family configuration information includes different terminal family types and the number of each terminal family type. Different topology relationships are pre-built for different load characteristics. For example, if the load characteristics fluctuate greatly, there are more tasks that need to be coordinated, so more sibling nodes are needed. If the task interaction volume is large, more parent nodes are needed. Therefore, the characteristics of the service cluster can be configured according to the above content.

[0109] Step S803: Configure load terminals into different terminal family types according to the family configuration information. The terminal family type includes a parent type, an elder brother type, and a younger brother type. The parent type is configured to prioritize processing tasks outside the service cluster. The elder brother type corresponds to the parent type and is configured to prioritize processing tasks distributed by the parent type. A load balancing algorithm is configured among the younger brother types to balance the tasks among them. The specific basis for configuring load family types on the load is to prioritize the communication relationship between loads and the data processing capacity of the load. Elder brother nodes prioritize communication relationships, and the more other load terminals they connect to, the more likely they are to be selected as the corresponding type of node. Parent nodes prioritize communication relationships with external clusters, and the more external clusters they connect to, the easier it is for them to be selected as the corresponding type of node.

[0110] Step S804: Configure different encryption levels in the hash segment for the load terminals corresponding to the parent type, elder brother type, and younger brother type. This allows data encryption to be completed according to the new configuration.

[0111] In step S803, a first conversion condition and a second conversion condition are also configured. When a load terminal of type 1 in the service cluster meets the first conversion condition, the terminal family type of that load terminal is converted to type 2 with a preset first conversion duration. When a load terminal of type 2 in the service cluster meets the second conversion condition, the terminal family type of that load terminal is converted to type 2 with a preset second conversion duration. Through the conversion of service cluster types, the conditions can be dynamically adjusted according to the actual load situation. For example, the first conversion condition might be that the predicted load is relatively stable or that there are few tasks that need to be distributed. The second conversion condition might be that there are few tasks that actually need to be executed that require a large amount of computing power. The specific values ​​can be set according to the situation of each service cluster.

[0112] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Red Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0113] The above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and are not intended to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the scope of the technology disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of protection of the claims.

Claims

1. A cluster service load balancing strategy method based on consistent hashing algorithm, characterized in that, Includes the following steps: Step S1: Name and number several terminal devices, label them as terminal names, and calculate the consistent hash value of each terminal device using a consistent hash algorithm; Step S2: Configure additional names for terminal devices and configure virtual nodes for several terminal devices using a virtual hash algorithm; Step S3: Construct a consistent hash ring and distribute the terminal devices within the consistent hash ring; allocate a certain number of hash segments to the front-end machine; Step S3 includes the following sub-steps: Step S301: Construct a consistent hash ring; Step S302: Obtain the consistent hash value of the terminal device and place the device node of the terminal device at the hash ring node with the same consistent hash value in the consistent hash ring; Step S303: Obtain the virtual hash value of the terminal device, and place the virtual node of the terminal device at the hash ring node in the consistent hash ring that has the same virtual hash value; Step S304: Obtain the number of front-end machines and mark it as the number of front-end machines; Step S305, using the formula Calculate the number of hash nodes allocated to each front-end machine, where Ds is the number of hash nodes and T is the number of front-end machines; Step S306: Number the front-end machines and allocate hash segments to the front-end machines in ascending order of their numbers. Each hash segment includes hash loop points, and the number of hash loop points is equal to the number of hash loop points. Step S4: Obtain the reported data, calculate the Key value of the reported data using a consistent hash algorithm, and store the reported data into the terminal device according to the Key value; Step S5: Send the stored data in the terminal device to the front-end machine corresponding to the hash segment where the terminal device is located for data processing; Step S6: Establish a load database and enter the load information for the current time period; Step S7: Read the load database, analyze the load situation for the time period, and change the cluster service operation mode based on the analysis results.

2. The cluster service load balancing strategy method based on consistent hashing algorithm according to claim 1, characterized in that, Step S1 includes the following sub-steps: Step S101: Name and number several terminal devices, and mark them as terminal names; Step S102: Calculate the consistent hash value for each terminal device using a consistent hash algorithm; The consistent hashing algorithm is configured as follows: Where H is the consistent hash value, M is the terminal name of the terminal device, and Hash is the hash operator.

3. The cluster service load balancing strategy method based on consistent hashing algorithm according to claim 2, characterized in that, Step S2 includes the following sub-steps: Step S201: Configure an additional name for the terminal device and mark it as a virtual name; Step S202: Calculate the virtual hash value of the virtual name using a virtual hash algorithm; The virtual hash algorithm is configured as follows: Where Hx is the virtual hash value, Mx is the virtual name of the terminal device, and Hash is the hash operator.

4. The cluster service load balancing strategy method based on consistent hashing algorithm according to claim 3, characterized in that, Step S4 includes the following sub-steps: Step S401: Receive the reported data and number the reported data; Step S402: Calculate the Key value of the reported data using a hash algorithm; The hash algorithm is configured as follows: Where Key is the Key value of the reported data, and O is the number of the reported data; Step S403: Obtain the Key value, increase the Key value, if the Key value is greater than... If the key value is zero, then the key value will be adjusted to zero and continued to increase until the key value is equal to the consistent hash value of a certain terminal device. Step S404: Store the reported data corresponding to the Key value into a terminal device with the same consistent hash value as the Key value.

5. A cluster service load balancing strategy method based on consistent hashing algorithm according to claim 4, characterized in that, Step S5 includes the following sub-steps: Step S501: Detect the distribution of consistent hash values ​​in the hash segment; Step S502: Obtain the terminal device corresponding to the consistent hash value contained in the hash segment corresponding to the front-end machine; Step S503: Connect the front-end machine and the terminal device, obtain the data stored in the terminal device, and perform data processing.

6. The cluster service load balancing strategy method based on consistent hashing algorithm according to claim 5, characterized in that, Step S6 includes the following sub-steps: Step S601: Establish the load database; Step S602: Using a first time threshold as a time period, record the load data of each terminal device and the front-end machine. The load data includes the peak load of the terminal and the peak load of the front-end machine.

7. A cluster service load balancing strategy method based on consistent hashing algorithm according to claim 6, characterized in that, Step S7 includes the following sub-steps: Step S701: Read the load database to obtain the peak terminal load and peak front-end load within the current time period; Step S702: Compare the terminal load peak value with the first terminal load threshold and the second terminal load threshold. If the terminal load peak value is less than or equal to the first terminal load threshold, output a terminal load too low signal; if the terminal load peak value is greater than the first terminal load threshold and less than or equal to the second terminal load threshold, output a terminal load normal signal; if the terminal load peak value is greater than the second terminal load threshold, output a terminal load too high signal. Step S703: If the output terminal load is too low, the backup terminal in the cluster server is removed and the reported data is redistributed; if the output terminal load is normal, the number of terminal devices in the cluster server is maintained. If the output terminal load signal is too high, add a backup terminal to the cluster server, calculate its consistent hash value and virtual hash value, and re-analyze the terminal devices allocated to the reported data; after processing, obtain the terminal load peak and analyze it until the output terminal load signal is normal. Step S704: Compare the peak load of the front-end processor with the first front-end processor load threshold and the second front-end processor load threshold. If the peak load of the front-end processor is less than or equal to the first front-end processor load threshold, output a front-end processor load too low signal; if the peak load of the front-end processor is greater than the first front-end processor load threshold and less than or equal to the second front-end processor load threshold, output a front-end processor load normal signal; if the peak load of the front-end processor is greater than the second front-end processor load threshold, output a front-end processor load too high signal. In step S705, if the output front-end load signal is too low, the standby front-end in the cluster server is removed and the hash segment is redistributed; if the output front-end load signal is normal, the number of front-ends in the cluster server is maintained; if the output front-end load signal is too high, a standby front-end is added to the cluster server and the hash segments of all front-ends are redistributed until the output front-end load signal is normal.

8. A cluster service load balancing strategy method based on consistent hashing algorithm according to claim 7, characterized in that, It also includes step S8, which includes the following sub-steps: Step S801: Identify the load characteristics of each service cluster by reading the load database; Step S802: Index the corresponding family configuration information from the pre-built family topology library according to the load characteristics and the topology relationship of the service cluster. The family configuration information includes different terminal family types and the number of each terminal family type. Step S803: Configure the load terminals into different terminal family types according to the family configuration information. The terminal family type includes a parent type, an elder brother type, and a younger brother type. The parent type is configured to prioritize processing tasks outside the service cluster. The elder brother type is set according to the parent type and is configured to prioritize processing tasks distributed by the parent type. A load balancing algorithm is configured between the younger brother types. The load balancing algorithm is used to balance the tasks between the younger brother types. Step S804: Configure different encryption levels in the hash segment for the load terminals corresponding to the parent type, elder brother type, and younger brother type.

9. A cluster service load balancing strategy method based on consistent hashing algorithm according to claim 8, characterized in that, In step S803, a first conversion condition and a second conversion condition are also configured. When there is a load terminal of type 1 in the service cluster that meets the first conversion condition, the terminal family type of the load terminal is converted to the type 2 with a preset first conversion time. When there is a load terminal of type 2 in the service cluster that meets the second conversion condition, the terminal family type of the load terminal is converted to the type 1 with a preset second conversion time.

Citation Information

Patent Citations

  • Load balancing method based on clusters and multiple processes

    CN111858033A

  • Arc jump: per-key selection of an alternative server when implemented bounded loads

    US11310309B1