A load balancing method and device of a server, electronic equipment and storage medium
By employing the DCHG algorithm to load balance the server cluster in a distributed storage system for video surveillance scenarios, and by adjusting the state attributes and grouping strategies of virtual nodes, the problems of uneven load and data migration overhead are solved, thereby improving system performance and scalability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AGRICULTURAL BANK OF CHINA
- Filing Date
- 2022-10-14
- Publication Date
- 2026-05-22
AI Technical Summary
In video surveillance scenarios, existing load balancing algorithms cause performance degradation in distributed storage systems, mainly because a large number of write requests require slicing to save index metadata, which consumes storage space, and frequent adjustments to the number of virtual nodes increase management overhead, making it impossible to effectively achieve load balancing.
The DCHG (Dynamic Consistency Algorithm Based on Groups) algorithm is adopted. By dividing the data center into a preset number of data areas and adjusting the state attributes of virtual nodes at the server cluster level, the data migration and identification overhead is reduced, and load balancing is achieved by combining server load, available storage capacity and inherent service capabilities.
While keeping the hash ring structure unchanged, the load balancing effect is improved, data migration overhead is reduced, and the scalability and load balancing capability of the distributed storage system are enhanced.
Smart Images

Figure CN115604269B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed storage technology, and in particular to a server load balancing method, apparatus, electronic device and storage medium. Background Technology
[0002] In the era of big data, distributed storage systems are an effective way to cope with the surge in data. Distributed storage systems face the problem of uneven load distribution caused by dynamic workload skew. Some servers may crash due to excessive load, while others may waste resources due to insufficient load, thus reducing the overall performance of the distributed storage system. Therefore, load balancing algorithms have a significant impact on the performance of distributed storage systems.
[0003] While many load balancing algorithms have achieved good results in general distributed storage systems, their performance inevitably degrades when directly applied to video surveillance scenarios. This is because video surveillance involves a large number of write requests, and each write operation requires data to be sliced and stored to improve the efficiency of read and write request processing. Therefore, current load balancing algorithms need to generate an index metadata record of the storage location for each data slice, thus consuming a significant amount of storage space and greatly impacting the performance and scalability of the distributed storage system. Therefore, how to perform load balancing on servers in video surveillance scenarios has become a pressing issue. Summary of the Invention
[0004] This application provides a server load balancing method, apparatus, electronic device, and storage medium, which can avoid data identification overhead and reduce a large amount of data migration overhead, improve the load balancing effect while ensuring that the structure of the hash ring does not change, and also improve the scalability of the distributed storage system.
[0005] In a first aspect, this application provides a server load balancing method, the method being applied to a distributed storage system, the distributed storage system comprising at least two data centers, each data center comprising multiple servers, the method comprising:
[0006] The at least two data centers are divided into a preset number of data areas, and the servers in the preset number of data areas are divided into multiple server clusters;
[0007] Determine the initial number of virtual nodes for each server cluster;
[0008] Determine the changes in the load level of each server cluster within the current period;
[0009] If the change status is changed, the target number of virtual nodes in the corresponding server cluster is determined based on the current load value, current available storage capacity and inherent service capability of the specified server in each server cluster in the current period.
[0010] Based on the initial quantity and the target quantity, determine the virtual nodes to be adjusted in the corresponding server cluster and the adjustment method, and adjust the virtual nodes to be adjusted based on the adjustment method to achieve load balancing of the server.
[0011] Secondly, this application provides a server load balancing device, which is applied to a distributed storage system, the distributed storage system including at least two data centers, each data center including multiple servers, the device comprising:
[0012] The initial quantity determination module is used to divide the at least two data centers into a preset number of data areas, divide the servers in the preset number of data areas into multiple server clusters, and determine the initial number of virtual nodes in each server cluster.
[0013] The load status determination module is used to determine the changes in the load level of each server cluster within the current period.
[0014] The target quantity determination module is used to determine the target number of virtual nodes in the corresponding server cluster based on the current load value, current available storage capacity and inherent service capacity of the specified server in each server cluster in the current period if the change status is changed.
[0015] The server load balancing module is used to determine the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster according to the initial number and the target number, and to adjust the virtual nodes to be adjusted according to the adjustment method to achieve server load balancing.
[0016] Thirdly, this application provides an electronic device comprising:
[0017] At least one processor; and
[0018] A memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the server load balancing method described in any embodiment of this application.
[0020] Fourthly, this application provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the server load balancing method described in any embodiment of this application.
[0021] This application provides a server load balancing method, comprising: dividing at least two data centers into a preset number of data areas; dividing the servers in the preset number of data areas into multiple server clusters; and determining the initial number of virtual nodes in each server cluster; determining the load level change status of each server cluster in the current period; if the change status is positive, determining the target number of virtual nodes in the corresponding server cluster based on the current load value, current available storage capacity, and inherent service capabilities of a specified server in each server cluster in the current period; determining the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster based on the initial number and the target number; and adjusting the virtual nodes to be adjusted based on the adjustment method to achieve server load balancing. This application designs a group-based dynamic consistency algorithm, DCHG. By setting up a server cluster, when one server in the cluster fails, other servers can quickly identify the data to be recovered, thus avoiding data identification overhead. It comprehensively considers the server load, available storage capacity, and inherent service capabilities to manage the number of virtual nodes. By changing the state attributes of virtual nodes, the number of virtual nodes can be adjusted, which can reduce a lot of data migration overhead. It can improve the load balancing effect while ensuring that the hash ring structure does not change, and also improve the scalability of the distributed storage system.
[0022] It should be noted that the aforementioned computer instructions may be stored, in whole or in part, on a computer-readable storage medium. This computer-readable storage medium may be packaged together with the processor of the server's load balancing device, or it may be packaged separately from the processor of the server's load balancing device; this application does not impose any limitations on this.
[0023] The descriptions of the second, third, and fourth aspects in this application can be referenced to the detailed description of the first aspect; and the beneficial effects described in the second, third, and fourth aspects can be referenced to the analysis of the beneficial effects of the first aspect, which will not be repeated here.
[0024] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description.
[0025] It is understood that before using the technical solutions disclosed in the various embodiments of this application, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this application in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A first flowchart illustrating a server load balancing method provided in an embodiment of this application;
[0028] Figure 2 This is a schematic diagram of data distribution based on server grouping strategy provided in an embodiment of this application;
[0029] Figure 3 A second flowchart illustrating a server load balancing method provided in an embodiment of this application;
[0030] Figure 4 A schematic diagram of the structure of a server load balancing device provided in an embodiment of this application;
[0031] Figure 5 This is a block diagram of an electronic device used to implement a server load balancing method according to an embodiment of this application. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0033] It should be noted that the terms "first," "second," "target," and "original," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those illustrated or described herein. Furthermore, the terms "comprising," "having," and any variations thereof are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] Before introducing the embodiments of this application, let's first describe current server load balancing methods. Typically, a Dynamic Consistent Hash (DCH) algorithm is used to dynamically adjust the server load in a distributed storage system by adding or deleting virtual nodes in the hash ring. Specifically: the initial number of virtual nodes for each server is calculated based on its inherent service capabilities (including CPU clock speed, memory size, and network bandwidth). After obtaining the initial number of virtual nodes for each server, the name of each virtual node is determined by adding a number to the server's Internet Protocol Address (IP Address). Then, a preset hash function is used to map the virtual nodes onto the hash ring, thus establishing the hash ring. Since the load in a distributed storage system is dynamic, adjustments to the virtual nodes on the hash ring are also necessary to achieve load balancing. If a server's load increases, the number of virtual nodes corresponding to that server can be reduced to decrease the likelihood of it receiving additional load; conversely, increasing the number of virtual nodes for a server increases the likelihood of a lightly loaded server receiving additional load, thereby achieving load balancing. Adjusting the hash ring requires determining the number of virtual nodes added or removed for each server. This is done by considering the server's inherent service capacity and load. The load on each server is calculated periodically, and the ideal number of virtual nodes for that server in the current period is determined. Comparing this to the current number of existing virtual nodes reveals the number of virtual nodes that need adjustment. Deleting or adding the corresponding number of virtual nodes to the hash ring completes the adjustment for the current period, thus achieving load balancing.
[0035] However, the current server load balancing methods described above have the following problems when applying the DCH algorithm to video surveillance scenarios regarding the calculation of the number of virtual nodes:
[0036] (1) The available storage capacity of the server was ignored. In a video surveillance distributed storage system, servers with larger available storage capacity have the ability to store more data and can be allocated more write requests. Therefore, when adjusting the load, more attention should be paid to the available storage capacity parameter of the server.
[0037] (2) Frequent adjustment of the number of virtual nodes. Changes in server load may cause changes in the number of virtual nodes that should exist in the current cycle. Even if the server load is always normal, it is still necessary to change the number of virtual nodes corresponding to the server, which increases the management overhead of the hash ring.
[0038] (3) The calculation rule for the number of virtual nodes that need to be adjusted is unreasonable. Since the number of virtual nodes that the server should have in the current period is inversely proportional to the server's load value, when the server fluctuates within the range of light load, the number of virtual nodes that need to be adjusted is large, which excessively transfers the load of the light-load server; when the server is in a heavy-load state, the number of virtual nodes that need to be adjusted is small, which cannot play the role of transferring the load.
[0039] (4) Regarding the adjustment of the hash ring, applying the DCH algorithm to video surveillance scenarios will generate a large amount of data migration and recognition overhead.
[0040] In summary, applying the DCH algorithm directly to a video surveillance distributed storage system may result in uneven load distribution, large amounts of data migration, and recognition overhead.
[0041] Figure 1 This is a first flowchart illustrating a server load balancing method provided in this application embodiment. This embodiment is applicable to load balancing of servers in a distributed storage system under video surveillance scenarios. The server load balancing method provided in this embodiment can be executed by the server load balancing device provided in this application embodiment. This device can be implemented by software and / or hardware and integrated into the electronic device executing this method.
[0042] See Figure 1 The method in this embodiment includes, but is not limited to, the following steps:
[0043] S110. Divide at least two data centers into a preset number of data areas, and divide the servers in the preset number of data areas into multiple server clusters.
[0044] This application does not limit the number of preset groups; two groups are optional. This embodiment uses two preset groups to explain the server load balancing method of this application. A data center includes multiple servers. The regional information of each data center can be different, such as data center A located in Shanghai, data center B located in Wuhan, etc.
[0045] Before dividing the servers in the data area of the preset number of groups into multiple server clusters, the process includes: determining the total number of servers in at least two data centers; determining the load of each server in at least two data centers; taking the remainder of the total number with the preset number to obtain a second number; and removing the second number of servers with the highest load from the at least two data centers so that the second number of servers do not participate in the server grouping strategy. Here, the preset number is the number of servers contained in the server cluster.
[0046] In this embodiment, at least two data centers are divided into a predetermined number of data zones based on the number of servers in each data center. Regardless of whether there is an even or odd number of data centers, at least two data centers are divided into two groups based on the number of servers in each data center, ensuring that the number of servers in each data zone is similar.
[0047] It should be noted that the data zones mentioned above are divided by data center, meaning they are divided according to the regional information of the data center. Servers within the same data center reside in the same data zone. The number of servers in each data zone may be equal or unequal, but the number of servers should be similar.
[0048] For example, there are four data centers: data center A has 5 servers, data center B has 8 servers, data center C has 6 servers, and data center D has 7 servers. Based on the number of servers in each data center, data centers A and B are grouped into data zone 1, and data centers C and D are grouped into data zone 2. Each data zone contains an equal number of data centers.
[0049] For example, there are four data centers: data center A has 2 servers, data center B has 3 servers, data center C has 4 servers, and data center D has 10 servers. Based on the number of servers in each data center, data centers A, B, and C are grouped into data zone 1, and data center D is grouped into data zone 2. The number of data centers in each data zone is not equal.
[0050] For example, there are three data centers: data center A has 5 servers, data center B has 6 servers, and data center C has 10 servers. Based on the number of servers in each data center, data centers A and B are grouped into data zone 1, and data center C is grouped into data zone 2. The number of data centers in each data zone is not equal.
[0051] In this embodiment, after obtaining two sets of data areas, the servers in the two sets of data areas are divided into multiple server clusters. Each server cluster includes a preset number of target servers. A preset number of servers are selected from data area 1 and data area 2 to form a server cluster. According to the replica allocation rules of the DCH algorithm, a replica of data1 is stored on each server in the server cluster. The purpose of obtaining multiple server clusters through this server grouping strategy is to ensure that when a server in the server cluster fails, the data to be recovered can be quickly identified through other servers, thereby avoiding data identification overhead.
[0052] S120. Determine the initial number of virtual nodes for each server cluster.
[0053] In this embodiment, after step S110, the servers in the distributed storage system are grouped to obtain multiple server clusters. The establishment and adjustment of the hash ring are then performed on a server cluster basis. This application calculates the initial number of virtual nodes corresponding to each server cluster based on the Dynamic Consistent Hash Group (DCHG) algorithm, considering the inherent service capabilities and available storage capacity of a specified server (i.e., a specified server in the server cluster).
[0054] Furthermore, determining the initial number of virtual nodes for each server cluster includes: identifying the server with the least available storage capacity in each server cluster as a designated server, and determining the inherent service capabilities of the designated server; and determining the initial number of virtual nodes for the corresponding server cluster based on the inherent service capabilities and available storage capacity of the designated server.
[0055] According to the barrel principle, the server with the least available storage capacity in each server cluster represents the maximum processing capacity of that server cluster. Therefore, the server with the least available storage capacity in each server cluster is selected, and the initial number of virtual nodes corresponding to that server cluster is calculated using the following formula (1).
[0056]
[0057] In the formula, V represents the initial number of virtual nodes corresponding to the server cluster; S iDC represents the inherent service capability of server i in the server cluster. i This represents the available storage capacity of server i in the server cluster; constant is a constant used to ensure that the number of virtual nodes in the server cluster of the distributed storage system is appropriate.
[0058] like Figure 2 The diagram illustrates the data distribution based on a server grouping strategy. As shown, the distributed storage system contains twelve servers, A to M, divided into four server clusters (group1 to group4 in the diagram). Virtual nodes 1-1 to 1-3, 2-1 to 2-3, 3-1 to 3-2, and 4-1 to 4-2 correspond to server clusters 1 to 4, respectively. According to the replica allocation rules of the server grouping strategy, data1 is allocated to servers A, B, and C; data2 is allocated to servers H, I, and G; and data3 is allocated to servers K, L, and M. When server A fails, the data that needs to be recovered can be quickly determined through servers B or C in its group1. Furthermore, when accessing data1, a server with a lighter load can be selected from group1 to handle the request, achieving load balancing among replicas and enhancing the load balancing effect of the distributed storage system.
[0059] S130. Determine the changes in the load level of each server cluster within the current period.
[0060] In this embodiment of the application, after obtaining the initial number of virtual nodes corresponding to each server cluster, the name of each virtual node can be determined by combining the server IP addresses in the server cluster with the virtual node number, that is, VName = ip1#ip2#ip3#k (k = 0, 1, 2, ...), where k is the index number of the virtual node. Then, the virtual node is mapped to the hash ring by the MD5 hash function, thus completing the establishment of the hash ring.
[0061] Similar to DCH, DCHG also requires hash ring adjustments to achieve dynamic load balancing. Since DCHG builds hash rings based on groups, the server with the least available storage capacity in each server cluster represents the group's maximum processing capacity. Therefore, when adjusting the hash ring, the number of virtual nodes that need to be adjusted for each server cluster is calculated by collecting data from the servers with the least available storage capacity in each cluster. Furthermore, because frequent load adjustments increase the management overhead of the hash ring and affect request allocation results, thus reducing load balancing effectiveness, DCHG further designed virtual node adjustment rules.
[0062] This step is the first step in the virtual node adjustment rules, which determines whether the number of virtual nodes in the server cluster needs to be adjusted. Specifically: calculate the load value of each server in the server cluster, add them together to obtain the load value of the server cluster. Divide the load value of the server cluster into multiple load levels. If the load level changes within adjacent periods, the load can be adjusted reasonably by adjusting the number of virtual nodes.
[0063] The server load value is calculated using the following formula (2):
[0064] L i =W c ×L(C i )+W m ×L(M i )+W b ×L(B i (2)
[0065] In the formula, L i L(C) represents the load on server i in the server cluster; i L(M) represents the CPU utilization of server i in the server cluster; i L(B) represents the memory utilization of server i in the server cluster; i W represents the network utilization of server i in the server cluster; c W m W b These represent the weights of server CPU utilization, memory utilization, and network utilization, respectively. c +W m +W b =1.
[0066] Optionally, the load can be divided into eight load levels based on the load value, as shown in Table 1 below:
[0067] Table 1. Load values of the server cluster and their corresponding load levels.
[0068]
[0069] Compared with the load levels of each server cluster in the previous cycle, determine the change status of the load level of each server cluster in the current cycle. Obtain the load level LL1 of each server cluster in the previous cycle T1 and the load level LL2 in the current cycle T2 through formula (2) and Table 1. If LL1 > LL2, the change status of the load level of this server cluster is a load reduction, and some virtual nodes need to be added to increase the possibility of this group receiving the load; if LL1 < LL2, the change status of the load level of this server cluster is a heavier load, and some virtual nodes need to be reduced to reduce the possibility of this group receiving the load; if LL1 = LL2, it means that the load level of this server cluster has not changed and there is no need to adjust the hash ring.
[0070] S140. If the change status is a change, then determine the target number of virtual nodes in the corresponding server cluster according to the current load value, current available storage capacity, and inherent service capacity of the specified server in each server cluster in the current cycle.
[0071] In the embodiment of the present application, when the change status of the load level of the server cluster is a load reduction or a heavier load, it is necessary to adjust the number of virtual nodes on the hash ring. This step is the second step of the virtual node adjustment rule, that is, calculate the target number of virtual nodes in this server cluster.
[0072] During the operation of the distributed storage system, the available storage capacity of the server is dynamically changing. Therefore, when calculating the number of virtual nodes to be adjusted, it is necessary to consider the real-time load and available storage capacity of the server. After the server starts to receive the load, its current service capacity is 1 - L i , and the remaining number of virtual nodes of this server should be 1 - L i times the initial number of virtual nodes. At the same time, since the available storage capacity of server i has also changed after receiving the load, the current available storage capacity of the current cycle is used for calculation.
[0073] Further, determining the target number of virtual nodes in the corresponding server cluster according to the current load value, current available storage capacity, and inherent service capacity of the specified server in each server cluster in the current cycle includes: determining the current load value and current available storage capacity of the specified server in the current cycle; determining the current service capacity based on the current load value and current available storage capacity; determining the target number of virtual nodes in the corresponding server cluster based on the current service capacity and inherent service capacity. Calculate the target number of virtual nodes in the server cluster through the following formula (3):
[0074] <�
[0075] In the formula, V′ represents the target number of virtual nodes corresponding to the server cluster; Si L represents the inherent service capability of server i in the server cluster; i This represents the current load value of server i in the server cluster; DC′ i This represents the current available storage capacity of server i in the server cluster; constant is a constant used to ensure that the number of virtual nodes in the server cluster of the distributed storage system is moderate.
[0076] S150. Determine the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster based on the initial quantity and the target quantity, and adjust the virtual nodes to be adjusted based on the adjustment method to achieve load balancing of the server.
[0077] In this embodiment, this step is the third step in the virtual node adjustment rules, namely, adjusting the state attributes of the virtual nodes. Currently, server load balancing methods adjust the load by adding or deleting virtual nodes. Changes in the hash ring structure may lead to changes in request allocation results, requiring data migration to ensure the efficiency of read request processing. Therefore, this application designs state management rules for virtual nodes to ensure that the hash ring structure remains unchanged during load adjustment, thus minimizing the impact on read request allocation results and avoiding data migration. Specifically, two state attributes, OPEN and CLOSE, are set for virtual nodes. Changing the state attributes of virtual nodes replaces adding or deleting virtual nodes, thereby preventing changes in the hash ring structure. The state attributes are used to control the virtual nodes' reception of write requests.
[0078] Furthermore, based on the initial and target quantities, the virtual nodes to be adjusted in the corresponding server cluster and the adjustment method are determined, including: determining the first number of virtual nodes to be adjusted based on the difference between the initial and target quantities; if the initial quantity is greater than the target quantity, the adjustment method is to set the state attribute of the first number of virtual nodes to "off"; if the initial quantity is less than the target quantity, the adjustment method is to set the state attribute of the first number of virtual nodes to "on". By changing the state attribute of the virtual nodes to be adjusted on the hash ring, the adjustment of the hash ring within the current period can be completed, thereby achieving load balancing.
[0079] Specifically, the rules for virtual node state management are summarized as follows:
[0080] (a) A virtual node in the OPEN state indicates that the virtual node is visible to both read and write requests. When the server load decreases, the state of some virtual nodes corresponding to the server is set to OPEN, that is, some virtual nodes are opened so that they are visible to both read and write requests.
[0081] (b) A virtual node in a CLOSE state indicates that the virtual node is visible to read requests but not to write requests. When the server load increases, the state of some virtual nodes corresponding to the server is set to CLOSE, which means that some virtual nodes are turned off, making them invisible to write requests but visible to read requests.
[0082] (c) When the server load does not change much (i.e. the load level remains unchanged), the state of the virtual node corresponding to the server remains unchanged.
[0083] Compared to adding or deleting virtual nodes, the virtual node state attribute management strategy significantly reduces data migration overhead. When adjusting load by adding or deleting virtual nodes, changes in the hash ring structure can lead to changes in request allocation results, requiring data migration to ensure efficient read request processing. However, adjusting load by changing the state of virtual nodes ensures that the hash ring structure remains unchanged. This achieves load balancing while minimizing the impact on read request allocation results, avoiding data migration and identification overhead.
[0084] The technical solution provided in this embodiment divides at least two data centers into a preset number of data areas, and then divides the servers in the preset number of data areas into multiple server clusters. It determines the initial number of virtual nodes in each server cluster; determines the load level changes of each server cluster within the current period; if the changes are positive, it determines the target number of virtual nodes in the corresponding server cluster based on the current load value, available storage capacity, and inherent service capabilities of the specified servers in each server cluster within the current period; it determines the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster based on the initial and target numbers, and adjusts the virtual nodes to be adjusted based on the adjustment method to achieve server load balancing. This application designs a group-based dynamic consistency algorithm (DCHG). By setting up server clusters, when a server in the cluster fails, other servers can quickly identify data to be recovered, thus avoiding data identification overhead. It comprehensively considers server load, available storage capacity, and inherent service capabilities to manage the number of virtual nodes, and adjusts the number of virtual nodes by changing the state attributes of the virtual nodes, which can reduce a large amount of data migration overhead, improve the load balancing effect while ensuring that the hash ring structure remains unchanged, and also improve the scalability of the distributed storage system.
[0085] The server load balancing method provided in the embodiments of this application is further described below. Figure 3 This is a schematic diagram of the second process of a server load balancing method provided in an embodiment of this application. This embodiment optimizes the above embodiment, specifically by: optimizing the server grouping strategy (i.e....) Figure 1The specific process of dividing the servers in the data area of the preset number of groups into multiple server clusters in step S110 of the embodiment will be explained in detail. The server clusters include a preset number of target servers, which is three, and the preset number of groups in the data area is two.
[0086] See Figure 3 The method in this embodiment includes, but is not limited to, the following steps:
[0087] S210. Sort the available storage capacity of the servers in each data area in descending order to obtain the capacity sorting result. Take the server that ranks first in the capacity sorting result as the target server, thereby obtaining the first target server and the second target server.
[0088] In this embodiment, the server cluster includes three target servers, denoted as the first target server, the second target server, and the third target server. The server with the largest available storage capacity in each data area is selected as the target server, resulting in the first target server and the second target server.
[0089] S220. The server that ranks second in the capacity sorting results of the two data areas is selected as the candidate server, thus obtaining two candidate servers.
[0090] In this embodiment of the application, the server with the second largest available storage capacity in each data area is selected as a candidate server, thereby obtaining two candidate servers.
[0091] S230. Determine the third target server from the two candidate servers according to the preset rules, thereby obtaining a server cluster.
[0092] In this embodiment, the preset rule is as follows: determine the capacity difference between the available storage capacities of the candidate servers; if the capacity difference exceeds a preset capacity value (e.g., the preset capacity value can be 4T), then the candidate server with the larger available storage capacity is selected as the third target server; if the capacity difference does not exceed the preset capacity value, then determine the total number of servers in the two data areas respectively; if the total number of servers in the two data areas is not equal, then the candidate server corresponding to the data area with the larger number of servers is selected as the third target server; if the total number of servers in the two data areas is equal, then determine the inherent service capability of each candidate server, determine the service difference between the inherent service capability of each candidate server and the inherent service capability of the first target server or the inherent service capability of the second target server, and select the candidate server with the smaller service difference as the third target server.
[0093] S240. Remove the target servers from their respective data areas to obtain two new sets of data areas. Repeat the operation of taking the server with the largest available storage capacity in each set of data areas as the target server to obtain multiple server clusters.
[0094] In this embodiment, the three target servers identified above are removed from their respective data areas to obtain two new sets of data areas. Steps S210-S240 are repeated until the servers in the two sets of data areas are grouped, thus obtaining multiple server clusters.
[0095] The server grouping strategy takes into account the requirement of dual-location replication and the importance of available storage capacity in a distributed storage system for video surveillance. Specific grouping rules were established, and the consistent hashing algorithm for replica allocation was optimized. This allows for rapid identification of data to be recovered in the event of server failure, avoiding data identification overhead. Furthermore, selecting the server with the lightest load within the group to handle corresponding read requests further enhances load balancing.
[0096] The technical solution provided in this embodiment obtains a capacity sorting result by sorting the available storage capacity of servers in each data area in descending order. The server ranked first in the capacity sorting result is selected as the target server, resulting in a first target server and a second target server. The server ranked second in the capacity sorting result of each data area is selected as a candidate server, resulting in two candidate servers. A third target server is determined from the two candidate servers according to a preset rule, thus obtaining a server cluster. The target servers are then removed from their respective data areas to obtain two new data areas. This process of selecting the server with the largest available storage capacity in each data area as the target server is repeated to obtain multiple server clusters. This application, by setting up server clusters through a server grouping strategy, allows for rapid identification of data to be recovered by other servers when a server in the cluster fails, thereby avoiding data identification overhead. It improves load balancing while maintaining the hash ring structure and also enhances the scalability of the distributed storage system.
[0097] Figure 4 This is a schematic diagram of a server load balancing device provided in an embodiment of this application. The device is applied to a distributed storage system, which includes at least two data centers, and each data center includes multiple servers, such as... Figure 4 As shown, the device 400 may include:
[0098] The initial quantity determination module 410 is used to divide the at least two data centers into a preset number of data areas, divide the servers in the preset number of data areas into multiple server clusters, and determine the initial number of virtual nodes in each server cluster.
[0099] The load status determination module 420 is used to determine the changes in the load level of each server cluster within the current period.
[0100] The target quantity determination module 430 is used to determine the target number of virtual nodes in the corresponding server cluster based on the current load value, current available storage capacity and inherent service capacity of the specified server in each server cluster in the current period if the change status is changed.
[0101] The server load balancing module 440 is used to determine the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster according to the initial quantity and the target quantity, and to adjust the virtual nodes to be adjusted based on the adjustment method to achieve server load balancing.
[0102] Optionally, the server cluster includes a preset number of target servers, wherein the preset number is three and the preset number of groups is two.
[0103] Furthermore, the aforementioned initial quantity determination module 410 may include a server cluster determination unit and an initial quantity determination unit;
[0104] The server cluster determination unit can be specifically used to: sort the available storage capacity of servers in each data area in descending order to obtain a capacity sorting result; take the server that ranks first in the capacity sorting result as the target server, thereby obtaining a first target server and a second target server; determine a third target server from the two data areas according to a preset rule, thereby obtaining a server cluster; remove the target server from its corresponding data area to obtain two new data areas, and repeat the operation of taking the server with the largest available storage capacity in each data area as the target server to obtain multiple server clusters.
[0105] Furthermore, the aforementioned server cluster determination unit can be specifically used to: select the server ranked second in the capacity sorting results of the two sets of data areas as candidate servers, and determine the capacity difference between the available storage capacities of the candidate servers; if the capacity difference exceeds a preset capacity value, select the candidate server with the larger available storage capacity as the third target server; if the capacity difference does not exceed the preset capacity value, determine the total number of servers in the two sets of data areas; if the total number of servers in the two sets of data areas is not equal, select the candidate server corresponding to the data area with the larger number of servers as the third target server; if the total number of servers in the two sets of data areas is equal, determine the inherent service capability of each candidate server, determine the service difference between the inherent service capability of each candidate server and the inherent service capability of the first target server or the inherent service capability of the second target server, and select the candidate server with the smaller service difference as the third target server.
[0106] The initial quantity determination unit can be specifically used to: determine the server with the least available storage capacity in each server cluster as a designated server, and determine the inherent service capacity of the designated server; and determine the initial number of virtual nodes in the corresponding server cluster based on the inherent service capacity of the designated server and the available storage capacity of the designated server.
[0107] Optionally, the virtual node is configured with a status attribute, which is used to control the virtual node's reception of write requests;
[0108] Furthermore, the aforementioned server load balancing module 440 can be specifically used to: determine a first number of virtual nodes to be adjusted based on the difference between the initial number and the target number; if the initial number is greater than the target number, the adjustment method is to set the status attribute of the first number of virtual nodes to off; if the initial number is less than the target number, the adjustment method is to set the status attribute of the first number of virtual nodes to on.
[0109] Furthermore, the aforementioned target quantity determination module 430 can be specifically used to: determine the current load value and current available storage capacity of the specified server within the current period; determine the current service capability based on the current load value and the current available storage capacity; and determine the target number of virtual nodes in the corresponding server cluster based on the current service capability and the inherent service capability.
[0110] Furthermore, the load balancing device for the aforementioned server may also include: a server removal module;
[0111] The server removal module is used to determine the total number of servers in the at least two data centers before dividing the servers in the data area of the preset number of groups into multiple server clusters; determine the load of each server in the at least two data centers; obtain a second number by taking the remainder of the total number and the preset number; and remove the second number of servers with the highest load from the at least two data centers.
[0112] The server load balancing device provided in this embodiment can be applied to the server load balancing method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0113] Figure 5 This is a block diagram of an electronic device used to implement a server load balancing method according to an embodiment of this application. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present application described and / or claimed herein.
[0114] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0115] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0116] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as server load balancing methods.
[0117] In some embodiments, the server load balancing method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the server load balancing method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the server load balancing method by any other suitable means (e.g., by means of firmware).
[0118] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0119] Computer programs used to implement the methods of this application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0120] In the context of this application, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0121] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0122] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0123] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0124] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this application can be achieved, and this is not limited herein.
[0125] The specific embodiments described above do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A server load balancing method, characterized in that, The method is applied to a distributed storage system, the distributed storage system comprising at least two data centers, each data center comprising multiple servers, and the method comprising: The at least two data centers are divided into a preset number of data areas, and the servers in the preset number of data areas are divided into multiple server clusters; Determine the initial number of virtual nodes for each server cluster; Determine the changes in the load level of each server cluster within the current period; If the change status is changed, the target number of virtual nodes in the corresponding server cluster is determined based on the current load value, current available storage capacity and inherent service capability of the specified server in each server cluster in the current period. Based on the initial quantity and the target quantity, determine the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster, and adjust the virtual nodes to be adjusted based on the adjustment method to achieve load balancing of the server. The server cluster includes a preset number of target servers, specifically three, and two preset groups. Dividing the servers in the preset number of data areas into multiple server clusters includes: sorting the available storage capacity of servers in each data area in descending order to obtain a capacity sorting result; selecting the server ranked first in the capacity sorting result as the target server, thus obtaining a first target server and a second target server; determining a third target server from the two data areas according to preset rules, thus obtaining a server cluster; removing the target server from its corresponding data area to obtain two new data areas; and repeating the operation of selecting the server with the largest available storage capacity in each data area as the target server to obtain multiple server clusters. The step of determining the third target server from the two sets of data areas according to preset rules includes: selecting the server ranked second in capacity sorting results of the two sets of data areas as a candidate server, and determining the capacity difference between the available storage capacities of the candidate servers; if the capacity difference exceeds a preset capacity value, selecting the candidate server with the larger available storage capacity as the third target server; if the capacity difference does not exceed the preset capacity value, determining the total number of servers in the two sets of data areas; if the total number of servers in the two sets of data areas is not equal, selecting the candidate server corresponding to the data area with the larger total number of servers as the third target server; if the total number of servers in the two sets of data areas is equal, determining the inherent service capability of each candidate server, determining the service difference between the inherent service capability of each candidate server and the inherent service capability of the first target server or the inherent service capability of the second target server, and selecting the candidate server with the smaller service difference as the third target server.
2. The server load balancing method according to claim 1, characterized in that, The virtual nodes are configured with state attributes, which are used to control the virtual nodes' reception of write requests; the step of determining the virtual nodes to be adjusted in the corresponding server cluster and the adjustment method based on the initial number and the target number includes: The first number of virtual nodes to be adjusted is determined based on the difference between the initial number and the target number; If the initial number is greater than the target number, the adjustment method is to set the state attribute of the first number of virtual nodes to off; If the initial number is less than the target number, the adjustment method is to set the state attribute of the first number of virtual nodes to "on".
3. The server load balancing method according to claim 1, characterized in that, Determining the initial number of virtual nodes for each server cluster includes: The server with the least available storage capacity in each server cluster is identified as the designated server, and the inherent service capabilities of the designated server are determined. The initial number of virtual nodes in the corresponding server cluster is determined based on the inherent service capabilities of the specified server and the available storage capacity of the specified server.
4. The server load balancing method according to claim 3, characterized in that, The step of determining the target number of virtual nodes in the corresponding server cluster based on the current load value, current available storage capacity, and inherent service capabilities of the specified servers in each server cluster within the current period includes: Determine the current load value and current available storage capacity of the specified server within the current period; Determine the current service capacity based on the current load value and the current available storage capacity; The target number of virtual nodes in the corresponding server cluster is determined based on the current service capabilities and the inherent service capabilities.
5. The server load balancing method according to claim 1, characterized in that, Before dividing the server in the data area of the preset number of groups into multiple server clusters, the method further includes: Determine the total number of servers in the at least two data centers; Determine the load on each server in the at least two data centers; The second quantity is obtained by taking the remainder between the sum of the quantities and the preset quantity, and the second quantity of servers with the highest load is removed from the at least two data centers.
6. A server load balancing device, characterized in that, The device is applied to a distributed storage system, the distributed storage system comprising at least two data centers, each data center comprising multiple servers, and the device comprising: The initial quantity determination module is used to divide the at least two data centers into a preset number of data areas, divide the servers in the preset number of data areas into multiple server clusters, and determine the initial number of virtual nodes in each server cluster. The load status determination module is used to determine the changes in the load level of each server cluster within the current period. The target quantity determination module is used to determine the target number of virtual nodes in the corresponding server cluster based on the current load value, current available storage capacity and inherent service capacity of the specified server in each server cluster in the current period if the change status is changed. The server load balancing module is used to determine the virtual nodes to be adjusted and the adjustment method in the corresponding server cluster according to the initial number and the target number, and to adjust the virtual nodes to be adjusted according to the adjustment method to achieve server load balancing. The server cluster includes a preset number of target servers, the preset number being three, and the preset number of groups being two. The initial quantity determination module includes a server cluster determination unit; The server cluster determination unit is specifically used to sort the available storage capacity of servers in each data area in descending order to obtain a capacity sorting result, and to select the server that ranks first in the capacity sorting result as the target server, thereby obtaining a first target server and a second target server; to determine a third target server from the two data areas according to a preset rule, thereby obtaining a server cluster; to remove the target server from its corresponding data area to obtain two new data areas, and to repeat the operation of selecting the server with the largest available storage capacity in each data area as the target server, so as to obtain multiple server clusters; The server cluster determination unit is specifically used to select the server ranked second in the capacity sorting results of the two sets of data areas as a candidate server, and determine the capacity difference between the available storage capacities of the candidate servers; if the capacity difference exceeds a preset capacity value, the candidate server with the larger available storage capacity is selected as the third target server; if the capacity difference does not exceed the preset capacity value, the total number of servers in the two sets of data areas is determined; if the total number of servers in the two sets of data areas is not equal, the candidate server corresponding to the data area with the larger total number of servers is selected as the third target server; if the total number of servers in the two sets of data areas is equal, the inherent service capability of each candidate server is determined, and the service difference between the inherent service capability of each candidate server and the inherent service capability of the first target server or the inherent service capability of the second target server is determined, and the candidate server with the smaller service difference is selected as the third target server.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the load balancing method of the server according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the load balancing method of the server according to any one of claims 1 to 5.