Load balancing method, device, equipment, medium and program product
By monitoring the server's load indicators and network bandwidth, and dynamically adjusting the data migration amount, the shortcomings of load imbalance detection and processing in the existing technology are solved, and the computing efficiency of the server is improved.
Patent Information
- Application Number
- CN202411911163.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-24
AI Technical Summary
When the prior art realizes server load balancing, it is impossible to detect and deal with load imbalance in time, resulting in insufficiency of server computing.
By monitoring the CPU utilization, memory utilization, and number of accesses for each server, the load pressure is calculated and the load pressure difference is determined. Determine the data migration based on the load pressure difference and network bandwidth limit value, and migrate the calculated data from a server with a high load to a server with a low load process.
It realizes a timely discovery and processing of load imbalanced servers, improving the utilization rate of computing resources and the processing efficiency of computing data.
Smart Images

Figure CN119697190A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and in particular to a load balancing method, device, equipment, medium and program product. Background Art
[0002] Load balancing, as a technology for distributing resources in computer networks, is mainly used to distribute network traffic or requests to multiple servers for processing to ensure that the load between servers is relatively even and avoid single-point overload, thereby maximizing the performance and stability of the overall system.
[0003] In the prior art, server load balancing is usually achieved through a modulo hash algorithm, a consistent hash algorithm, or a consistent hash algorithm with virtual nodes.
[0004] However, the method of achieving server load balancing through the modulo hash algorithm, the consistent hash algorithm or the consistent hash algorithm with virtual nodes can only determine the calculation data distribution rules, and cannot timely discover the imbalance of server load, resulting in the inability to timely handle the imbalance of server load, thereby making the server's calculation efficiency low. Secondly, using the existing technology to load balance each server requires recalculating the location of each calculation data, causing calculation interruptions and additional time overhead, reducing the processing efficiency of calculation data. Summary of the invention
[0005] The present invention provides a load balancing method, device, equipment, medium and program product, which can timely discover and process servers with unbalanced loads and improve the computing efficiency of the servers.
[0006] In a first aspect, an embodiment of the present invention provides a load balancing method, including:
[0007] Determine the load pressure of each server based on the CPU utilization, memory utilization and number of accesses of each server, and calculate the load pressure difference between servers;
[0008] Obtaining a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determining a data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server;
[0009] Determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server;
[0010] According to the amount of data migration, the calculated data on the data sending server is migrated to the data receiving server for processing.
[0011] Optionally, the load pressure of each server is determined based on the CPU utilization, memory utilization and number of visits of each server, including: taking a weighted sum of the CPU utilization, memory utilization and number of visits of each server to obtain the load pressure of each server; and the data flow resistance from the data sending server to the data receiving server is determined based on the network bandwidth limit value and the data size limit value between the data sending server and the data receiving server, including: taking a weighted sum of the network bandwidth limit value and the data size limit value to obtain the data flow resistance from the data sending server to the data receiving server.
[0012] Optionally, the amount of data migration from the data sending server to the data receiving server is determined based on the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server, including: determining the amount of data migration from the data sending server to the data receiving server based on the division result of the load pressure difference and the data flow resistance.
[0013] Optionally, the calculated data on the data sending server is migrated to the data receiving server for processing, including: determining whether the data migration amount is greater than a set migration amount threshold; if so, calculating the actual migration amount by subtracting the data migration amount from the migration amount threshold, and migrating the calculated data on the data sending server to the data receiving server for processing according to the actual migration amount; obtaining candidate servers other than the data sending server and the data receiving server, and the server number of each candidate server; using a random number generator to generate a random integer based on each server number, and taking the candidate server with the same server number as the random integer as the target server; after migrating the calculated data of the migration amount threshold to the target server, returning to execute the operation of determining the load pressure of each server based on the CPU utilization, memory utilization and number of visits of each server until the load balancing condition is met; if not, obtaining the calculated data of the data migration amount on the data sending server, and migrating the calculated data of the data migration amount to the data receiving server for processing.
[0014] Optionally, the calculation data on the data sending server is migrated to the data receiving server for processing according to the actual migration amount, including: obtaining the target calculation data of the actual migration amount on the data sending server according to the data correlation, data access frequency and data update frequency of each calculation data on the data sending server; and migrating the target calculation data of the actual migration amount to the data receiving server for processing.
[0015] Optionally, the method also includes: collecting the load pressure, load pressure difference and data flow resistance corresponding to each server at a set frequency, and generating a load pressure graph corresponding to each server based on the load pressure, load pressure difference and data flow resistance corresponding to each server; displaying the load pressure graph corresponding to each server so that the user can determine the data sending server, the data receiving server, and the amount of data migration from the data sending server to the data receiving server based on the load pressure, load pressure difference and data flow resistance on the load pressure graph.
[0016] In a second aspect, an embodiment of the present invention further provides a load balancing device, including:
[0017] A load pressure difference determination module is used to determine the load pressure of each server according to the CPU utilization, memory utilization and access quantity of each server, and calculate the load pressure difference between the servers;
[0018] A data flow resistance determination module is used to obtain a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determine the data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server;
[0019] A data migration amount determination module, used to determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server;
[0020] The data migration module is used to migrate the calculated data on the data sending server to the data receiving server for processing according to the data migration amount.
[0021] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0022] at least one processor; and
[0023] a memory communicatively connected to at least one processor; wherein,
[0024] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the load balancing method provided by any embodiment of the present invention.
[0025] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a processor to implement the load balancing method provided by any embodiment of the present invention when executed.
[0026] In a fifth aspect, an embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the load balancing method provided by any embodiment of the present invention.
[0027] The technical solution of the embodiment of the present invention obtains a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, determines the data migration amount from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server, and migrates the calculated data on the data sending server to the data receiving server for processing according to the data migration amount, thereby avoiding the situation in which the prior art can only determine the calculation data distribution rules but cannot timely discover servers with unbalanced loads, resulting in low server computing efficiency. Servers with unbalanced loads can be discovered and processed in a timely manner, thereby achieving full utilization of computing resources and improving the processing efficiency of computing data.
[0028] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0030] Figure 1 is a flow chart of a load balancing method provided according to Embodiment 1 of the present invention;
[0031] Figure 2 is a flow chart of another load balancing method provided according to Embodiment 2 of the present invention;
[0032] Figure 3 It is a schematic diagram of reallocating computing data on a downed server according to an embodiment of the present invention;
[0033] Figure 4 is a structural diagram of a load balancing device provided according to Embodiment 3 of the present invention;
[0034] Figure 5 It is a schematic diagram of the structure of an electronic device provided by Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0035] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] Embodiment 1
[0038] Figure 1 This is a flow chart of a load balancing method provided according to Embodiment 1 of the present invention. This embodiment is applicable to situations where load balancing is performed on each server. The method can be executed by a load balancing device. The load balancing device can be implemented in the form of hardware and / or software. The load balancing device can be configured in an electronic device such as a computer.
[0039] like Figure 1 As shown, a load balancing method disclosed in this embodiment includes:
[0040] S110 , determining the load pressure of each server according to the CPU utilization, memory utilization and access quantity of each server, and calculating the load pressure difference between the servers.
[0041] In this step, specifically, the load pressure of each server can be determined according to the sum of the CPU utilization, memory utilization and the number of accesses of each server. Alternatively, the CPU utilization, memory utilization and the number of accesses of each server can be weighted and summed to obtain the load pressure of each server.
[0042] S120, obtaining a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determining a data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server.
[0043] In this embodiment, the data flow resistance can be used to reflect the resistance of computing data to be transmitted between the data sending server and the data receiving server.
[0044] In this step, specifically, it can be determined whether the load pressure difference between the servers is greater than or equal to the set pressure difference threshold, and the servers whose load pressure difference is greater than or equal to the set pressure difference threshold are used as data sending servers and data receiving servers. Among them, the load pressure of the data sending server is greater than the load pressure of the data receiving server. The pressure difference threshold can be determined according to user needs and / or historical experience.
[0045] Then, the network bandwidth limit value and the data size limit value when data is transmitted between the data sending server and the data receiving server can be obtained, and the data flow resistance from the data sending server to the data receiving server can be determined according to the network bandwidth limit value and the data size limit value. Exemplarily, the data flow resistance from the data sending server to the data receiving server can be determined according to the sum of the network bandwidth limit value and the data size limit value. Alternatively, the data flow resistance from the data sending server to the data receiving server can be determined according to the weighted sum of the network bandwidth limit value and the data size limit value. The network bandwidth limit value can be determined according to user needs and / or historical experience. The data size limit value can be determined according to the data size of each transmission between the sending server and the data receiving server, for example, the data size limit value can be determined according to the average value of the data size of each transmission.
[0046] S130: Determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server.
[0047] In this step, specifically, the amount of data migration from the data sending server to the data receiving server may be determined according to the ratio of the load pressure difference to the data flow resistance.
[0048] S140. Migrate the calculated data on the data sending server to the data receiving server for processing according to the data migration amount.
[0049] In this step, specifically, the calculation data of the data migration amount can be obtained on the data sending server, and the calculation data of the data migration amount can be migrated to the data receiving server for processing.
[0050] The technical solution of this embodiment determines the load pressure of each server according to the CPU utilization, memory utilization and number of visits of each server, and calculates the load pressure difference between the servers; obtains the data sending server and the data receiving server whose load pressure difference is greater than or equal to the set pressure difference threshold, and determines the data flow resistance from the data sending server to the data receiving server according to the network bandwidth limit value and the data size limit value between the data sending server and the data receiving server; determines the data migration amount from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server; and according to the data migration amount, migrates the calculated data on the data sending server to the data receiving server for processing. This technical means solves the problem that the prior art can only determine the calculation data distribution rules but cannot timely discover servers with unbalanced loads, resulting in low server computing efficiency. It can timely discover and process servers with unbalanced loads, realize full utilization of computing resources, and improve the server computing efficiency.
[0051] Embodiment 2
[0052] Figure 2 It is a flow chart of another load balancing method provided according to the second embodiment of the present invention. This embodiment is a further optimization and expansion based on the above embodiments, and can be combined with various optional technical solutions in the above implementation methods.
[0053] like Figure 2 As shown, a load balancing method disclosed in this embodiment includes:
[0054] S210 , performing weighted summation on the CPU utilization, memory utilization and access quantity of each server respectively to obtain the load pressure of each server, and calculating the load pressure difference between the servers.
[0055] In this step, specifically, the CPU utilization can be multiplied by the first weight coefficient to obtain a first multiplication result, the memory utilization can be multiplied by the second weight coefficient to obtain a second multiplication result, and the number of accesses can be multiplied by the third weight coefficient to obtain a third multiplication result. Among them, the first weight coefficient, the second weight coefficient, and the third weight coefficient can be determined according to the user's emphasis on the CPU utilization, the memory utilization, and the number of accesses. Then, the sum of the first multiplication result, the second multiplication result, and the third multiplication result can be calculated to obtain the load pressure of the server.
[0056] Exemplarily, the load pressure of each server can be determined by the following specific calculation formula:
[0057] Pi=w1×CPUi+w2×Memoryi+w3×Requesti
[0058] Where Pi is the load pressure, w1 is the first weight coefficient, w2 is the second weight coefficient, w3 is the third weight coefficient, CPUi is the CPU utilization, Memoryi is the memory utilization, and Requesti is the number of accesses.
[0059] The advantage of this setting is that the server load pressure is obtained by taking a weighted sum of the server's CPU utilization, memory utilization and number of visits, which fully considers the impact of the importance of CPU utilization, memory utilization and number of visits on the load pressure calculation, thereby improving the accuracy of the calculated load pressure.
[0060] S220, obtaining a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and performing weighted summation on the network bandwidth limit value and the data size limit value to obtain a data flow resistance from the data sending server to the data receiving server.
[0061] In this step, specifically, the network bandwidth limit value and the fourth weight coefficient may be multiplied to obtain a fourth multiplication result, and the data size limit value and the fifth weight coefficient may be multiplied to obtain a fifth multiplication result. The fourth weight coefficient and the fifth weight coefficient may be determined according to the importance that the user attaches to the network bandwidth limit value and the data size limit value. Then, the sum of the fourth multiplication result and the fifth multiplication result may be calculated to obtain the data flow resistance from the data sending server to the data receiving server.
[0062] Exemplarily, the data flow resistance from the data sending server to the data receiving server may be determined by the following specific calculation formula:
[0063] Rij=k1×Netwidthij+k2×Dataij
[0064] Among them, Rij is the data flow resistance, k1 is the fourth weight coefficient, k2 is the fifth weight coefficient, Netwidthij is the network bandwidth limit value, and Dataij is the data size limit value.
[0065] The advantage of this setting is that the data flow resistance from the data sending server to the data receiving server is obtained by taking a weighted sum of the network bandwidth limit value and the data size limit value, taking into account the impact of the importance of the network bandwidth limit value and the data size limit value on the data flow resistance, thereby improving the accuracy of the calculated data flow resistance.
[0066] S230: Determine the amount of data migration from the data sending server to the data receiving server according to the result of dividing the load pressure difference by the data flow resistance.
[0067] In this step, specifically, the load pressure difference may be divided by the data flow resistance to obtain the amount of data migration from the data sending server to the data receiving server.
[0068] Exemplarily, the amount of data migration from the data sending server to the data receiving server may be determined by the following specific calculation formula:
[0069]
[0070] Among them, Qij is the data migration amount, Pij is the load pressure difference, and Rij is the data flow resistance. Specifically, the load pressure difference can be determined according to the formula Pij=Pi-Pj, where Pi is the load pressure of the data sending server and Pj is the load pressure of the data receiving server.
[0071] The advantage of this setting is that the amount of data migration from the data sending server to the data receiving server is determined by the load pressure difference and the data flow resistance. While considering the impact of the load pressure difference on the data migration amount, the impact of the data flow resistance on the data migration amount is also considered, thereby improving the accuracy of the calculated data migration amount.
[0072] S240: Determine whether the data migration amount is greater than a set migration amount threshold. If so, execute S250; if not, execute S290.
[0073] In this step, specifically, the total amount of calculated data distributed to each server for processing can be divided by the total number of servers to obtain a migration threshold. Then, when the data migration amount is greater than the set migration threshold, the calculated data of the data migration amount can be migrated to the data receiving server and other servers for processing. When the data migration amount is less than or equal to the set migration threshold, the calculated data of the data migration amount can be migrated to the data receiving server for processing.
[0074] S250 , calculating the actual migration amount by subtracting the amount of data migration from the migration amount threshold, and migrating the calculated data on the data sending server to the data receiving server for processing according to the actual migration amount.
[0075] In this step, specifically, after obtaining the actual migration amount by subtracting the migration amount threshold from the data migration amount, calculation data of the actual migration amount can be obtained on the data sending server, and the calculation data of the actual migration amount can be migrated to the data receiving server for processing.
[0076] Optionally, the calculation data on the data sending server is migrated to the data receiving server for processing according to the actual migration amount, including: obtaining the target calculation data of the actual migration amount on the data sending server according to the data correlation, data access frequency and data update frequency of each calculation data on the data sending server; and migrating the target calculation data of the actual migration amount to the data receiving server for processing.
[0077] Specifically, each calculation data may be sorted in ascending order according to data relevance to obtain a first sorting result. Then, when it is detected that there are calculation data with the same data relevance in the first sorting result, the calculation data with the same data relevance may be sorted in ascending order according to the data access frequency to obtain a second sorting result. Thereafter, when it is detected that there are calculation data with the same data access frequency in the second sorting result, the calculation data with the same data access frequency may be sorted in ascending order according to the data update frequency to obtain the actual sorting result of each calculation data on the data sending server. Finally, according to the actual sorting result, the target calculation data of the actual migration amount is obtained on the data sending server, and the target calculation data of the actual migration amount is migrated to the data receiving server for processing.
[0078] Exemplarily, according to the actual migration amount, target computing data with lower data relevance, data access frequency and data update frequency can be obtained on the data sending server, and the target computing data of the actual migration amount can be migrated to the data receiving server for processing.
[0079] The advantage of this setting is that by obtaining the target calculation data of the actual migration amount on the data sending server through the data correlation, data access frequency and data update frequency of each calculation data, the target calculation data with low data correlation, data access frequency and data update frequency can be migrated to the data receiving server for processing, thereby effectively improving the computing efficiency of the data sending server.
[0080] S260: Obtain candidate servers other than the data sending server and the data receiving server, and a server number of each candidate server.
[0081] S270: Use a random number generator to generate a random integer based on each server number, and use the candidate server whose server number is the same as the random integer as the target server.
[0082] In this embodiment, the random integer may be the same as the server number of any candidate server.
[0083] Exemplarily, assuming that the server numbers of the candidate servers are 0, 1, and 3 respectively, a random integer 0, 1, or 3 may be generated. If the random integer is 1, the candidate server with the server number 1 may be used as the target server.
[0084] S280. After migrating the calculated data of the migration amount threshold to the target server, return to execute S210 until the load balancing condition is met.
[0085] In this step, specifically, the calculation data of the migration threshold can be obtained in the data sending server, and the calculation data of the migration threshold can be migrated to the target server. Then, the operation of weighted summing of the CPU utilization, memory utilization and number of accesses of each server can be returned to be performed until any load balancing condition is met. There can be multiple load balancing conditions, such as the load pressure difference between each server is less than the set pressure difference threshold, or the data migration amount migrated from the data sending server to the data receiving server is less than or equal to the set migration threshold.
[0086] S290. Obtain calculation data of the data migration amount on the data sending server, and migrate the calculation data of the data migration amount to the data receiving server for processing.
[0087] In this step, specifically, according to the data relevance, data access frequency and data update frequency of each calculation data on the data sending server, the calculation data of the data migration amount can be obtained on the data sending server, and the calculation data of the data migration amount can be migrated to the data receiving server for processing.
[0088] The advantage of this setting is that by migrating the calculation data of the data migration amount to the data receiving server and other servers for processing when the data migration amount is greater than the set migration amount threshold, it can avoid distributing too much calculation data to the data receiving server, causing new load balancing problems, ensuring that the load between servers is relatively uniform and improving the processing efficiency of calculation data.
[0089] Optionally, the method further includes: collecting the load pressure, load pressure difference and data flow resistance corresponding to each server at a set frequency, and generating a load pressure graph corresponding to each server according to the load pressure, load pressure difference and data flow resistance corresponding to each server; displaying the load pressure graph corresponding to each server, so that the user can determine the data sending server, the data receiving server, and the amount of data migration from the data sending server to the data receiving server according to the load pressure, load pressure difference and data flow resistance on the load pressure graph. The load pressure graph can be a line graph or a histogram with time as the horizontal axis.
[0090] The advantage of this setting is that by generating a load pressure graph corresponding to each server and displaying the load pressure graph corresponding to each server, it is convenient for users to intuitively obtain the load pressure difference and data flow resistance between servers, thereby improving the efficiency of determining the data sending server, data receiving server and data migration amount, and thus improving the efficiency of load balancing scheduling between servers.
[0091] Optionally, when a server is detected to be down, each server to be selected that is not down and the server number of each server to be selected can be obtained, and a first random integer can be generated based on the server number of each server to be selected using a random number generator. Then, a server to be selected whose server number is the same as the first random integer can be used as a data receiving server, and a downtime calculation data can be selected from the downtime server and migrated to the data receiving server for processing. Afterwards, when it is detected that there is still downtime calculation data on the downtime server, a second random integer different from the first random integer can be generated based on the server number of each server to be selected using a random number generator. Finally, the second random integer can be used as the first random integer, and the operation of using the server to be selected whose server number is the same as the first random integer as the data receiving server can be returned to be executed until no downtime calculation data is detected on the downtime server.
[0092] For example, Figure 3 As shown, there are neural network models with model numbers 1, 2, 3, 4, 5 and 6, and the calculation data of the neural network models with model numbers 3 and 6 have been allocated to the server with server number 0 for execution through the modulo hash algorithm, the calculation data of the neural network models with model numbers 1 and 4 have been allocated to the server with server number 1 for execution, and the calculation data of the neural network models with model numbers 2 and 5 have been allocated to the server with server number 2 for execution. Then, when it is detected that the server with model number 2 is down, a first random integer 0 or 1 can be generated using a random number generator. If the first random integer is 0, the calculation data in a downtime on the downtime server can be allocated to the server with server number 0 for processing. Since there is still calculation data in the downtime on the downtime server, a second random integer different from the first random integer can be generated using a random number generator, and the second random integer can only be 1. At this time, the calculation data in the last downtime on the downtime server can be allocated to the server with server number 1 for processing.
[0093] Optionally, when a new server is detected, each candidate server and the server number of each candidate server can be obtained, and a random number generator can randomly generate a third random integer based on the server number of each candidate server. Then, the candidate server with the same server number as the third random integer can be used as a data sending server, and a calculation data can be selected on the data sending server to be migrated to the new server for processing. After that, when it is detected that the load of the new server is too low, a random number generator can be used to generate a fourth random integer different from the third random integer based on the server number of each candidate server. Finally, the fourth random integer can be used as the third random integer, and the operation of executing the candidate server with the same server number as the third random integer as the data sending server is returned until the load between the servers is balanced.
[0094] The advantage of such a setting is that, compared with the existing technology of realizing server load balancing through modulo hashing algorithm, consistent hashing algorithm or consistent hashing algorithm with virtual nodes, the technical solution of this embodiment determines the data sending server and the data receiving server by generating random integers, avoiding the need to recalculate the location of each calculation data when the number of servers changes, thereby causing calculation interruption and additional time overhead, while realizing load balancing of each server, the processing efficiency of the calculation data is improved. Secondly, by generating a second random integer different from the first random integer and a fourth random integer different from the third random integer, it is avoided to distribute too much calculation data to the same server and to migrate too much calculation data from the same server, thereby realizing server load balancing.
[0095] The technical solution of this embodiment obtains the load pressure of the server by weighted summing up the CPU utilization, memory utilization and number of accesses of the server, which fully considers the influence of the importance of CPU utilization, memory utilization and number of accesses on the calculation of load pressure, and improves the accuracy of the calculated load pressure. Secondly, the data flow resistance from the data sending server to the data receiving server is obtained by weighted summing up the network bandwidth limit value and the data size limit value, which considers the influence of the importance of the network bandwidth limit value and the data size limit value on the data flow resistance, and improves the accuracy of the calculated data flow resistance. Finally, when the data migration amount is greater than the set migration amount threshold, the calculated data of the data migration amount is migrated to the data receiving server and other servers for processing, which can avoid the situation where too much calculated data is distributed to the data receiving server, resulting in new load balancing problems, ensuring that the load between the servers is relatively uniform, and improving the processing efficiency of the calculated data.
[0096] Embodiment 3
[0097] Figure 4 It is a structural diagram of a load balancing device provided according to Embodiment 3 of the present invention. This embodiment can be applied to the situation of load balancing of various servers. The load balancing device can be implemented in the form of hardware and / or software and can be configured in an electronic device such as a computer.
[0098] like Figure 4 As shown, the load balancing device disclosed in this embodiment includes: a load pressure difference determination module 41, a data flow resistance determination module 42, a data migration amount determination module 43 and a data migration module 44, wherein:
[0099] The load pressure difference determination module 41 is used to determine the load pressure of each server according to the CPU utilization, memory utilization and access quantity of each server, and calculate the load pressure difference between the servers;
[0100] The data flow resistance determination module 42 is used to obtain a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determine the data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server;
[0101] A data migration amount determination module 43, used to determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server;
[0102] The data migration module 44 is used to migrate the calculated data on the data sending server to the data receiving server for processing according to the data migration amount.
[0103] The technical solution in this embodiment, through the mutual cooperation of the load pressure difference determination module, the data flow resistance determination module, the data migration amount determination module and the data migration module, solves the problem that the prior art can only determine the calculation data distribution rules but cannot timely detect servers with unbalanced loads, resulting in low server computing efficiency. It can timely detect and process servers with unbalanced loads, realize full utilization of computing resources, and improve the computing efficiency of the server.
[0104] Optionally, the load pressure difference determination module 41 is specifically used to perform weighted summation on the CPU utilization, memory utilization and access quantity of each server to obtain the load pressure of each server.
[0105] Optionally, the data flow resistance determination module 42 is specifically configured to perform weighted summation on the network bandwidth limit value and the data size limit value to obtain the data flow resistance from the data sending server to the data receiving server.
[0106] Optionally, the data migration amount determination module 43 is specifically used to determine the data migration amount from the data sending server to the data receiving server according to the division result of the load pressure difference and the data flow resistance.
[0107] Optionally, the data migration module 44 is specifically used to: determine whether the data migration amount is greater than a set migration amount threshold; if so, calculate the subtraction result of the data migration amount and the migration amount threshold to obtain the actual migration amount, and migrate the calculated data on the data sending server to the data receiving server for processing according to the actual migration amount; obtain candidate servers other than the data sending server and the data receiving server, and the server number of each candidate server; use a random number generator to generate a random integer based on each server number, and use the candidate server with the same server number as the random integer as the target server; after migrating the calculated data of the migration amount threshold to the target server, return to execute the operation of determining the load pressure of each server based on the CPU utilization, memory utilization and number of visits of each server until the load balancing condition is met; if not, obtain the calculated data of the data migration amount on the data sending server, and migrate the calculated data of the data migration amount to the data receiving server for processing.
[0108] Optionally, when the data migration module 44 migrates the calculation data on the data sending server to the data receiving server for processing according to the actual migration amount, it is specifically used to: obtain the target calculation data of the actual migration amount on the data sending server according to the data correlation, data access frequency and data update frequency of each calculation data on the data sending server; and migrate the target calculation data of the actual migration amount to the data receiving server for processing.
[0109] Optionally, the device also includes a load pressure map generating module, which is used to: collect the load pressure, load pressure difference and data flow resistance corresponding to each server at a set frequency, and generate a load pressure map corresponding to each server according to the load pressure, load pressure difference and data flow resistance corresponding to each server; display the load pressure map corresponding to each server so that the user can determine the data sending server, the data receiving server, and the amount of data migration from the data sending server to the data receiving server according to the load pressure, load pressure difference and data flow resistance on the load pressure map.
[0110] The load balancing device provided in the embodiment of the present invention can execute the load balancing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For the contents not described in detail in this embodiment, reference can be made to the description in any method embodiment of the present application.
[0111] Embodiment 4
[0112] Figure 5 FIG. 1 is a schematic diagram showing the structure of an electronic device 10 that can be used to implement an embodiment of the present invention. Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0113] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0114] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a load balancing method.
[0115] In some embodiments, the load balancing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the load balancing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the load balancing method in any other appropriate manner (e.g., by means of firmware).
[0116] Various implementations 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 chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0117] Computer programs for implementing the methods of the present invention 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0118] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0119] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0120] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0121] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0122] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0123] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A load balancing method, characterized in that: The method comprises: Determine the load pressure of each server based on the CPU utilization, memory utilization and number of accesses of each server, and calculate the load pressure difference between servers; Obtaining a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determining a data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server; Determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server; According to the amount of data migration, the calculated data on the data sending server is migrated to the data receiving server for processing.
2. The method according to claim 1, characterized in that Determine the load pressure of each server based on the CPU utilization, memory utilization, and number of accesses of each server, including: The CPU utilization, memory utilization, and number of accesses of each server are weighted and summed to obtain the load pressure of each server. According to the network bandwidth limit value and data size limit value between the data sending server and the data receiving server, the data flow resistance from the data sending server to the data receiving server is determined, including: The network bandwidth limit value and the data size limit value are weightedly summed to obtain the data flow resistance from the data sending server to the data receiving server.
3. The method according to claim 1, characterized in that Determining the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server, including: The amount of data migration from the data sending server to the data receiving server is determined based on the result of dividing the load pressure difference by the data flow resistance.
4. The method according to claim 1, characterized in that: According to the amount of data migration, the calculated data on the data sending server is migrated to the data receiving server for processing, including: Determine whether the data migration amount is greater than a set migration amount threshold; If so, the actual migration amount is obtained by subtracting the data migration amount from the migration amount threshold, and the calculated data on the data sending server is migrated to the data receiving server for processing according to the actual migration amount; Obtain candidate servers other than the data sending server and the data receiving server, and the server number of each candidate server; Use a random number generator to generate a random integer based on each server number, and use the candidate server with the same server number as the random integer as the target server; After the calculated data of the migration threshold is migrated to the target server, the operation of determining the load pressure of each server according to the CPU utilization, memory utilization and access quantity of each server is returned until the load balancing condition is met; If not, the calculation data of the data migration amount is obtained on the data sending server, and the calculation data of the data migration amount is migrated to the data receiving server for processing.
5. The method according to claim 4, characterized in that Migrate the calculated data on the data sending server to the data receiving server for processing according to the actual migration amount, including: According to the data relevance, data access frequency and data update frequency of each calculation data on the data sending server, the target calculation data of the actual migration amount is obtained on the data sending server; The target calculation data of the actual migration amount is migrated to the data receiving server for processing.
6. The method according to claim 1, characterized in that The method further comprises: Collect the load pressure, load pressure difference and data flow resistance corresponding to each server at a set frequency, and generate a load pressure graph corresponding to each server according to the load pressure, load pressure difference and data flow resistance corresponding to each server; The load pressure graph corresponding to each server is displayed so that the user can determine the data sending server, the data receiving server, and the amount of data migration from the data sending server to the data receiving server based on the load pressure, load pressure difference and data flow resistance on the load pressure graph.
7. A load balancing device, characterized in that: The device comprises: A load pressure difference determination module is used to determine the load pressure of each server according to the CPU utilization, memory utilization and access quantity of each server, and calculate the load pressure difference between the servers; A data flow resistance determination module is used to obtain a data sending server and a data receiving server whose load pressure difference is greater than or equal to a set pressure difference threshold, and determine the data flow resistance from the data sending server to the data receiving server according to a network bandwidth limit value and a data size limit value between the data sending server and the data receiving server; A data migration amount determination module, used to determine the amount of data migration from the data sending server to the data receiving server according to the load pressure difference and data flow resistance corresponding to the data sending server and the data receiving server; The data migration module is used to migrate the calculated data on the data sending server to the data receiving server for processing according to the data migration amount.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the load balancing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the load balancing method according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the load balancing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Distributed type dynamic cache expanding method and system supporting load balancing
CN102244685A
Load balancing method and device of server, electronic equipment and storage medium
CN115604269A
Task scheduling method and device, electronic equipment and storage medium
CN117215773A
Migration of virtual machines
US20170315838A1