Load balancing method, device and load balancer
Patent Information
- Application Number
- CN202411503736.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2044-10-25
AI Technical Summary
[0004]但是传统的负载均衡方法无法对不同算力的服务器进行感知,需要人为地为不同的服务器配置权重,无法实现根据服务器算力对负载进行动态调度
本申请提供的负载均衡方法、装置及负载均衡器,基于服务器集群中各个服务器的负载信息和配置信息,确定各个服务器的性能权重,根据对目标网络负载生成的随机数和多个服务器的性能权重,确定期望权重,根据多个服务器的性能权重和性能权重从多个服务器中确定目标服务器,以由目标服务器对目标网络负载进行处理,基于服务器的配置信息计算性能权重,可以实现兼容不同算力的服务器,基于服务器的负载信息计算性能权重,可以根据服务器的负载状态实现动态调度服务器,从而实现兼容服务器集群中具有不同算力的服务器的动态负载均衡。
Smart Images

Figure CN119342054B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a load balancing method, apparatus, and load balancer. Background Technology
[0002] With the rapid growth of internet traffic, many websites and online services are facing a large user base, leading to a sharp increase in server load. Traditional single-server architectures can no longer meet the requirements of high traffic and high performance.
[0003] Load balancers can distribute requests across multiple servers or computing resources, thereby reducing the load on a single server and ensuring high availability, high performance, and scalability of network services.
[0004] However, traditional load balancing methods cannot detect servers with different computing power and require manual configuration of weights for different servers, making it impossible to dynamically schedule the load based on the server's computing power. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing a load balancing method, apparatus, and load balancer to be compatible with servers with different computing power and to achieve load balancing through dynamic server scheduling.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a load balancing method applied to a load balancer, the method comprising: Based on the load and configuration information of multiple servers in the server cluster, the performance weights of the multiple servers are determined respectively. In response to a triggering event of the target network load, generate a random number for the target network load; Based on the performance weights of the multiple servers and the random number, determine the expected weight for the target network load; The target server is determined from the plurality of servers based on the performance weights of the plurality of servers and the expected weights. A scheduling request for the target network load is sent to the target server so that the target server can process the target network load.
[0007] Optionally, the configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server; determining the performance weights of the multiple servers based on their load information and configuration information in the server cluster includes: Calculate the weight numerator for each server based on its processing configuration parameters and network bandwidth configuration parameters; The performance weight of each server is calculated based on its load information and weight numerator.
[0008] Optionally, the processing configuration parameters include: the number of processing cores and the processing frequency; calculating the weight numerator for each server based on the processing configuration parameters and network bandwidth configuration parameters for each server includes: Calculate the processing parameters for each server based on the number of processing cores and processing frequency of each server; The weight numerator of each server is calculated based on the processing parameters and network bandwidth configuration parameters of each server.
[0009] Optionally, the load information includes: processor utilization and network utilization; calculating the performance weight of each server based on the load information and weight numerator of each server includes: Calculate the load on each server based on its processor utilization and network utilization. Calculate the performance weight of each server based on its load and weight numerator.
[0010] Optionally, generating random numbers for the target network load includes: A quantum random number generator is used to generate quantum random numbers as random numbers for the target network load.
[0011] Optionally, determining the expected weight for the target network load based on the performance weights of the plurality of servers and the random number includes: The expected weight for the target network load is determined by multiplying the total weight of the performance weights of the multiple servers with the random number.
[0012] Optionally, determining the target server from the plurality of servers based on the performance weights of the plurality of servers and the desired weight includes: Based on the performance weights, the multiple servers are traversed sequentially. The cumulative weight of the currently traversed server is calculated based on the performance weight of the currently traversed server and the performance weight of the already traversed servers. If the accumulated weight is greater than or equal to the expected weight, then the current traversed server is determined to be the target server; If the accumulated weight is less than the expected weight, then continue to traverse the multiple servers until the target server is obtained.
[0013] Optionally, the method further includes: Obtain the configuration and load information of the newly connected server; Based on the configuration and load information of the newly accessed server, determine the performance weight of the newly accessed server; The newly accessed server is added to the server cluster, and its performance weight is stored.
[0014] Secondly, embodiments of this application also provide a load balancing device applied to a load balancer, the device comprising: The weight determination module is used to determine the performance weights of the multiple servers based on their load and configuration information in the server cluster. A random number generation module is used to generate random numbers for the target network load in response to a triggering event of the target network load. The weight determination module is further configured to determine the expected weight for the target network load based on the performance weights of the plurality of servers and the random number. The server determination module is used to determine the target server from the plurality of servers based on the performance weights of the plurality of servers and the expected weights; The request sending module is used to send a scheduling request to the target server for the target network load, so that the target server can process the target network load.
[0015] Optionally, the configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server; the weight determination module includes: The weight numerator calculation unit is used to calculate the weight numerator of each server based on the processing configuration parameters and network bandwidth configuration parameters of each server. The performance weight calculation unit is used to calculate the performance weight of each server based on the load information and weight numerator of each server.
[0016] Optionally, the processing configuration parameters include: the number of processing cores and the processing frequency; the weight numerator calculation unit is specifically used to calculate the processing parameters of each server based on the number of processing cores and the processing frequency of each server; and to calculate the weight numerator of each server based on the processing parameters of each server and the network bandwidth configuration parameters.
[0017] Optionally, the load information includes: processor utilization and network utilization; the performance weight calculation unit is specifically used to calculate the load of each server based on the processor utilization and network utilization of each server; and to calculate the performance weight of each server based on the load of each server and the weight numerator.
[0018] Optionally, the random number generation module is specifically used to generate quantum random numbers using a quantum random number generator as random numbers for the target network load.
[0019] Optionally, the weight determination module is further configured to determine the expected weight for the target network load based on the product of the total weight of the performance weights of the plurality of servers and the random number.
[0020] Optionally, the server determination module is specifically configured to: sequentially traverse the plurality of servers according to the magnitude of the performance weight; calculate the cumulative weight of the currently traversed server based on the performance weight of the currently traversed server and the performance weight of the previously traversed servers; if the cumulative weight is greater than or equal to the expected weight, then determine the currently traversed server as the target server; if the cumulative weight is less than the expected weight, then continue traversing the plurality of servers until the target server is obtained.
[0021] Optionally, the device further includes: The server access module is used to obtain the configuration information and load information of the newly accessed server; determine the performance weight of the newly accessed server based on the configuration information and load information; add the newly accessed server to the server cluster and store the performance weight of the newly accessed server.
[0022] Thirdly, embodiments of this application also provide a load balancer, including: a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the load balancer is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the load balancing method as described in any of the first aspects.
[0023] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the load balancing method as described in any of the first aspects.
[0024] The beneficial effects of this application are: The load balancing method, apparatus, and load balancer provided in this application determine the performance weight of each server based on the load and configuration information of each server in a server cluster. They determine the desired weight based on a random number generated for the target network load and the performance weights of multiple servers. A target server is then selected from the multiple servers based on the performance weights and the target server's performance weights, allowing it to process the target network load. The performance weights are calculated based on the server's configuration information, enabling compatibility with servers of different computing power. Furthermore, the performance weights are calculated based on the server's load information, allowing for dynamic server scheduling based on the server's load status. This achieves dynamic load balancing for servers with different computing power within a compatible server cluster. Attached Figure Description
[0025] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a schematic diagram of the architecture of the load balancing system provided in the embodiments of this application; Figure 2 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 1 ; Figure 3 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 2 ; Figure 4 A flowchart illustrating the load configuration method provided in the embodiments of this application. Figure 3 ; Figure 5 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 4 ; Figure 6 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 5 ; Figure 7 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 6 ; Figure 8 This is a schematic diagram of load balancing provided in an embodiment of this application; Figure 9 This is a schematic diagram of the structure of the load balancing device provided in the embodiments of this application; Figure 10 A schematic diagram of a load balancer provided in an embodiment of this application. Detailed Implementation
[0027] 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 some embodiments of this application, but not all embodiments.
[0028] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0029] Furthermore, the terms "first," "second," etc., used 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 orders other than those illustrated or described herein. Additionally, the terms "comprising" and "having," and any variations thereof, are intended to cover a 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.
[0030] It should be noted that, where there is no conflict, the features in the embodiments of this application can be combined with each other.
[0031] The load balancing method provided in this application is applied to the load balancer in a load balancing system. Figure 1 This is a schematic diagram of the architecture of the load balancing system provided in the embodiments of this application, such as... Figure 1 As shown, the load balancing system may include at least a load balancer 100 and multiple servers 200, with the multiple servers 200 forming a server cluster.
[0032] The load balancer can be deployed on a Linux server, and the load balancing program can be run on the Linux server to execute the load balancing method provided in this application.
[0033] Figure 2 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 1 ,like Figure 2 As shown, the method may include: S201: Determine the performance weights of multiple servers based on their load and configuration information in the server cluster.
[0034] In this embodiment, the server cluster includes multiple servers, which can be of the same type or different types. The server configuration information is the computing power information configured when the server joins the server cluster. This computing power information is used to indicate the amount of load the server can handle. The server load information is the load status information of the load tasks currently being executed by the server, i.e., the server's computing power utilization rate.
[0035] Load balancers analyze server load and configuration information to calculate server performance weights. Performance weights indicate the remaining computing power a server can handle. The more and more complex the load tasks a server is currently executing, the lower its performance weight. Conversely, the fewer and simpler the load tasks a server is currently executing, the higher its performance weight.
[0036] For example, the performance weight of a server can be determined based on the ratio of its configuration information to its load information.
[0037] In some embodiments, the load balancer can obtain the load information of multiple servers each time it receives new network load, and calculate the performance weight of multiple servers based on the configuration information saved when the multiple servers access the server cluster.
[0038] In other embodiments, the load balancer can calculate the performance weights of multiple servers based on the load information reported by the heartbeats of multiple servers at regular intervals, as well as the configuration information saved when multiple servers access the server cluster.
[0039] S202: In response to a trigger event of target network load, generate a random number for the target network load.
[0040] In this embodiment, the target network load is the target workload received by the server cluster, and the triggering event for the target network load is the processing request for the target workload received by the server cluster. After receiving the triggering event for the target network load, the load balancer generates a random number for the target network load. The random number is a random number in the range [0-1].
[0041] In some embodiments, the load balancer may further include a random number generator. After receiving a trigger event for the target network load, the load balancer uses the random number generator to generate a random number for the target network load. Specifically, based on the random number generator, different random numbers can be generated for each network load requesting processing from the server cluster, ensuring that different network loads can be distributed to different servers for processing.
[0042] S203: Determine the expected weight for the target network load based on the performance weights of multiple servers and a random number.
[0043] In this embodiment, the expected weight can be a performance weight determined by random numbers for the target network load. The expected weight can be determined by calculating the performance weights of multiple servers based on random numbers.
[0044] In some embodiments, the expected weight can be calculated as follows: the random performance weight of multiple servers is determined by multiplying the performance weight of multiple servers with the random number, and the expected weight is determined based on the random performance weight of multiple servers. The expected weight can be the maximum value, median value, or average value among the random performance weights of multiple servers.
[0045] In other embodiments, the expected weight can be calculated by determining the average performance weight of the server cluster based on the performance weights of multiple servers, and then determining the expected weight of the target network load based on the average performance weight and a random number. In this case, the expected weight of the target network load can be determined by multiplying the average performance weight and the random number.
[0046] For example, the average performance weight can be the arithmetic mean, weighted average, mean squared average, etc. of the performance weights of multiple servers, and this embodiment does not limit this.
[0047] S204: Determine the target server from multiple servers based on their performance weights and expected weights.
[0048] In this embodiment, the performance weights and expected weights of multiple servers are compared, and the server corresponding to the performance weight that meets the conditions is determined as the target server.
[0049] In some embodiments, the difference between the performance weights and expected weights of multiple servers can be calculated, and the server with the performance weight that is greater than the expected weight and has the smallest difference with the expected weight can be identified as the target server.
[0050] In other embodiments, the performance weights of multiple servers can be sorted from smallest to largest, and the relationship between the performance weight and the expected weight of each server can be determined in turn. The server with the first performance weight greater than the expected weight can be identified as the target server.
[0051] S205: Send a scheduling request to the target server for the target network load so that the target server can process the target network load.
[0052] In this implementation, after the load balancer determines the target server from multiple servers in the server cluster, it sends a scheduling request for the target network load to the target server, which then executes the target network load and obtains the load execution result.
[0053] The load balancing method provided in the above embodiments determines the performance weight of each server based on the load information and configuration information of each server in the server cluster. It determines the expected weight based on the random number generated for the target network load and the performance weights of multiple servers. It determines the target server from multiple servers based on the performance weights of multiple servers and the target server to process the target network load. It calculates the performance weight based on the server's configuration information, which can achieve compatibility with servers with different computing power. It calculates the performance weight based on the server's load information, which can achieve dynamic scheduling of servers according to the server's load status, thereby achieving dynamic load balancing of servers with different computing power in the compatible server cluster.
[0054] In one possible implementation, Figure 3 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 2 ,like Figure 3 As shown, the process of determining the performance weights of multiple servers based on their load and configuration information in the server cluster, as described in S201, may include: S211: Calculate the weight numerator for each server based on its processing configuration parameters and network bandwidth configuration parameters.
[0055] The configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server.
[0056] In this embodiment, the server's processing configuration parameters are parameters that indicate the server's hardware processing performance, and these processing configuration parameters are fixed values. The server's network bandwidth configuration parameters are parameters that indicate the network bandwidth that the server possesses.
[0057] The server's hardware processing performance and network bandwidth determine the server's computing power, i.e., the amount of load the server can handle. When calculating the server's performance weight based on the server's load information and configuration information, the server's configuration information is used as the weight numerator. Specifically, the weight numerator can be calculated based on the processing configuration parameters and network bandwidth configuration parameters.
[0058] For example, the formula for calculating the weight numerator can be expressed as: Weight numerator = Processing configuration parameters + Network bandwidth configuration parameters.
[0059] S212: Calculate the performance weight of each server based on its load information and weight numerator.
[0060] In this embodiment, a weight denominator is generated based on the processor's load information. The performance weight of each server can be calculated based on the ratio of the weight numerator to the weight denominator. The server's load information indicates the server's computing power utilization rate, which is a value less than 1. To determine that the more load tasks a server is currently executing and the more complex the load tasks, the smaller the server's performance weight, a weight denominator greater than 1 needs to be obtained based on the processor's load information and a preset value.
[0061] For example, the formula for calculating the server's performance weight can be expressed as: Performance weight = weight numerator / (1 + load information), where 1 + load information is the weight denominator.
[0062] In one possible implementation, Figure 4 A flowchart illustrating the load configuration method provided in the embodiments of this application. Figure 3 ,like Figure 4 As shown, the process of calculating the weight numerator of each server based on the processing configuration parameters and network bandwidth configuration parameters of each server in S211 above may include: S301: Calculate the processing parameters for each server based on the number of processing cores and processing frequency of each server.
[0063] S302: Calculate the weight numerator for each server based on its processing parameters and network bandwidth configuration parameters.
[0064] The processor's processing configuration parameters include: number of processing cores and processing frequency.
[0065] In this embodiment, the number of processing cores refers to the number of integrated computing cores of the server's central processing unit (CPU), such as single-core or multi-core, and the processing frequency refers to the computing frequency of the central processing unit, such as 1GHz or 2GHz.
[0066] The number of processing cores and the processing frequency of a server determine its processing efficiency. Based on the number of processing cores and the processing frequency, the server's processing parameters can be calculated. The formula for calculating the processing parameters can be expressed as: number of processing cores * processing frequency.
[0067] The server's processing parameters indicate the server's hardware processing performance, while the server's network bandwidth configuration parameters indicate the network bandwidth the server possesses. The server's hardware processing performance and network bandwidth determine the server's computing power, i.e., the amount of load the server can handle. Specifically, the weight numerator can be calculated based on the processing parameters and network bandwidth configuration parameters.
[0068] The load balancing method provided in the above embodiments calculates the weight numerator of each server based on the processing configuration parameters and network bandwidth configuration parameters of each server, and calculates the performance weight based on the load information and weight numerator of each server. Servers with different processing configuration parameters and network bandwidth configuration parameters can be connected to the server cluster, thereby achieving compatibility with servers with different computing power and improving the processing efficiency of network load.
[0069] In one possible implementation, Figure 5 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 4 ,like Figure 5 As shown, the process of calculating the performance weight of each server based on the load information and weight numerator of each server in S212 above may include: S303: Calculate the load on each server based on its processor utilization and network utilization.
[0070] S304: Calculate the performance weight of each server based on its load and weight numerator.
[0071] The load information includes processor utilization and network utilization.
[0072] In this embodiment, the server's processor utilization is calculated based on the server's processing parameters and the computing power consumed by the currently executing load tasks. The server's network utilization is calculated based on the server's network bandwidth configuration parameters and the network bandwidth consumed by the currently executing load tasks. Based on the server's processor utilization and network utilization, the server's load can be determined. For example, the formula for calculating the load can be expressed as: (Processor utilization + Network utilization) / 2.
[0073] The weight denominator is generated based on the processor load. The performance weight of each server can be calculated based on the ratio of the weight numerator to the weight denominator. The server load is a value less than 1. To determine that the more load tasks a server is currently executing and the more complex the load tasks, the smaller the server's performance weight, a weight denominator greater than 1 needs to be obtained based on the processor load and preset values.
[0074] For example, the formula for calculating the server's performance weight can be expressed as: Performance weight = weight numerator / (1 + load), where 1 + load information is the weight denominator.
[0075] The load balancing method provided in the above embodiments calculates the server load based on the server's processor utilization and network utilization, and then calculates the server's performance weight based on the server's load and weight numerator. By dynamically calculating the server's performance weight through the server's processor utilization and network utilization, dynamic scheduling of servers can be achieved, thereby realizing load balancing.
[0076] In one possible implementation, the process of generating random numbers for the target network load in S202 above may include: A quantum random number generator is used to generate quantum random numbers as random numbers for the target network load.
[0077] In this embodiment, the load balancer also includes a quantum random number generator. Quantum random numbers are generated using the uncertainty principle of quantum mechanics. Their randomness is determined by the unpredictability and uncertainty of quantum systems. Using a quantum random number generator to generate quantum random numbers as random numbers for the target network load results in higher randomness than that generated by pseudo-random number generation methods. This ensures a high degree of randomness when calculating the expected weight based on the random numbers, making server scheduling more even when determining the target server based on the expected weight. Furthermore, since the performance of the quantum random number generator is higher than that of the traditional pseudo-random number generation method, it can greatly improve the efficiency of the load balancer in scheduling servers and improve the efficiency of servers in the server cluster in handling network load.
[0078] In one possible implementation, the process of determining the desired weight for the target network load based on the performance weights of multiple servers and a random number in step S203 may include: The expected weight for the target network load is determined by multiplying the total weight of the performance weights of multiple servers by a random number.
[0079] In this embodiment, the performance weights of multiple servers in the server cluster are summed to obtain the total weight of the server cluster. The expected weight for the target network load is obtained by multiplying the total weight by a random number.
[0080] In some embodiments, the desired weights for the target network load are obtained by multiplying the total weights by a quantum random number.
[0081] In one possible implementation, Figure 6 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 5 ,like Figure 6 As shown, based on the expected weight obtained by multiplying the total weight by a random number, the process of determining the target server from multiple servers in step S204, according to the performance weights and expected weights of multiple servers, may include: S401: Based on the performance weight, traverse multiple servers sequentially.
[0082] S402: Calculate the cumulative weight of the currently traversed server based on the performance weight of the currently traversed server and the performance weight of the servers already traversed.
[0083] S403: If the accumulated weight is greater than or equal to the expected weight, then the current traversed server is determined to be the target server.
[0084] S404: If the accumulated weight is less than the expected weight, continue to traverse multiple servers until the target server is found.
[0085] In this embodiment, in order to achieve load balancing, servers with high performance weights need to be selected as target servers. Therefore, the servers are sorted in reverse order according to their performance weights, with servers with high performance weights ranked first and servers with low performance weights ranked last.
[0086] The system iterates through multiple servers in reverse order, determining whether the performance weight of the first server is greater than or equal to the expected weight. If the performance weight of the first server is greater than or equal to the expected weight, the first server is designated as the target server. If the performance weight of the first server is less than the expected weight, the system continues to iterate through the second server. Based on the performance weight of the second server and the performance weight of the first server already iterated through, the system calculates the cumulative weight of the first and second servers. The system then determines whether the cumulative weight of the first and second servers is greater than or equal to the expected weight. If the cumulative weight of the first and second servers is greater than or equal to the expected weight, the second server is designated as the target server. If the cumulative weight of the first and second servers is less than the expected weight, the system continues to iterate through the third server, and so on, until a server with a cumulative weight greater than or equal to the expected weight is found and designated as the target server.
[0087] The load balancing method provided in the above embodiments traverses the servers in reverse order, determines whether the performance weight of the currently traversed server and the cumulative weight of the performance weights of the traversed servers are greater than or equal to the expected weight, thereby determining the target server, and achieving server load balancing based on the cumulative weight and the expected weight, making the scheduling of each server in the server cluster more even.
[0088] In one possible implementation, Figure 7 A flowchart illustrating the load balancing method provided in the embodiments of this application. Figure 6 ,like Figure 7 As shown, the method may further include: S501: Obtain the configuration and load information of the newly connected server.
[0089] S502: Determine the performance weight of the newly accessed server based on its configuration and load information.
[0090] S503: Add the newly accessed server to the server cluster and store the performance weight of the newly accessed server.
[0091] In this embodiment, when a new server needs to connect to the server cluster, the new server actively reports its configuration information and load information to the load balancer. The load balancer calculates the performance weight based on the configuration information and load information of the new server. The performance weight at this time is the initial performance weight of the new server when it connects to the server cluster. The method of calculating the performance weight will not be described in detail here.
[0092] After calculating the performance weight of the newly connected server, the load balancer adds the new server to the server cluster and reorders the servers according to the performance weight of the new server and the performance weight of the existing servers in the server cluster.
[0093] Afterward, the newly connected server will periodically report its load information, and the load balancer will update the performance weight of the newly connected server based on the periodically reported load information and configuration settings.
[0094] It should be noted that after each server in the server cluster reports its load information, the load balancer calculates the updated performance weights, and the servers need to be reordered based on these updated performance weights.
[0095] The load balancing method provided in the above embodiments calculates the performance weight of the newly accessed server based on its configuration information and load information, adds the newly accessed server to the server cluster and stores its performance weight, thereby realizing dynamic scaling of the server cluster. This eliminates the need for users to manually add servers and configure their performance weights, allowing the load balancer to more flexibly schedule servers in the server cluster.
[0096] Example, Figure 8 This is a load balancing diagram provided in an embodiment of this application, such as... Figure 8 As shown, server 1 has a single processing core, a processing frequency of 1GHz, and a network bandwidth configuration parameter of 500Mbps uplink bandwidth. Server 2 has a dual processing core, a processing frequency of 2GHz, and a network bandwidth configuration parameter of 500Mbps uplink bandwidth. Server 3 has a single processing core, a processing frequency of 1GHz, and a network bandwidth configuration parameter of 200Mbps uplink bandwidth. Taking server 1 as an example, the performance weight of server 1 = weight numerator / (1 + load) = (processing parameters + network bandwidth configuration parameter) / (1 + (processor utilization + network utilization) / 2) = [(number of processing cores * processing frequency) + network bandwidth configuration parameter] / (1 + (processor utilization + network utilization) / 2) = [(1 * 1000) + 500] / (1 + (0.5 + 0.5) / 2) = 1000.
[0097] Based on performance weights, the servers in the server cluster are sorted to obtain the sorted servers. The performance weight of server 2 is greater than that of server 1, and the performance weight of server 1 is greater than that of server 3.
[0098] The expected weight is obtained by multiplying the performance weights of the three servers by a random number. The performance weight of server 2 is less than the expected weight, and the sum of the performance weights of server 2 and server 1 is greater than the expected weight. Therefore, server 1 is determined to be the target server.
[0099] Based on the above method embodiments, this application also provides a load balancing device applied to a load balancer. Figure 9This is a schematic diagram of the structure of the load balancing device provided in the embodiments of this application, as shown below. Figure 9 As shown, the device may include: The weight determination module 601 is used to determine the performance weights of multiple servers based on their load and configuration information in the server cluster. The random number generation module 602 is used to generate random numbers for the target network load in response to a triggering event of the target network load. The weight determination module 601 is also used to determine the expected weight for the target network load based on the performance weights of multiple servers and random numbers. Server determination module 603 is used to determine the target server from multiple servers based on the performance weights and expected weights of multiple servers; The request sending module 604 is used to send a scheduling request for the target network load to the target server so that the target server can process the target network load.
[0100] Optionally, the configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server; the weight determination module 601 includes: The weight numerator calculation unit is used to calculate the weight numerator of each server based on the processing configuration parameters and network bandwidth configuration parameters of each server. The performance weight calculation unit is used to calculate the performance weight of each server based on the load information and weight numerator of each server.
[0101] Optionally, the processing configuration parameters include: the number of processing cores and the processing frequency; a weight numerator calculation unit, specifically used to calculate the processing parameters of each server based on the number of processing cores and the processing frequency of each server; and to calculate the weight numerator of each server based on the processing parameters of each server and the network bandwidth configuration parameters.
[0102] Optionally, the load information includes: processor utilization and network utilization; a performance weight calculation unit, specifically used to calculate the load of each server based on the processor utilization and network utilization of each server; and to calculate the performance weight of each server based on the load of each server and the weight numerator.
[0103] Optionally, the random number generation module 602 is specifically used to generate quantum random numbers as random numbers for the target network load using a quantum random number generator.
[0104] Optionally, the weight determination module 601 is also used to determine the expected weight for the target network load based on the product of the total weight of the performance weights of multiple servers and a random number.
[0105] Optionally, the server determination module 603 is specifically used to traverse multiple servers sequentially according to their performance weights; calculate the cumulative weight of the currently traversed server based on the performance weight of the currently traversed server and the performance weights of the previously traversed servers; if the cumulative weight is greater than or equal to the expected weight, then the currently traversed server is determined as the target server; if the cumulative weight is less than the expected weight, then the traversal of multiple servers continues until the target server is obtained.
[0106] Optionally, the device may further include: The server access module is used to obtain the configuration and load information of newly accessed servers; determine the performance weight of newly accessed servers based on their configuration and load information; add the newly accessed servers to the server cluster and store their performance weights.
[0107] The above-described apparatus is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effects are similar, so they will not be described again here.
[0108] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0109] Figure 10 A schematic diagram of the load balancer provided in the embodiments of this application is shown below. Figure 10 As shown, the load balancer 100 may include a processor 101, a storage medium 102, and a bus. The storage medium 102 stores program instructions executable by the processor 101. When the load balancer 100 is running, the processor 101 communicates with the storage medium 102 via the bus, and the processor 101 executes the program instructions to perform the above-described method embodiment. The specific implementation and technical effects are similar and will not be described in detail here.
[0110] Optionally, this application also provides a program product, such as a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the above-described method embodiments.
[0111] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0112] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0113] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0114] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0115] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A load balancing method, characterized in that, Applied to load balancers, the method includes: Based on the load and configuration information of multiple servers in the server cluster, the performance weights of the multiple servers are determined respectively. In response to a triggering event of the target network load, generate a random number for the target network load; Based on the performance weights of the multiple servers and the random number, determine the expected weight for the target network load; The target server is determined from the plurality of servers based on the performance weights of the plurality of servers and the expected weights. A scheduling request for the target network load is sent to the target server so that the target server can process the target network load; The configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server; the process of determining the performance weights of the multiple servers based on their load information and configuration information in the server cluster includes: Calculate the weight numerator for each server based on its processing configuration parameters and network bandwidth configuration parameters; Based on the load information and weight numerator of each server, the performance weight of each server is calculated, where the performance weight = weight numerator / (1 + load information), and 1 + load information is the weight denominator.
2. The method according to claim 1, characterized in that, The processing configuration parameters include: the number of processing cores and the processing frequency; the calculation of the weight numerator for each server based on the processing configuration parameters and network bandwidth configuration parameters of each server includes: Calculate the processing parameters for each server based on the number of processing cores and processing frequency of each server; The weight numerator of each server is calculated based on the processing parameters and network bandwidth configuration parameters of each server.
3. The method according to claim 1, characterized in that, The load information includes: processor utilization and network utilization; the calculation of the performance weight of each server based on the load information and weight numerator of each server includes: Calculate the load on each server based on its processor utilization and network utilization. Calculate the performance weight of each server based on its load and weight numerator.
4. The method according to claim 1, characterized in that, The generation of random numbers for the target network load includes: A quantum random number generator is used to generate quantum random numbers as random numbers for the target network load.
5. The method according to claim 1, characterized in that, Determining the expected weight for the target network load based on the performance weights of the plurality of servers and the random number includes: The expected weight for the target network load is determined by multiplying the total weight of the performance weights of the multiple servers with the random number.
6. The method according to claim 5, characterized in that, The step of determining the target server from the plurality of servers based on the performance weights of the plurality of servers and the expected weights includes: Based on the performance weights, the multiple servers are traversed sequentially. The cumulative weight of the currently traversed server is calculated based on the performance weight of the currently traversed server and the performance weight of the already traversed servers. If the accumulated weight is greater than or equal to the expected weight, then the current traversed server is determined to be the target server; If the accumulated weight is less than the expected weight, then continue to traverse the multiple servers until the target server is obtained.
7. The method according to claim 1, characterized in that, The method further includes: Obtain the configuration and load information of the newly connected server; Based on the configuration and load information of the newly accessed server, determine the performance weight of the newly accessed server; The newly accessed server is added to the server cluster, and its performance weight is stored.
8. A load balancing device, characterized in that, Applied to a load balancer, the device includes: The weight determination module is used to determine the performance weights of the multiple servers based on their load and configuration information in the server cluster. A random number generation module is used to generate random numbers for the target network load in response to a triggering event of the target network load. The weight determination module is further configured to determine the expected weight for the target network load based on the performance weights of the plurality of servers and the random number. The server determination module is used to determine the target server from the plurality of servers based on the performance weights of the plurality of servers and the expected weights; The request sending module is used to send a scheduling request to the target server for the target network load, so that the target server can process the target network load; The configuration information for each server includes: processing configuration parameters and network bandwidth configuration parameters for each server; the weight determination module includes: The weight numerator calculation unit is used to calculate the weight numerator of each server based on the processing configuration parameters and network bandwidth configuration parameters of each server. The performance weight calculation unit is used to calculate the performance weight of each server based on the load information and weight numerator of each server. The performance weight is calculated as: weight numerator / (1 + load information), where 1 + load information is the weight denominator.
9. A load balancer, characterized in that, include: The system includes a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the load balancer is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the load balancing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Load balancing system based on dynamic weight
CN112217894A
Task scheduling method and device, electronic equipment and storage medium
CN117215773A