Load balancing method and system and readable storage medium
By obtaining and calculating load information, filtering schedulable nodes, and dynamically selecting load balancing strategies, the response problem of microservice scheduling solutions when load changes is solved, and load balancing and resource utilization optimization in cloud-edge environments are achieved.
Patent Information
- Application Number
- CN202410755027.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-12
AI Technical Summary
Existing microservice scheduling solutions are difficult to respond in real time according to changes in service load in a short period of time, making it difficult to guarantee service quality, especially when heterogeneous clusters and edge nodes have limited resources.
By obtaining the load information of cluster nodes and pods, calculating load scores, filtering schedulable nodes, monitoring load conditions in real time, and dynamically selecting load balancing strategies to avoid node overload and waste of resources, load balancing is achieved.
It effectively avoids node overload and waste of resources, reduces operation and maintenance costs, improves service quality, and achieves dynamic load balancing in a cloud-edge environment.
Smart Images

Figure CN118606002A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of microservice technology, and specifically relates to a load balancing method, system and readable storage medium. Background Art
[0002] Most frameworks and open source software of microservice architecture are designed to be intrusive, so it is necessary to integrate relevant service governance components into business logic. In the service mesh architecture, inter-service communication is carried out through the mesh proxy. All traffic between applications and the management and control of traffic will be implemented in the service mesh through the proxy. Furthermore, container virtualization technology can standardize microservice deployment. This containerized microservice architecture is not only widely used in the field of cloud computing, but also has good adaptability to the diverse needs of edge scenarios. Deploying containerized microservice applications in the cloud-edge environment can simultaneously enjoy the low access latency of edge nodes and the high computing power of cloud data centers. According to the traffic strategy, each service request can choose to reach different instances of different versions of the destination service on the node.
[0003] Since the configuration of cluster nodes is heterogeneous, different nodes have different processing capabilities, and the resources of edge nodes are limited, different types of microservice chains have different resource requirements. At the same time, the dynamic nature of services in the cluster will also affect scheduling decisions. Cluster resources and microservice loads are usually in dynamic change and iteration, resulting in the distribution of user requests constantly changing. It is difficult for existing scheduling solutions to make real-time dynamic responses to changes in service load in a short period of time. The lack of dynamic response to services will inevitably lead to difficulties in ensuring service quality.
[0004] Therefore, in view of the above technical problems, it is necessary to provide an improved scheduling solution based on load balancing.
[0005] The information disclosed in this background technology section is only intended to enhance the understanding of the overall background of the invention and should not be regarded as an acknowledgment or any form of suggestion that the information constitutes the prior art already known to a person skilled in the art. Summary of the invention
[0006] The object of the present invention is to provide a load balancing method, system and readable storage medium, which can avoid the problem of blocking caused by node overload and alleviate the problem of waste due to insufficient resource utilization.
[0007] In order to achieve the above object, a technical solution provided by a specific embodiment of the present invention is as follows:
[0008] In a first aspect, the present invention provides a load balancing method, comprising:
[0009] Obtain load information of each node in the cluster and each pod in the node, the load information including multiple load usages;
[0010] Determine whether each pod in the cluster is in a load balancing state;
[0011] If not, the schedulable nodes are screened based on the load information of each node and the preset load usage threshold of each node;
[0012] Based on a preset load evaluation algorithm, respectively calculate a first load score for each node and each pod, and calculate a second load score for each pod based on the first load scores for each node and each pod;
[0013] The pod corresponding to the maximum value of the second load score is obtained, and the request to be scheduled is scheduled to the pod.
[0014] In one or more embodiments of the present invention, the screening of schedulable nodes based on the load information of each node and the preset load usage threshold of each node includes:
[0015] If at least one load usage in the node load information is greater than the corresponding load usage threshold, the node is an unschedulable node;
[0016] If all the load usages in the node load information are less than or equal to the corresponding load usage threshold, then the node is a schedulable node.
[0017] In one or more embodiments of the present invention, the method further comprises:
[0018] Obtaining a timestamp corresponding to the load information, and calculating a difference between the current time and the time recorded by the timestamp;
[0019] If the difference between the current time and the time recorded by the timestamp is greater than a preset validity threshold, the load information is invalid;
[0020] If the difference between the current time and the time recorded by the timestamp is less than or equal to a preset validity threshold, the load information is valid.
[0021] In one or more embodiments of the present invention, the load evaluation algorithm is:
[0022]
[0023] finalScore=(nodeScore×γ node +podScore×γ pod ) / (γ node +γ pod )
[0024] Among them, α i is the usage of each load recorded in the node load information; i is α i The corresponding weight value; b j It is the usage of each load recorded in the pod load information; j for b j The corresponding weight value; MaxScore is the preset maximum score; γ node is the weight of the first load score of the node in the second load score, γ pod The first load score of the pod is the weight of the second load score, and finalScore is the load score corresponding to the pod.
[0025] In one or more embodiments of the present invention, the method further comprises:
[0026] Real-time monitoring of the workload of each node and pod in the cluster;
[0027] Based on the preset monitoring strategy, the load information of each node in the cluster and each pod in the node is periodically collected;
[0028] The corresponding pod is marked based on an average value of the load information collected within a preset time interval, and a timestamp is added to the average value based on the time interval.
[0029] In one or more embodiments of the present invention, the method further comprises:
[0030] Monitor the workload of each node and pod in the cluster in real time;
[0031] Based on the preset monitoring strategy, the load information of each node in the cluster and each pod in the node is periodically collected;
[0032] The corresponding pod is labeled based on the load information collected most recently, and a timestamp is added to the load information based on the collection time.
[0033] In one or more embodiments of the present invention, the method further comprises:
[0034] If the cluster is load balanced, the scheduling request is scheduled based on a polling algorithm, a minimum connection algorithm, or a random selection of healthy instances.
[0035] In a second aspect, the present invention provides a load balancing system, comprising:
[0036] An acquisition module is used to obtain load information of each node in the cluster and each pod in the node, wherein the load information includes multiple load usages;
[0037] The judgment module is used to determine whether each pod in the cluster is in a load balancing state;
[0038] The screening module is used to screen the schedulable nodes based on the load information of each node and the preset load usage threshold when the cluster load is unbalanced;
[0039] A calculation module, configured to calculate a first load score of each node and each pod based on a preset load evaluation algorithm, and calculate a second load score of each pod based on the first load scores of each node and each pod;
[0040] The scheduling module is used to obtain the pod corresponding to the maximum value of the second load score, and schedule the request to be scheduled to the pod.
[0041] In a third aspect, the present invention provides a load balancing system, comprising:
[0042] A monitoring module is used to monitor the workload of each node and pod in the cluster in real time, and periodically collect the load information of each node in the cluster and the pod in each node based on a preset monitoring strategy;
[0043] A data input module, used to update the load information in real time, and process the load information based on a preset monitoring strategy and send it to the optimization processing module;
[0044] The optimization processing module is used to dynamically select the load balancing strategy based on the variance value of each pod's load usage;
[0045] File reading and writing module, used to read the selected load balancing strategy;
[0046] The application deployment module is used to write a command line based on the selected load balancing strategy to complete the application modification deployment.
[0047] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the load balancing method.
[0048] Compared with the prior art, the load balancing method provided by the present invention is based on the load balancing request scheduling strategy of the service grid, and filters and selects the service grid nodes according to the actual workload and resource utilization rate of the production environment, which can avoid the problem of node overload and blockage. At the same time, considering the node heterogeneity and service differences, it can alleviate the problem of insufficient resource utilization and waste to a certain extent. Furthermore, the adaptive application system can dynamically update the preferred load balancing strategy, and automatically send the service grid to reduce the operation and maintenance costs, provide feedback through real-time load perception, maintain load balancing, and optimize service quality. Based on the load balancing method, the configuration information automatically sends the module to complete the entire dynamic optimization strategy process, without intruding the source code, and has high scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 is a schematic diagram of a load information acquisition and processing architecture in one embodiment of the present invention;
[0051] Figure 2 is a flow chart of a load balancing method in one embodiment of the present invention;
[0052] Figure 3 is a structural block diagram of a load balancing system in one embodiment of the present invention;
[0053] Figure 4 is a structural block diagram of an electronic device in one embodiment of the present invention;
[0054] Figure 5 It is an application system architecture diagram in one embodiment of the present invention. DETAILED DESCRIPTION
[0055] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific implementation modes.
[0056] Unless explicitly stated otherwise, throughout the specification and claims, the term “comprise” or variations such as “include” or “comprising”, etc., will be understood to include the stated elements or components but not to exclude other elements or components.
[0057] In order to facilitate understanding of the technical solutions of the present application, the technical terms that may appear in the present invention are first explained in detail below.
[0058] Microservice Architecture: is an architectural concept that aims to reduce system coupling and provide more flexible service support by decomposing functions into discrete services. Split a large single application and service into several or even dozens of supporting microservices, which can extend a single component rather than the entire application stack to meet service level agreements. Create applications around business domain components that can be developed, managed, and iterated independently. Use cloud architecture and platform-style deployment, management, and service capabilities in decentralized components to make product delivery simpler. In essence, it is to use some services with clear functions and concise business to solve larger and more practical problems.
[0059] Service Mesh: When using service mesh, you don't have to worry about the details of service governance. All functions outside of business are handled by the service mesh. The service mesh draws a clear line between business logic and service governance logic. It is the most thorough method of decoupling and reuse among all architectural patterns. Under the service mesh architecture, inter-service communication is carried out through the mesh proxy. All traffic between applications and the management and control of traffic will be implemented in the service mesh through the proxy. Each microservice instance in the service mesh will be configured with a Sidecar proxy, whose main responsibility is to take over the inbound and outbound traffic of the corresponding service. For example, all service governance functions such as service subscription, service discovery, circuit breaking, current limiting, degradation and distributed tracing are taken over by Sidecar. Application services only need to communicate with Sidecar to access each other. With the deployment of a large number of Sidecars in microservices, these Sidecar nodes naturally form a service mesh.
[0060] There are many methods for scheduling requests in the existing technical solutions. One is to schedule the requests to be scheduled through a single fixed request scheduling strategy. Under this scheduling strategy, it is difficult to meet application requirements and achieve excellent real-time response. In the common situation where the load changes in real time, it is easy to cause low-performance nodes to be overloaded and blocked due to the inability to perceive the current load distribution status, while high-performance nodes have insufficient resource utilization and waste.
[0061] The second method is to use manual update strategies for scheduling. Manual scheduling can alleviate the problem of uneven load on pods on each node of the service grid to a certain extent. However, in actual application scenarios, manual adjustment of strategies is extremely inefficient and it is still difficult to guarantee service quality. The large amount of human resources consumed causes a surge in operation and maintenance costs.
[0062] The inventor of the present invention discovered the main shortcomings of the prior art and proposed a new technical implementation idea based on the shortcomings of the prior art: by periodically collecting load information of nodes and / or pods in the service grid in real time, filtering nodes in the service framework whose load reaches the threshold based on the load information, and no longer scheduling requests to the node. A new evaluation system is created to normalize the load of the pods of each schedulable node, calculate the load score of each pod through an algorithm, and schedule the request to be scheduled to the pod with the highest load score.
[0063] Please refer to Figure 2 FIG. 1 is a flow chart of a load balancing method in one embodiment of the present invention. The load balancing method specifically includes the following steps:
[0064] S201: Obtain load information of each node in the cluster and each pod in the node;
[0065] It should be noted that the performance loss of the microservice architecture in the cloud-edge environment is distributed in various parts. At the same time, due to the differences in node resource configuration and service characteristics within the system, the cluster resources and microservice loads are usually in dynamic change and iteration. Therefore, the load information of each node and / or pod changes irregularly at all times. In order to balance the load, the load balancing method provided by the present invention needs to obtain the load information on each node and pod when scheduling a request, and then obtain the pod that is most suitable for scheduling at the current moment and the node corresponding to the pod.
[0066] It is understandable that the embodiments of the present invention do not limit the location where the load information of each node and pod is recorded. Preferably, the load information on each node and pod can be recorded on the CRD of the corresponding node. CRD is CustomResource Definition, which is a Kubernetes API extension mechanism. It allows users to create and manage custom resources that are not part of the Kubernetes standard API. CRD makes Kubernetes not only limited to built-in resources (such as Pod, Service, etc.), but also supports user-defined resource types.
[0067] It can be understood that before executing the above step of "obtaining the load information of each node in the service grid and each pod in the node, the load information including multiple load usages", the load balancing method provided by the present invention also includes monitoring and collecting the load information of each node and pod, and recording the load information in the corresponding node or pod.
[0068] Specifically, in an exemplary embodiment, monitoring and collecting load information of each node and pod, and recording the load information in the corresponding node or pod includes: real-time monitoring of the workload of each node and pod in the service grid; based on a preset monitoring strategy, periodically collecting the load information of each node in the service grid and each pod in the node, and storing the load information in an intermediate variable; marking the corresponding pod based on the average value of the load information collected within a preset time interval, and adding a timestamp to the average value based on the time interval.
[0069] It should be noted that adding a timestamp to the average value based on a time interval includes: marking the average value based on the time length of the time interval; writing the average value with the time length mark into the CRD of the corresponding node or pod in the form of a comment, and adding the time when the average value is obtained as a timestamp to the comment.
[0070] For example, Figure 1 As shown, it is a schematic diagram of the processing architecture for obtaining load information in a specific embodiment. In this specific embodiment, the cluster workload is monitored in real time with the help of Metrics-server components and log files, and the cpu_usage (CPU occupancy), cpu_percent (CPU usage), mem_usage (memory occupancy), mem_percent (memory usage) of all Nodes in the cluster and the cpu_usage (CPU occupancy), mem_usage (memory occupancy) and RC (number of requests in a time interval) of all Pods are recorded. The required load information is periodically obtained from the Metrics-server component and log files. Since the Metrics-server provides the most recent real-time data, after obtaining it, the Metrics-annotator supports user-defined performance indicators. If the average and maximum values of the CPU occupancy in the recent time are required, they need to be continuously obtained and stored in the intermediate variables within the preset time interval and calculated accordingly according to the set formula, and the output is a value such as cpu_usage_avg_t or cpu_usage_max_t, where t represents a preset time interval, etc.
[0071] Furthermore, the mean value marked with the time length is written into the corresponding node or pod in the form of an annotation, and a timestamp is added after the annotation is completed to mark the time when the mean value is obtained.
[0072] In another exemplary embodiment, monitoring and collecting load information of each node and pod, and recording the load information in the corresponding node or pod includes: real-time monitoring of the workload of each node and pod in the service grid; periodically collecting load information of each node in the service grid and each pod in the node based on a preset monitoring strategy; marking the corresponding pod based on the most recently collected load information, and adding a timestamp to the load information based on the collection time.
[0073] It should also be noted that the load information includes the load usage of multiple nodes / pods. Specifically, the load usage may include but is not limited to: CPU occupancy, CPU usage rate, memory occupancy, memory usage rate, number of requests within a time interval of a pod, etc. The embodiments of the present invention no longer limit the type and quantity of load information recorded and obtained.
[0074] At the same time, it can be understood that the longer the recording interval of each node and / or pod load information is, the less pressure on data processing and the lower the loss of system performance; conversely, the shorter the recording interval of load information is, the stronger the timeliness of the data is, and the load situation of the node / pod within the specified time can be more accurately reflected. Therefore, the recording time interval of load information can be adaptively adjusted based on the actual usage scenario, and the embodiment of the present invention does not limit this.
[0075] S202: Screening schedulable nodes based on the load information of each node and a preset load usage threshold of each node;
[0076] It is understandable that the principle of load balancing is to schedule more requests to pods with smaller current loads, thereby reducing the load on high-load nodes and achieving the purpose of system load balancing. The load threshold is the identification indicator that distinguishes between schedulable nodes and non-schedulable nodes.
[0077] Specifically, based on the preset load thresholds corresponding to each load usage, the schedulable nodes are screened, including: if there is at least one item of node load information whose load usage is greater than the corresponding load threshold, the node is an unschedulable node; if there is no at least one item of node load information whose load usage is greater than the corresponding load threshold, the node is a schedulable node.
[0078] It should also be noted that the criterion for determining whether a node is schedulable is the relationship between the load usage in the node's corresponding load information and the preset load threshold, so the validity of the load information is crucial to the above judgment logic. Furthermore, before selecting schedulable nodes, the validity of the node load information needs to be further verified to avoid abnormal judgment of the node status due to failure to pull load information, which causes the load information to become invalid.
[0079] In an exemplary embodiment, the above-mentioned validity check of the node load information includes: obtaining the timestamp corresponding to the load information, and calculating the difference between the current time and the time recorded in the timestamp; if the difference between the current time and the time recorded in the timestamp is greater than a preset validity threshold, the load information is invalid; if the difference between the current time and the time recorded in the timestamp is less than or equal to the preset validity threshold, the load information is valid.
[0080] S203: Based on a preset load evaluation algorithm, respectively calculate a first load score of each node and each pod, and calculate a second load score of each pod based on the first load scores of each node and each pod;
[0081] It should be noted that, in an exemplary embodiment, the load evaluation algorithm of the present invention may be:
[0082]
[0083] finalScore=(nodeScore×γ node +podScore×γ pod ) / (γ node +γ pod )
[0084] Among them, α i is the usage of each load recorded in the node load information; i is α i The corresponding weight value; b j It is the usage of each load recorded in the pod load information; j for b j The corresponding weight value; MaxScore is the preset maximum score; γ node is the weight of the first load score of the node in the second load score, γ pod is the weight of the first load score of the pod in the second load score, finalScore is the load score corresponding to the pod, L is the number of load usages in the node load information, and L' is the number of load usages in the pod load information.
[0085] The size of the weight value can affect the degree of influence of different load usage on the load score. The larger the weight value, the greater the influence of the corresponding load usage on the load score. Conversely, the smaller the weight value, the smaller the influence of the corresponding load usage on the load score. Based on different implementation scenarios, the size of each weight value can be adaptively adjusted. The embodiment of the present invention does not limit the value of the weight value.
[0086] It can be understood that the first load scores of each node and pod can reflect the load conditions of the corresponding node / pod to a certain extent. However, in complex application scenarios, there may be a situation where a node has a large load pressure but a relatively small load pressure on a certain pod. Based on the above situation, whether from the perspective of the node or the pod, the unilateral score is difficult to accurately present the priority of scheduling. Therefore, in the load balancing method provided by the present invention, the first load score corresponding to the pod is comprehensively calculated with the first load score of the node where it is located, and the generated second load score is used as the criterion for selecting the scheduled pod.
[0087] S204: Obtain the pod corresponding to the maximum value of the second load score, and schedule the pending scheduling request to the corresponding pod.
[0088] It should be noted that the load balancing method provided by the present invention aims to provide a relief method that can be adopted when the load of each node / pod in the system is uneven. Therefore, it can be understood that before screening the nodes, the non-load balancing method of the present invention further includes: calculating the variance of the load usage of each pod; if the above variance is greater than the preset balance threshold, then based on the load information of each node and the preset load usage thresholds, select the schedulable nodes.
[0089] It can be understood that variance is a measure of the degree of dispersion of a random variable or a set of data. That is, variance is used to measure the deviation between a random variable and its mathematical expectation (i.e., the mean). In the embodiments of the present invention, the variance of the load usage of each pod can measure the degree of load change. The larger the calculated variance, the more uneven the load of the corresponding pods.
[0090] Furthermore, when the above variance is greater than the preset balance threshold, it is considered that the system load is uneven at this time. Therefore, load balancing is required. Therefore, based on the load information of each node and the preset load usage thresholds, select the schedulable nodes. Based on the preset load evaluation algorithm, calculate the first load scores of each node and pod respectively, and calculate the second load scores of each pod based on the first load scores of each node and pod; obtain the pod corresponding to the maximum value of the second load score, and schedule the pending scheduling request to the pod.
[0091] If the variance is less than or equal to the preset balance threshold, it means that the system load is uniform at this time, and dynamic optimization can be performed in the default load balancing strategy set according to the load balancing degree. In an exemplary embodiment, the following situations are dynamically adjusted: when D < 1, ROUND_ROBIN (round-robin algorithm) is selected; when D > 2, LEAST_CONN (least connection algorithm) is selected; when 1 < D < 2, RANDOM (randomly select healthy instances) is selected, where D is the calculated variance value.
[0092] Please refer to Figure 3 As shown, based on the same inventive concept as the aforementioned load balancing method, an embodiment of the present invention provides a load balancing system 300 , which includes: an acquisition module 301 , a screening module 302 , a calculation module 303 and a scheduling module 304 .
[0093] Specifically, the acquisition module 301 is used to obtain the load information of each node in the cluster and each pod in the node, and the load information includes multiple load usages; the screening module 302 is used to screen the schedulable nodes based on the load information of each node and the preset load usage thresholds; the calculation module 303 is used to calculate the first load score of each node and pod respectively based on the preset load evaluation algorithm and calculate the second load score of each pod based on the first load score of each node and pod; the scheduling module 304 is used to obtain the pod corresponding to the maximum value of the second load score, and schedule the request to be scheduled to the corresponding pod.
[0094] Please refer to Figure 5 As shown, based on the same inventive concept as the aforementioned load balancing method, another embodiment of the present invention provides a load balancing system 500, which includes: a monitoring module 501, a data input module 502, an optimization processing module 503, a file reading and writing module 504 and an application deployment module 505.
[0095] Specifically, the monitoring module 501 is used to monitor the workload of each node and pod in the cluster in real time, and periodically collect the load information of each node in the cluster and each pod in the node based on the preset monitoring strategy; the data input module 502 is used to update the load information in real time, and process the load information based on the preset monitoring strategy and send it to the optimization processing module; the optimization processing module 503 is used to dynamically select the load balancing strategy based on the variance value of the load usage of each pod; the file reading and writing module 504 is used to read the load balancing strategy; the application deployment module 505 is used to write the command line to complete the application modification and deployment.
[0096] It should be noted that the file reading and writing modules modify the load balancing fields in the configuration files respectively; the application deployment module writes the command line, adaptively updates the configuration to make the new configuration information of the application service effective, and completes the application modification and deployment.
[0097] In an exemplary embodiment, Istio is a representative of the second-generation microservice governance framework, which uses Sidecar to decouple business logic from service governance in the form of a service mesh, and each service instance has an agent. EdgeMesh is an extension and expansion of the service mesh in edge computing scenarios, gradually connecting to the standard Istio for service governance control, and each node has an agent, which is more lightweight. The results obtained by optimizing the algorithm mechanism of the traffic management execution module need to be updated and applied to Istio and EdgeMesh in real time and adaptively.
[0098] The processing flow of the configuration information automatic delivery module is divided into two steps. In the first step, the YAML reading and writing module searches for the field position in the file named "destination-rule.yaml" for modification, that is, modifying the loadBalancer (load balancer) field in the configuration file respectively; the second step is to write the command line to adaptively update the configuration so that the new configuration information of the application service takes effect, that is, to complete the application modification and deployment by writing to the command line "kubectl apply-f file path / destination-rule.yaml" and other similar commands.
[0099] Please refer to Figure 4 As shown, an embodiment of the present invention further provides an electronic device 400, which includes at least one processor 401, a memory 402 (for example, a non-volatile memory), a memory 403, and a communication interface 404, and the at least one processor 401, the memory 402, the memory 403, and the communication interface 404 are connected together via a bus 405. At least one processor 401 is used to call at least one program instruction stored or encoded in the memory 402, so that the at least one processor 401 performs various operations and functions of the load balancing method described in various embodiments of this specification.
[0100] In an embodiment of the present specification, the electronic device 400 may include, but is not limited to, a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile electronic device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable electronic device, a consumer electronic device, and the like.
[0101] An embodiment of the present invention further provides a computer-readable medium carrying computer-executable instructions. When the computer-executable instructions are executed by a processor, they can be used to implement various operations and functions of the load balancing method described in various embodiments of this specification.
[0102] The computer-readable medium in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0103] In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0104] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take 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 code.
[0105] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatuses, systems, and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks 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 process in the flowchart. 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.
[0106] The foregoing description of specific exemplary embodiments of the present invention is for the purpose of illustration and demonstration. These descriptions are not intended to limit the present invention to the precise form disclosed, and it is clear that many changes and variations can be made based on the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the present invention and its practical application, so that those skilled in the art can realize and utilize various different exemplary embodiments of the present invention and various different selections and changes. The scope of the present invention is intended to be limited by the claims and their equivalents.
Claims
1. A load balancing method, It is characterized in that include: Obtain load information of each node in the cluster and each pod in the node, the load information including multiple load usages; Determine whether each pod in the cluster is in a load balancing state; If not, the schedulable nodes are screened based on the load information of each node and the preset load usage threshold of each node; Based on a preset load evaluation algorithm, respectively calculate a first load score for each node and each pod, and calculate a second load score for each pod based on the first load scores for each node and each pod; The pod corresponding to the maximum value of the second load score is obtained, and the request to be scheduled is scheduled to the pod.
2. The load balancing method according to claim 1, It is characterized in that The screening of schedulable nodes based on the load information of each node and the preset load usage threshold of each node includes: If at least one load usage in the node load information is greater than the corresponding load usage threshold, the node is an unschedulable node; If all the load usages in the node load information are less than or equal to the corresponding load usage threshold, then the node is a schedulable node.
3. The load balancing method according to claim 1, It is characterized in that The method further comprises: Obtaining a timestamp corresponding to the load information, and calculating a difference between the current time and the time recorded by the timestamp; If the difference between the current time and the time recorded by the timestamp is greater than a preset validity threshold, the load information is invalid; If the difference between the current time and the time recorded by the timestamp is less than or equal to a preset validity threshold, the load information is valid.
4. The load balancing method according to claim 1, It is characterized in that The load evaluation algorithm is: finalScore=(nodeScore×γ node +podScore×c pod ) / (c node +g pod ) Among them, α i is the usage of each load recorded in the node load information; i is α i The corresponding weight value; b j It is the usage of each load recorded in the pod load information; j for b j The corresponding weight value; MaxScore is the preset maximum score; γ node is the weight of the first load score of the node in the second load score, γ pod The first load score of the pod is the weight of the second load score, and finalScore is the load score corresponding to the pod.
5. The load balancing method according to claim 1, It is characterized in that The method further comprises: Monitor the workload of each node and pod in the cluster in real time; Based on the preset monitoring strategy, the load information of each node in the cluster and each pod in the node is periodically collected; The corresponding pod is marked based on an average value of the load information collected within a preset time interval, and a timestamp is added to the average value based on the time interval.
6. The load balancing method according to claim 1, It is characterized in that The method further comprises: Monitor the workload of each node and pod in the cluster in real time; Based on the preset monitoring strategy, the load information of each node in the cluster and each pod in the node is periodically collected; The corresponding pod is labeled based on the load information collected most recently, and a timestamp is added to the load information based on the collection time.
7. The load balancing method according to claim 1, It is characterized in that The method further comprises: If the cluster is load balanced, the scheduling request is scheduled based on a polling algorithm, a minimum connection algorithm, or a random selection of healthy instances.
8. A load balancing system, It is characterized in that include: An acquisition module is used to obtain load information of each node in the cluster and each pod in the node, wherein the load information includes multiple load usages; The judgment module is used to determine whether each pod in the cluster is in a load balancing state; The screening module is used to screen the schedulable nodes based on the load information of each node and the preset load usage threshold when the cluster load is unbalanced; A calculation module, configured to calculate a first load score of each node and each pod based on a preset load evaluation algorithm, and calculate a second load score of each pod based on the first load scores of each node and each pod; The scheduling module is used to obtain the pod corresponding to the maximum value of the second load score, and schedule the request to be scheduled to the pod.
9. A load balancing system, It is characterized in that include: A monitoring module is used to monitor the workload of each node and pod in the cluster in real time, and periodically collect the load information of each node in the cluster and the pod in each node based on a preset monitoring strategy; A data input module, used to update the load information in real time, and process the load information based on a preset monitoring strategy and send it to the optimization processing module; The optimization processing module is used to dynamically select the load balancing strategy based on the variance value of each pod's load usage; File reading and writing module, used to read the selected load balancing strategy; The application deployment module is used to write a command line based on the selected load balancing strategy to complete the application modification deployment.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the load balancing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Dynamic load balancing resource scheduling method based on Kubernetes
CN110780998A
Dynamic load balancing method for cloud platform
CN114090235A
Cluster resource load balancing method and device, electronic equipment and medium
CN114443284A
Resource load data processing method and device and storage medium
CN115454569A
Cited By
Load balancing method and device for distributed system, equipment and storage medium
CN119225970A
