Dynamic load balancing method and device for cloud platform
By introducing load factor and load table matching technology into the load balancer of the cloud platform, dynamically adjusting the execution server for forwarding of business requests, solving the situation in the existing technology that cannot effectively reflect the server load, achieving better load balancing effects and reducing the risk of server crashes.
Patent Information
- Application Number
- CN202411582525.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-03-11
AI Technical Summary
The existing load balancing technology cannot effectively reflect the load status of the server, resulting in the inability to achieve excellent load balancing effects.
By introducing load factors into the load balancer of the cloud platform, obtaining the resource requirements of business requests, and matching it with the load table of the resource monitoring end of the cloud platform, dynamically adjusting the execution server for forwarding of business requests.
It achieves better balanced effects on resource utilization rates such as CPU, memory, IO, etc., reducing the risk of failure and crash caused by performance bottlenecks of high-load servers.
Smart Images

Figure CN119603308A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of load balancing, and specifically to a dynamic load balancing method for a cloud platform, a dynamic load balancing device for a cloud platform, a computer-readable storage medium, and a computer program product. Background Art
[0002] With the rapid development of the Internet and computer technology, the number of applications deployed on public cloud platforms (hereinafter referred to as cloud platforms) is increasing. The scale of cloud platforms is also getting larger and larger, and the number of servers managed by system operation and maintenance is growing. For the purpose of high availability, servers will be deployed in clusters, and a business request will be distributed to a server in the cluster for processing according to certain rules. Compared with single-machine deployment, cluster mode can distribute the original large number of business requests to multiple servers for processing, reducing the load pressure on each server and reducing the risk of production accidents and crashes caused by resource bottlenecks.
[0003] As the business of the system becomes increasingly complex, the types of resources occupied by various business requests are different. For example, there are "computation-intensive requests" that occupy more CPU time for calculation; "data-intensive requests" that occupy more memory resources for storing data; "IO-intensive requests" that occupy more IO resources to access files. And the time and quantity of resources occupied by requests of the same type are also different. For example, request A occupies 10% of the memory, while request B only needs 2% of the memory; request C occupies 80% of the CPU time, but request D only needs 10% of the CPU time. At present, load balancing devices also provide a minimum number of connections strategy, that is, forwarding requests to the server with the smallest number of business connections. However, as mentioned above, a small number of business connections does not mean that the load pressure caused is small, and it cannot reflect the load situation of the server, so it is impossible to achieve an excellent load balancing effect. Summary of the invention
[0004] The purpose of the implementation mode of the present application is to provide a dynamic load balancing method and device for a cloud platform, set the load type of the request, obtain the load status of the server, and combine the two as a load factor to dynamically adjust the execution server for forwarding business requests, so as to at least solve some of the technical problems in the background technology.
[0005] In order to achieve the above-mentioned object, the first aspect of the present application provides a dynamic load balancing method of a cloud platform, which is applied to a load balancer, wherein the load balancer determines a candidate server for processing the service request based on the service request, and the method comprises:
[0006] Acquire a business request, generate a candidate server, and determine whether the business request includes a load factor; if the load factor is included, parse the load factor to obtain the resource requirement for processing the business request, wherein the resource requirement includes multiple sub-resources; send the resource requirement to a resource monitoring terminal in the cloud platform, trigger the resource monitoring terminal to match the resource requirement with a load table maintained by the resource monitoring terminal to obtain a matching result, receive the matching result returned by the resource monitoring terminal, wherein the matching result includes several servers; determine an execution server based on the candidate server and the matching result, and send the business request including the load factor to the execution server.
[0007] Optionally, a business request including a load factor is generated through the following steps: determining multiple sub-resources required to process the business request from historical data or a standard template for processing the business request; determining the load factor based on the combination type of the multiple sub-resources; and writing the load factor into a preset field of the business request to obtain a business request including a load factor.
[0008] Optionally, the load table records the sub-resource load status of each server in the server cluster within the cloud platform; the resource demand is matched with the load table maintained by it to obtain a matching result, including: selecting several servers with the smallest load of each sub-resource from the load table, respectively forming sub-item sets of different sub-resources; if the sub-item sets have an intersection, the intersection is used as the matching result; if the sub-item sets do not have an intersection, the union of the sub-item sets is calculated, and the sub-item ranking of each sub-resource of each server in the union in the load table is obtained, and the resource load ranking of the servers in the union is obtained by combining the sub-item rankings, and several servers are selected as matching results based on the resource load ranking.
[0009] Optionally, determining the execution server based on the candidate server and the matching result includes: obtaining the generation time of the candidate server; if the matching result is not received within a first preset time after the generation time, using the candidate server as the execution server; if the matching result is received within the first preset time after the generation time, determining the execution server based on the inclusion relationship between the candidate server and the matching result.
[0010] Optionally, the matching result also includes the latest update time of the load table used for matching; if the matching result is received within a first preset time after the generation time, determine whether the difference between the generation time and the latest update time is greater than a second preset time; if the difference between the generation time and the latest update time is greater than the second preset time, use the candidate server as the execution server; if the difference between the generation time and the latest update time is not greater than the second preset time, determine the execution server based on the inclusion relationship between the candidate server and the matching result.
[0011] Optionally, determining the execution server based on the inclusion relationship between the candidate server and the matching result includes: judging whether the candidate server is in the matching result; if the candidate server is in the matching result, using the candidate server as the execution server; if the candidate server is not in the matching result, assigning a preset value to the candidate server, assigning values to the servers in the matching result respectively according to the reception time of the matching result in the load balancer and the position of the server in the matching result, and selecting the server with the largest assigned value as the execution server.
[0012] Optionally, the servers in the matching result are assigned values respectively according to the reception time of the matching result on the load balancer and the position of the server in the matching result, including: calculating the difference between the reception time and the generation time, and obtaining a time assignment by negative correlation mapping the difference; obtaining the position order of the servers in the matching result, and obtaining a position assignment according to the position order; and using the product of the time assignment and the position assignment as the assignment of the server in the matching result.
[0013] The present application also provides a dynamic load balancing device for a cloud platform, including an initial allocation module, which is used to determine a candidate server for processing a business request based on the business request, and the device also includes: a factor judgment module, which is used to obtain a business request and determine whether the business request includes a load factor; a demand determination module, which is used to parse the load factor to obtain the resource requirement for processing the business request when the load factor is included, and the resource requirement includes multiple sub-resources; a result generation module, which is used to send the resource requirement to a resource monitoring end in the cloud platform, trigger the resource monitoring end to match the resource requirement with the load table it maintains to obtain a matching result, and receive the matching result returned by the resource monitoring end, and the matching result includes several servers; and a request forwarding module, which is used to determine the execution server based on the candidate server and the matching result, and send the business request including the load factor to the execution server.
[0014] Optionally, a business request including a load factor is generated through the following steps: determining multiple sub-resources required to process the business request from historical data or a standard template for processing the business request; determining the load factor based on the combination type of the multiple sub-resources; and writing the load factor into a preset field of the business request to obtain a business request including a load factor.
[0015] Optionally, the load table records the sub-resource load status of each server in the server cluster within the cloud platform; the resource demand is matched with the load table maintained by it to obtain a matching result, including: selecting several servers with the smallest load of each sub-resource from the load table, respectively forming sub-item sets of different sub-resources; if the sub-item sets have an intersection, the intersection is used as the matching result; if the sub-item sets do not have an intersection, the union of the sub-item sets is calculated, and the sub-item ranking of each sub-resource of each server in the union in the load table is obtained, and the resource load ranking of the servers in the union is obtained by combining the sub-item rankings, and several servers are selected as matching results based on the resource load ranking.
[0016] Optionally, determining the execution server based on the candidate server and the matching result includes: obtaining the generation time of the candidate server; if the matching result is not received within a first preset time after the generation time, using the candidate server as the execution server; if the matching result is received within the first preset time after the generation time, determining the execution server based on the inclusion relationship between the candidate server and the matching result.
[0017] Optionally, the matching result also includes the latest update time of the load table used for matching; if the matching result is received within a first preset time after the generation time, determine whether the difference between the generation time and the latest update time is greater than a second preset time; if the difference between the generation time and the latest update time is greater than the second preset time, use the candidate server as the execution server; if the difference between the generation time and the latest update time is not greater than the second preset time, determine the execution server based on the inclusion relationship between the candidate server and the matching result.
[0018] Optionally, determining the execution server based on the inclusion relationship between the candidate server and the matching result includes: judging whether the candidate server is in the matching result; if the candidate server is in the matching result, using the candidate server as the execution server; if the candidate server is not in the matching result, assigning a preset value to the candidate server, assigning values to the servers in the matching result respectively according to the reception time of the matching result in the load balancer and the position of the server in the matching result, and selecting the server with the largest assigned value as the execution server.
[0019] Optionally, the servers in the matching result are assigned values respectively according to the reception time of the matching result on the load balancer and the position of the server in the matching result, including: calculating the difference between the reception time and the generation time, and obtaining a time assignment by negative correlation mapping the difference; obtaining the position order of the servers in the matching result, and obtaining a position assignment according to the position order; and using the product of the time assignment and the position assignment as the assignment of the server in the matching result.
[0020] In the third aspect of the present application, an electronic device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the aforementioned dynamic load balancing method of the cloud platform when executing the computer program.
[0021] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein instructions are stored in the storage medium, and when the instructions are executed on a computer, the computer executes the steps of the aforementioned dynamic load balancing method for the cloud platform.
[0022] In a fifth aspect of the present application, a computer program product is provided, comprising a computer program, which implements the aforementioned dynamic load balancing method for the cloud platform when executed by a processor.
[0023] The above technical solution has at least the following beneficial effects:
[0024] By introducing each server in the server cluster into the original CLB strategy, the utilization rate of CPU, memory, IO and other resources is improved, so that the CLB allocation strategy maintains a better balance effect, reducing the risk of failure and crash of the original high-load server due to performance bottlenecks.
[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0027] Figure 1 A schematic diagram schematically shows a dynamic load balancing method in the prior art;
[0028] Figure 2 The following is a schematic diagram showing the steps of a dynamic load balancing method for a cloud platform according to an embodiment of the present application;
[0029] Figure 3 The following schematically shows an application architecture diagram of a dynamic load balancing method for a cloud platform according to an embodiment of the present application;
[0030] Figure 4 A schematic diagram of an application environment of a dynamic load balancing method of a cloud platform according to an embodiment of the present application is schematically shown;
[0031] Figure 5 The structure diagram of the dynamic load balancing device of the cloud platform according to the implementation mode of the present application is schematically shown;
[0032] Figure 6 The internal structure of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the implementation methods of the present application clearer, the technical solutions in the implementation methods of the present application will be clearly and completely described below in conjunction with the drawings in the implementation methods of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the implementation methods of the present application, and are not used to limit the implementation methods of the present application. Based on the implementation methods in the present application, all other implementation methods obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0034] It should be noted that if the implementation methods of the present application involve directional indications (such as up, down, left, right, front, back...), such directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0035] In addition, if there are descriptions involving "first", "second", etc. in the implementation methods of this application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various implementation methods can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0036] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0037] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0038] The current cloud platform request forwarding is completed by the load balancing device (Cloud Load Balance, CLB), and almost all forwarding rules are "polling" mechanisms. For example, there are three servers in the cluster, server A, server B, and server C. Business requests are forwarded to A, B, C, A, B, C, ... in turn for processing. Based on the above analysis, the following load imbalance situations will occur. Figure 1 The following schematic diagram shows a dynamic load balancing method in the prior art. Figure 1 As shown in the figure, there are 3 business requests in total. The first one is forwarded to server A, which takes 3 seconds. The second one is forwarded to server B, which takes 1 second. The third one will be forwarded to server A according to the "polling" mechanism, which takes 5 seconds. The difference between server A and server B can reach 7 seconds, but if the third request can be forwarded to server B, the difference between the two is only 3 seconds. It can be seen that the polling mechanism can only meet the "quantity balance" of business requests, but cannot provide optimal load balancing, because this mechanism does not take into account the differences in resource types and resource quantities occupied by each business request.
[0039] Figure 2 The following is a schematic diagram showing the steps of a dynamic load balancing method for a cloud platform according to an embodiment of the present application. Figure 2 As shown, a dynamic load balancing method for a cloud platform is applied to a load balancer (Cloud LoadBalance, CLB), which is a device that distributes network traffic, requests or workloads to multiple servers or computing resources. The current load balancer determines the candidate server for processing the service request based on the service request. This method combines the existing load balancing strategy instead of selecting based only on server load. The method includes:
[0040] S01. Obtain a service request, generate a candidate server, and determine whether the service request includes a load factor. The load factor here is carried in the service request through service transformation and can be recorded as load_type.
[0041] S02. When a load factor is included, the load factor is parsed to obtain the resource requirements for processing the business request, and the resource requirements include multiple sub-resources; the load factor indicates that this business request will consume multiple sub-resources such as CPU, memory, IO, etc., and these required sub-resources are collectively referred to as resource requirements. When a load factor is not included, the load balancer processes this business request as a normal business request and no longer executes subsequent steps. The normal business requests here include business requests with strong real-time requirements, low resource consumption, or special requirements. This setting avoids the need for interaction with the resource monitoring end for all business requests, improves the processing speed, and reduces the processing consumption of the load balancer.
[0042] S03. Send the resource demand to the resource monitoring end in the cloud platform, trigger the resource monitoring end to match the resource demand with the load table it maintains to obtain a matching result, and receive the matching result returned by the resource monitoring end, where the matching result includes several servers; based on the cloud platform's own monitoring and collection of various monitoring data, the resource monitoring end in the cloud platform maintains a load table, which records in detail the load conditions of the CPU, memory, IO and other sub-resources of each server in the cluster, and the load conditions here include load data or load ranking.
[0043] S04: Determine an execution server according to the candidate server and the matching result, and send the service request including the load factor to the execution server. The CLB forwards the service request to the execution server according to the policy result.
[0044] Through the above implementation, by setting the load factor and comprehensively considering the load status of the server, the service request forwarding destination is dynamically adjusted based on the load status and the existing strategy. This implementation enables each server in the cluster to maintain a better balance in the utilization of resources such as CPU, memory, and IO, and reduces the risk of high-load server crashes due to performance bottlenecks.
[0045] Figure 3 The following schematically shows an application architecture diagram of a dynamic load balancing method for a cloud platform according to an embodiment of the present application. Figure 3 As shown in the figure, the cloud platform includes CLB, server cluster, and resource monitoring terminal. CLB is used to allocate business requests to specific servers in the server cluster. The server cluster includes multiple servers such as server A and server B for processing business requests. The resource monitoring terminal comes from the cloud platform's own monitoring. The cloud platform maintains a load table on the resource monitoring terminal through its own monitoring mechanism, which records in detail the load ranking of CPU, memory, IO and other resources of each server in the server cluster.
[0046] Figure 4The following schematically shows an application environment diagram of a dynamic load balancing method of a cloud platform according to an embodiment of the present application. Figure 4 As shown, the dynamic load balancing method of the cloud platform provided by this application can be applied to Figure 4 In the application environment shown. Among them, the terminal 102 communicates with the cloud platform 104 through the network. Among them, the terminal 102 is used to generate business requests, and can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The cloud platform 104 is composed of multiple servers, including the aforementioned CLB. The CLB in the cloud platform performs the actions of the aforementioned steps S01 to S04, allocates and processes business requests, and sends the processing results to the terminal 102, thereby realizing load balancing of the cloud platform 104 when processing business requests.
[0047] In some embodiments of the present application, a business request including a load factor is generated by the following steps: determining multiple sub-resources required for processing the business request from historical data or a standard template for processing the business request; determining a load factor according to the combination type of the multiple sub-resources; writing the load factor into a preset field of the business request to obtain a business request including a load factor. The load factor in the present application is realized by business transformation, and the load factor load_type is carried in the business request, marking that this business request is about to consume sub-resources such as CPU, memory, and IO. When a business request is received, it is possible to determine which sub-resources it needs based on the historical data of the processing process of similar business requests, and it is also possible to determine which sub-resources it needs by comparing the business request with the standard template for processing the request. The load factor is determined according to the combination type of the multiple sub-resources. For example, if only CPU and memory are required to process the business request, the load factor is set to 1; if only CPU and IO are required to process the business request, the load factor is set to 2; if CPU, memory, and IO are required to process the business request, the load factor is set to 3; if GPU and IO are required to process the business request, the load factor is set to 4, and so on. In short, the setting is subject to the ability of CLB to resolve, and the specific setting can be adjusted by yourself. The service request is written into the preset field of the service request to achieve transmission along with the service request. The CLB obtains whether the service request carries a load factor and the sub-resource represented by the load factor by analyzing the presence or absence of the preset field or whether it is a specific value.
[0048] In some embodiments of the present application, the load table records the sub-resource load status of each server in the server cluster in the cloud platform; the matching operation of the resource demand with the load table maintained by it obtains the matching result, including: selecting several servers with the smallest load of each sub-resource from the load table, respectively forming sub-item sets of different sub-resources; if the sub-item sets have an intersection, the intersection is used as the matching result; if the sub-item sets do not have an intersection, the union of the sub-item sets is calculated, and the sub-item ranking of each sub-resource of each server in the union in the load table is obtained, and the resource load ranking of the server in the union is obtained by combining the sub-item rankings, and several servers are selected as matching results based on the resource load ranking. This embodiment provides a method for generating matching results, which selects the server with the lowest comprehensive ranking based on the ranking of each sub-resource in the load table. Taking the sub-resources including CPU, memory, and IO as an example, the following is explained: respectively obtain N servers with the smallest CPU, memory, and IO loads, and obtain 3 sub-item sets, each of which corresponds to CPU, memory, and IO, and the number of servers in each sub-item set is N. If there is an intersection among the three sub-item sets, it means that there is at least one server that can satisfy the current low load of each sub-resource and can better meet the resource demand. However, in most cases, the above ideal situation does not exist, so the resource load ranking of a total of 3N servers in the three sub-item sets is calculated, for example, multiple servers with the smallest load corresponding to the resource load ranking are selected as matching results for feedback. Among them, there are many ways to calculate the resource load ranking based on the sub-item ranking, such as directly accumulating the comprehensive value for ranking. It is also possible to set corresponding weights for the sub-resource ranking according to the importance of each sub-resource, and to perform resource load ranking by weighted sum.
[0049] Since the information interaction with the resource monitoring end is introduced in this application, it will cause certain communication delays and processing delays. If the CLB delays or does not receive the information fed back by the resource monitoring end, it will seriously affect the allocation of service requests. In order to avoid the above situation, avoid the impact of the communication status on the service allocation, and improve the user experience, it is necessary to set a corresponding processing mechanism. In some embodiments of the present application, the execution server is determined according to the candidate server and the matching result, including: obtaining the generation time of the candidate server; if the matching result is not received within the first preset time after the generation time, the candidate server is used as the execution server; if the matching result is received within the first preset time after the generation time, the execution server is determined according to the inclusion relationship between the candidate server and the matching result. For example, the first preset time is set to 10ms. If the matching result is not received within 10ms after the candidate server is generated, it will no longer wait, and the candidate server is used as the execution server to send the service request to ensure the timely allocation and processing of the service request.
[0050] In some embodiments of the present application, the matching result also includes the latest update time of the load table used for matching; if the matching result is received within the first preset time after the generation time, it is determined whether the difference between the generation time and the latest update time is greater than the second preset time, if the difference between the generation time and the latest update time is greater than the second preset time, the selected server is used as the execution server; if the difference between the generation time and the latest update time is not greater than the second preset time, the execution server is determined according to the inclusion relationship between the selected server and the matching result. Since the resource monitoring end updates the load table periodically, if the load table is not updated for a long time, the load status recorded by it is no longer referenceable. Therefore, in order to ensure that the load table accurately reflects the current load status of the servers in the cluster, it is necessary to ensure that the latest update time of the load table is within a certain range. The latest update time can be returned with the return of the matching result, or it can be returned by the matching result.
[0051] In some embodiments of the present application, the execution server is determined according to the inclusion relationship between the candidate server and the matching result, including: judging whether the candidate server is in the matching result; if the candidate server is in the matching result, using the candidate server as the execution server; if the candidate server is not in the matching result, assigning a preset value to the candidate server, assigning values to the servers in the matching result according to the receiving time of the matching result in the load balancer and the position of the server in the matching result, and selecting the server with the largest assigned value as the execution server. This embodiment provides a fusion strategy on the CLB side. If the candidate server is in the matching result, it means that the candidate server not only meets the existing allocation strategy of the CLB, but also meets the minimum load constraint based on the load table, so the service request can be sent to the candidate server as the execution server. However, in most cases, the candidate server is not in the matching result, and a certain strategy is required for selection. The strategy in this embodiment is selected based on the two factors of receiving time and position in the matching result.
[0052] In some embodiments of the present application, the servers in the matching result are assigned values according to the receiving time of the matching result in the load balancer and the position of the server in the matching result, including: calculating the difference between the receiving time and the generating time, and obtaining the time assignment by negative correlation mapping the difference; obtaining the position order of the server in the matching result, and obtaining the position assignment according to the position order; and taking the product of the time assignment and the position assignment as the assignment of the server in the matching result. If the receiving time of the matching result is later, it means that the timeliness of the matching result is lower, so the time assignment should be lower, so negative correlation mapping is used to obtain the time assignment based on the difference. If the position of the server in the matching result is closer to the front, it means that its resource load ranking is lower, and its position assignment should be higher. The product of the maximum time assignment value and the maximum position assignment value should be greater than the preset value of the server to be selected to ensure that the server to be selected will not be required. For example, when the candidate server is assigned a value of 1, the time of the server in the matching result is assigned a value of 1.1, and the position is assigned values of 1.1, 1.0, 0.9, and 0.8 respectively, the values of the servers in the matching result are 1.21, 1.1, 0.99, and 0.88, and the first server in the matching result is selected as the execution server. If the matching result is received later, the time of the server in the matching result is assigned a value of 0.9, and the candidate server should be selected as the execution server. Although the probability of the server ranked later in the matching result being selected is small, it will determine the overall ranking of the candidate servers. When the determined execution server cannot process the business request for various reasons, the server ranked later will be selected as the execution server in sequence.
[0053] Through the above implementation methods, a better balance effect is maintained in the utilization of sub-resources such as CPU, memory, and IO, reducing the risk of failure and crash of high-load servers due to performance bottlenecks. At the same time, the impact on the original CLB is reduced, and the robustness of the original cloud platform is maintained when the sub-resource utilization cannot be obtained.
[0054] Based on the same inventive concept, the present application also provides a dynamic load balancing device for a cloud platform. Figure 5 The following schematically shows a schematic diagram of the structure of a dynamic load balancing device of a cloud platform according to an embodiment of the present application. Figure 5As shown, a dynamic load balancing device for a cloud platform includes an initial allocation module, which is used to determine a candidate server for processing a business request based on the business request, and the device also includes: a factor judgment module, which is used to obtain a business request and determine whether the business request includes a load factor; a demand determination module, which is used to parse the load factor to obtain a resource requirement for processing the business request when the load factor is included, and the resource requirement includes multiple sub-resources; a result generation module, which is used to send the resource requirement to a resource monitoring end in the cloud platform, trigger the resource monitoring end to match the resource requirement with the load table it maintains to obtain a matching result, and receive the matching result returned by the resource monitoring end, and the matching result includes several servers; and a request forwarding module, which is used to determine an execution server based on the candidate server and the matching result, and send the business request including the load factor to the execution server.
[0055] In some optional embodiments, a business request including a load factor is generated by the following steps: determining multiple sub-resources required to process the business request from historical data or a standard template for processing the business request; determining the load factor based on the combination type of the multiple sub-resources; and writing the load factor into a preset field of the business request to obtain a business request including a load factor.
[0056] In some optional implementations, the load table records the sub-resource load status of each server in the server cluster within the cloud platform; the resource demand is matched with the load table maintained by it to obtain a matching result, including: selecting several servers with the smallest load of each sub-resource from the load table, respectively forming sub-item sets of different sub-resources; if the sub-item sets have an intersection, the intersection is used as the matching result; if the sub-item sets do not have an intersection, the union of the sub-item sets is calculated, and the sub-item ranking of each sub-resource of each server in the union in the load table is obtained, and the resource load ranking of the servers in the union is obtained by combining the sub-item rankings, and several servers are selected as matching results based on the resource load ranking.
[0057] In some optional embodiments, determining the execution server based on the candidate server and the matching result includes: obtaining the generation time of the candidate server; if the matching result is not received within a first preset time after the generation time, using the candidate server as the execution server; if the matching result is received within a first preset time after the generation time, determining the execution server based on the inclusion relationship between the candidate server and the matching result.
[0058] In some optional embodiments, the matching result also includes the latest update time of the load table used for matching; if the matching result is received within a first preset time after the generation time, it is determined whether the difference between the generation time and the latest update time is greater than a second preset time; if the difference between the generation time and the latest update time is greater than the second preset time, the selected server is used as the execution server; if the difference between the generation time and the latest update time is not greater than the second preset time, the execution server is determined based on the inclusion relationship between the selected server and the matching result.
[0059] In some optional implementations, determining the execution server based on the inclusion relationship between the candidate server and the matching result includes: determining whether the candidate server is in the matching result; if the candidate server is in the matching result, using the candidate server as the execution server; if the candidate server is not in the matching result, assigning a preset value to the candidate server, assigning values to the servers in the matching result according to the reception time of the matching result in the load balancer and the position of the server in the matching result, and selecting the server with the largest assigned value as the execution server.
[0060] In some optional implementations, the servers in the matching results are assigned values according to the reception time of the matching results at the load balancer and the position of the servers in the matching results, including: calculating the difference between the reception time and the generation time, and obtaining a time assignment by negative correlation mapping the difference; obtaining the position order of the servers in the matching results, and obtaining a position assignment according to the position order; and using the product of the time assignment and the position assignment as the assignment of the server in the matching results.
[0061] The specific definition of each functional module in the dynamic load balancing device of the above-mentioned cloud platform can refer to the definition of the dynamic load balancing method of the cloud platform above, which will not be repeated here. Each module in the above-mentioned device or system can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules. The device acts on the dynamic load balancing of the cloud platform, and also has the advantages of maintaining a more balanced effect and reducing the risk of high-load server crashes.
[0062] An embodiment of the present application provides a storage medium on which a program is stored, and when the program is executed by a processor, the dynamic load balancing method of the above-mentioned cloud platform is implemented.
[0063] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 shown. Figure 6 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected by a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a dynamic load balancing method of a cloud platform is implemented.
[0064] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0065] In one embodiment, the dynamic load balancing device of the cloud platform provided by the present application can be implemented in the form of a computer program, which can be used in Figure 6 The computer device is run on the computer device shown. The memory of the computer device can store various program modules constituting the dynamic load balancing device of the cloud platform, and the computer program composed of each program module enables the processor to execute the steps of the dynamic load balancing method of the cloud platform of each embodiment of the present application described in this specification.
[0066] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0067] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0068] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0069] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0070] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0071] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0072] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0073] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0074] The above is only the implementation mode of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A dynamic load balancing method for a cloud platform, applied to a load balancer, wherein the load balancer determines a candidate server for processing a service request based on a service request, characterized in that: The method includes: Obtaining a service request, generating a candidate server, and determining whether the service request includes a load factor; In the case where a load factor is included, parsing the load factor to obtain a resource requirement for processing the service request, wherein the resource requirement includes a plurality of sub-resources; Sending the resource demand to a resource monitoring terminal in the cloud platform, triggering the resource monitoring terminal to match the resource demand with a load table maintained by the resource monitoring terminal to obtain a matching result, and receiving the matching result returned by the resource monitoring terminal, wherein the matching result includes a number of servers; An execution server is determined according to the candidate server and the matching result, and the service request including the load factor is sent to the execution server.
2. The method according to claim 1, characterized in that: A business request including a load factor is generated by the following steps: Determining a plurality of sub-resources required to process the business request from historical data or a standard template for processing the business request; Determining a load factor according to a combination type of the plurality of sub-resources; The load factor is written into a preset field of the service request to obtain a service request including the load factor.
3. The method according to claim 1, characterized in that The load table records the sub-resource load status of each server in the server cluster in the cloud platform; The resource demand is matched with the load table maintained by the resource demand to obtain a matching result, including: Selecting a number of servers with the smallest load for each sub-resource from the load table to form sub-item sets of different sub-resources respectively; If there is an intersection among the item sets, the intersection is used as a matching result; If there is no intersection among the sub-item sets, calculate the union of the sub-item sets, obtain the sub-item ranking of each sub-resource of each server in the union in the load table, obtain the resource load ranking of the servers in the union by combining the sub-item rankings, and select several servers as matching results based on the resource load rankings.
4. The method according to claim 1, characterized in that: Determining an execution server according to the candidate server and the matching result includes: Obtaining the generation time of the candidate server; If the matching result is not received within a first preset time period after the generation time, the server to be selected is used as the execution server; If the matching result is received within a first preset time period after the generation time, the execution server is determined according to the inclusion relationship between the candidate server and the matching result.
5. The method according to claim 4, characterized in that The matching result also includes the latest update time of the load table used for matching; If the matching result is received within a first preset time after the generation time, determining whether the difference between the generation time and the latest update time is greater than a second preset time; If the difference between the generation time and the latest update time is greater than a second preset time length, the server to be selected is used as the execution server; If the difference between the generation time and the latest update time is not greater than a second preset time length, the execution server is determined according to the inclusion relationship between the candidate server and the matching result.
6. The method according to claim 4 or 5, characterized in that: Determining the execution server according to the inclusion relationship between the candidate server and the matching result includes: Determine whether the server to be selected is in the matching result; If the server to be selected is in the matching result, the server to be selected is used as the execution server; If the server to be selected is not in the matching result, a preset value is assigned to the server to be selected, and values are assigned to the servers in the matching result according to the time when the matching result is received in the load balancer and the position of the server in the matching result, and the server with the largest assigned value is selected as the execution server.
7. The method according to claim 6, characterized in that Assigning values to the servers in the matching result respectively according to the time when the matching result is received by the load balancer and the position of the server in the matching result, including: Calculating the difference between the receiving time and the generating time, and obtaining a time value by performing negative correlation mapping on the difference; Obtaining the position order of the servers in the matching results, and assigning values according to the position order to obtain position values; The product of the time assignment and the location assignment is used as the assignment of the server in the matching result.
8. A dynamic load balancing device for a cloud platform, comprising an initial allocation module, for determining a candidate server for processing a service request based on a service request, characterized in that: The device also includes: A factor determination module, used to obtain a service request and determine whether the service request includes a load factor; A demand determination module, configured to, in the case of including a load factor, parse the load factor to obtain a resource requirement for processing the service request, wherein the resource requirement includes a plurality of sub-resources; A result generation module is used to send the resource demand to the resource monitoring end in the cloud platform, trigger the resource monitoring end to match the resource demand with the load table it maintains to obtain a matching result, and receive the matching result returned by the resource monitoring end, wherein the matching result includes a number of servers; and A request forwarding module is used to determine an execution server according to the candidate server and the matching result, and send the service request including the load factor to the execution server.
9. The device according to claim 8, characterized in that A business request including a load factor is generated by the following steps: Determining a plurality of sub-resources required to process the business request from historical data or a standard template for processing the business request; Determining a load factor according to a combination type of the plurality of sub-resources; The load factor is written into a preset field of the service request to obtain a service request including the load factor.
10. The device according to claim 8, characterized in that The load table records the sub-resource load status of each server in the server cluster in the cloud platform; The resource demand is matched with the load table maintained by the resource demand to obtain a matching result, including: Selecting a number of servers with the smallest load for each sub-resource from the load table to form sub-item sets of different sub-resources respectively; If there is an intersection among the item sets, the intersection is used as a matching result; If there is no intersection among the sub-item sets, calculate the union of the sub-item sets, obtain the sub-item ranking of each sub-resource of each server in the union in the load table, obtain the resource load ranking of the servers in the union by combining the sub-item rankings, and select several servers as matching results based on the resource load rankings.
11. The device according to claim 8, characterized in that Determining an execution server according to the candidate server and the matching result includes: Obtaining the generation time of the candidate server; If the matching result is not received within a first preset time period after the generation time, the server to be selected is used as the execution server; If the matching result is received within a first preset time period after the generation time, the execution server is determined according to the inclusion relationship between the candidate server and the matching result.
12. The device according to claim 11, characterized in that The matching result also includes the latest update time of the load table used for matching; If the matching result is received within a first preset time after the generation time, determining whether the difference between the generation time and the latest update time is greater than a second preset time; If the difference between the generation time and the latest update time is greater than a second preset time length, the server to be selected is used as the execution server; If the difference between the generation time and the latest update time is not greater than a second preset time length, the execution server is determined according to the inclusion relationship between the candidate server and the matching result.
13. The device according to claim 11 or 12, characterized in that Determining the execution server according to the inclusion relationship between the candidate server and the matching result includes: Determine whether the server to be selected is in the matching result; If the server to be selected is in the matching result, the server to be selected is used as the execution server; If the server to be selected is not in the matching result, a preset value is assigned to the server to be selected, and values are assigned to the servers in the matching result according to the time when the matching result is received in the load balancer and the position of the server in the matching result, and the server with the largest assigned value is selected as the execution server.
14. The device according to claim 13, characterized in that Assigning values to the servers in the matching result respectively according to the time when the matching result is received by the load balancer and the position of the server in the matching result, including: Calculating the difference between the receiving time and the generating time, and obtaining a time value by performing negative correlation mapping on the difference; Obtaining the position order of the servers in the matching results, and assigning values according to the position order to obtain position values; The product of the time assignment and the location assignment is used as the assignment of the server in the matching result.
15. A computer-readable storage medium, wherein instructions are stored in the storage medium, and when the storage medium is executed on a computer, the computer executes the steps of the dynamic load balancing method for a cloud platform as described in any one of claims 1 to 7.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the dynamic load balancing method for a cloud platform as described in any one of claims 1 to 7.