Cluster Load Balancing Processing Method, Device, Equipment and Computer Storage Medium
By simulating the cluster behavior under different load balancing strategies, the appropriate target strategy is automatically selected, which solves the problems of low efficiency and poor accuracy of cluster load balancing in the existing technology, and achieves more efficient and accurate load balancing strategy selection and switching.
Patent Information
- Application Number
- CN202110989735.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-08-26
AI Technical Summary
The existing cluster load balancing switching methods are inefficient and have poor accuracy.
By obtaining the historical access data and parameter values of the previous adjustment cycle, input these data into the access model corresponding to different load balancing policies, simulate the load balancing situation under different policies, and automatically select the target load balancing strategy suitable for the current use.
It improves the efficiency and accuracy of cluster load balancing policy selection, reduces manual participation, and realizes automated policy switching.
Smart Images

Figure CN115729692B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a method, apparatus, device, and computer storage medium for cluster load balancing processing. Background Art
[0002] A cluster is a group of independent and uniformly managed servers. The servers in the cluster can share the completion of a work task. Among them, one server in the cluster is a node. To enable each node in the cluster to relatively evenly share the work task, thereby improving the overall efficiency of the cluster, load balancing technology is commonly used to manage the cluster.
[0003] Load balancing technology has various implementation strategies, such as the round-robin method, the random method, etc. The advantages and disadvantages of different load balancing strategies are different. A cluster may be suitable for different load balancing strategies under different working conditions. Currently, the selection and switching of the load balancing strategy of the cluster mainly rely on developers to collect and analyze the usage data of the current load balancing strategy used by the cluster, and then discuss in a meeting to decide whether to switch the load balancing strategy and what kind of load balancing strategy to switch to.
[0004] The current cluster load balancing switching method has problems such as low efficiency and poor accuracy. Summary of the Invention
[0005] This application provides a method, apparatus, device, and computer storage medium for cluster load balancing processing, which is used to solve the problems of low efficiency and poor accuracy existing in the current cluster load balancing switching method.
[0006] In a first aspect, this application provides a method for cluster load balancing processing. The cluster includes at least two nodes, and the cluster supports N load balancing strategies, where N is an integer greater than or equal to 2. The cluster adopted a first load balancing strategy among the N load balancing strategies in the previous adjustment period. The method includes:
[0007] Obtain the first historical access data of the cluster in the previous adjustment period, and the first parameter value of the cluster in the previous adjustment period. The first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the first load balancing strategy in the previous adjustment period of the cluster;
[0008] Input the first historical access data into N - 1 access models respectively to obtain N - 1 second parameter values of the cluster in the previous adjustment period; each of the access models corresponds to one of the N load balancing policies except the first load balancing policy, and the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing policy in the first test adjustment period; the duration of the first test adjustment period is the same as that of the previous adjustment period;
[0009] Determine a target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value;
[0010] If the target load balancing policy is different from the first load balancing policy, control the cluster to use the target load balancing policy to process access data in the current adjustment period.
[0011] Optionally, the determining the target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value includes:
[0012] If there are X second parameter values among the N - 1 second parameter values whose corresponding load balancing situations are better than the load balancing situation corresponding to the first parameter value, determine the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values, where X is greater than or equal to 1 and less than or equal to N - 1;
[0013] Or, if the load balancing situations corresponding to all the second parameter values among the N - 1 second parameter values are lower than or equal to the load balancing situation corresponding to the first parameter value, use the first load balancing policy as the target load balancing policy.
[0014] Optionally, the determining the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values includes:
[0015] If X is equal to 1, use the second load balancing policy corresponding to this second parameter value as the target load balancing policy;
[0016] If X is greater than or equal to 2, determine the target load balancing policy from the second load balancing policies corresponding to the X second parameter values according to the load balancing situations corresponding to the X second parameter values.
[0017] Optionally, the determining the target load balancing policy from the second load balancing policies corresponding to the X second parameter values according to the load balancing situations corresponding to the X second parameter values includes:
[0018] According to the load balancing situation corresponding to the X second parameter values, use the second load balancing policy corresponding to the second parameter value with the best load balancing situation among the X second parameter values as the target load balancing policy.
[0019] Optionally, the determining the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values includes:
[0020] Obtain the second historical access data of the first M adjustment cycles of the cluster, and the third parameter values of the cluster in the first M adjustment cycles; the third parameter values are used to characterize the load balancing situation of each node in the cluster when processing the second historical access data of each cycle by using the load balancing policy corresponding to each cycle during the first M adjustment cycles of the cluster; M is greater than or equal to 2;
[0021] Input the second historical access data of the first M adjustment cycles of the cluster into X access models respectively to obtain X fourth parameter values of the cluster in the first M adjustment cycles; each access model in the X access models corresponds to a second load balancing policy; the fourth parameter values are used to characterize the load balancing situation of each node in the cluster when processing the second historical access data by using the corresponding second load balancing policy during the second test adjustment cycle; the duration of the second test adjustment cycle is the same as the sum of the durations of the first M adjustment cycles;
[0022] If there are Y second parameter values corresponding to the load balancing situation among the X fourth parameter values that are better than the load balancing situation corresponding to the third parameter values, then determine the target load balancing policy according to the load balancing policies corresponding to the Y second parameter values, where Y is greater than or equal to 1 and less than or equal to X;
[0023] Or, if the load balancing situations corresponding to all the fourth parameter values among the X fourth parameter values are lower than or equal to the load balancing situation corresponding to the third parameter values, then use the first load balancing policy as the target load balancing policy.
[0024] Optionally, the determining the target load balancing policy according to the load balancing policies corresponding to the Y second parameter values includes:
[0025] If Y is equal to 1, then use the load balancing policy corresponding to this fourth parameter value as the target load balancing policy;
[0026] If Y is greater than or equal to 2, then determine the target load balancing policy from the load balancing policies corresponding to the Y fourth parameter values according to the load balancing situations corresponding to the Y fourth parameter values.
[0027] Optionally, determining the target load balancing policy from the load balancing policies corresponding to the Y fourth parameter values according to the load balancing situation corresponding to the Y fourth parameter values includes:
[0028] According to the load balancing situation corresponding to the Y fourth parameter values, taking the load balancing policy corresponding to the fourth parameter value with the best load balancing situation among the Y fourth parameter values as the target load balancing policy.
[0029] Optionally, controlling the cluster to use the target load balancing policy to process access data in the current adjustment period includes:
[0030] Sending a load balancing policy switching request to the load balancer of the cluster, where the load balancing policy switching request includes: an identifier of the target load balancing policy.
[0031] In a second aspect, the present application provides a cluster load balancing processing device. The cluster includes at least two nodes, and the cluster supports N load balancing policies, where N is an integer greater than or equal to 2; the cluster adopted the first load balancing policy among the N load balancing policies in the previous adjustment period; the device includes:
[0032] An acquisition module, configured to acquire the first historical access data of the cluster in the previous adjustment period, and the first parameter value of the cluster in the previous adjustment period; the first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the first load balancing policy in the previous adjustment period of the cluster;
[0033] A processing module, configured to respectively input the first historical access data into N-1 access models to obtain N-1 second parameter values of the cluster in the previous adjustment period; each access model corresponds to one load balancing policy other than the first load balancing policy among the N load balancing policies, and the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing policy in the first test adjustment period; the duration of the first test adjustment period is the same as the duration of the previous adjustment period;
[0034] A determination module, configured to determine a target load balancing policy from the N load balancing policies according to the N-1 second parameter values and the first parameter value;
[0035] A control module, configured to control the cluster to process access data using the target load balancing policy in the current adjustment period when the target load balancing policy is different from the first load balancing policy.
[0036] In a third aspect, the present application provides an electronic device, which includes: at least one processor and a memory;
[0037] The memory stores computer-executable instructions;
[0038] The at least one processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the method described in any one of the first aspect.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in any one of the first aspect.
[0040] In a fifth aspect, the present application provides a cluster load balancing processing system, which includes a cluster and a load balancer. The load balancer supports N load balancing policies, where N is an integer greater than or equal to 2; the load balancer is used to execute the method described in any one of the first aspect to perform load balancing control on the cluster.
[0041] In a sixth aspect, the present application provides a cluster load balancing processing system, which includes a cluster, a load balancer, and an electronic device. The load balancer supports N load balancing policies, where N is an integer greater than or equal to 2; the electronic device is used to execute the method described in any one of the first aspect to control the load balancer to perform load balancing control on the cluster.
[0042] The cluster load balancing processing method, device, equipment, and computer storage medium provided by the present application can automatically obtain the actual load balancing situation of each node in the cluster in the previous adjustment period, and automatically obtain the load balancing simulation situation of each node in the cluster when processing the first historical access data using other load balancing policies by inputting the first historical access data in the previous adjustment period into the access models corresponding to other load balancing policies. This method can automatically select a load balancing policy suitable for the cluster to use in the current adjustment period by comparing the actual load balancing situation and the simulation situation of each node in the cluster, without manual participation, improving the efficiency and accuracy of cluster load balancing policy selection. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0044] Figure 1 It is a schematic diagram of the architecture of a load balancing system to which a cluster load balancing processing method provided by an embodiment of the present application is applied;
[0045] Figure 2 It is a schematic diagram of the architecture of another load balancing system to which a cluster load balancing processing method provided by an embodiment of the present application is applied;
[0046] Figure 3 It is a schematic flowchart of a cluster load balancing processing method provided by an embodiment of the present application;
[0047] Figure 4 It is a schematic flowchart of another cluster load balancing processing method provided by an embodiment of the present application;
[0048] Figure 5 It is a schematic diagram of the structure of a cluster load balancing processing device provided by an embodiment of the present application;
[0049] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application.
[0050] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and text descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Embodiments
[0051] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0052] Figure 1 It is a schematic diagram of the architecture of a load balancing system to which a cluster load balancing processing method provided by an embodiment of the present application is applied. As Figure 1 shown, the load balancing system includes: a terminal, a cluster composed of multiple nodes, and a load balancer. Among them, the terminal is used to request the cluster to process access data. The above-mentioned cluster can be a group of independent and uniformly managed servers, and one server in the cluster is a node. Each node in the cluster can process a part of the entire cluster's work tasks in parallel, so as to implement the distribution of a unified work task to multiple nodes for processing. The load balancer distributes tasks to the nodes in the cluster through a load balancing strategy to balance the load of each node.
[0053] Among them, the load balancing strategy is the method used by the load balancer to allocate the work tasks of the entire cluster to each node in the cluster. For example, the round-robin method, the random method, the source address hashing method, the least connection number method, etc.
[0054] Different load balancing strategies may have different advantages and disadvantages respectively, and the working conditions of the cluster may vary in different working stages. Therefore, the load balancing strategies suitable for the cluster in different stages may also be different.
[0055] Currently, for the selection and switching of the load balancing strategy of the cluster, mainly after the R & D personnel collect and analyze the usage data of the load balancing strategy currently used by the cluster, they hold meetings to discuss whether to switch the load balancing strategy and, if so, to which load balancing strategy. After determining that the load balancing strategy needs to be switched and the load balancing strategy to be switched to, the operation and maintenance personnel also need to manually change the load balancing strategy of the cluster.
[0056] Different from the above technical solutions, the present application provides a cluster load balancing processing method, which can automatically select the target load balancing strategy suitable for the cluster to use under the current working conditions, thereby improving the efficiency and accuracy of the selection of the cluster load balancing strategy.
[0057] The cluster load balancing processing method provided by the present application can be applicable to the Figure 1 schematic diagram of the load balancing system architecture shown above. Among them, in addition to being used to execute the distribution of the entire cluster work tasks, the load balancer is also used to select the target load balancing strategy suitable for the cluster to use under the current working conditions, and when the target load balancing strategy is not the load balancing strategy currently used by the cluster, control the cluster to use the target load balancing strategy.
[0058] The cluster load balancing processing method provided by the present application can also be applicable to the Figure 2 schematic diagram of the load balancing system architecture shown. As Figure 2 shown, the load balancing system includes: a terminal, a cluster composed of multiple nodes, a load balancer, and an electronic device. Among them, the terminal is used to request the cluster to process the access data. The above load balancer is only used to execute the distribution of the entire cluster work tasks. The electronic device is used to select the target load balancing strategy suitable for the cluster to use under the current working conditions, and when the target load balancing strategy is not the load balancing strategy currently used by the cluster, control the cluster to use the target load balancing strategy.
[0059] It should be understood that the above Figure 1 and Figure 2An exemplary description is given by taking the load balancer as a separate device independent of the cluster. The load balancer can also be integrated into a certain node in the cluster, and this node performs load balancing on the cluster. In other words, this node has the function of performing load balancing on the cluster, and this application does not limit this. It should be understood that in addition to the load balancing function, this node can also have other functions, such as processing access data, etc.
[0060] Exemplarily, the above-mentioned electronic device can be, for example, any terminal or server with processing capabilities. The terminal involved in this application can also be referred to as a terminal device, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. For example, it can be a mobile phone, a tablet computer (pad), or a computer with wireless transceiver functions.
[0061] It should be understood that the execution subject of the cluster load balancing processing method provided in this application can be a load balancer or a component with processing capabilities in the load balancer (such as a chip), or an electronic device independent of the load balancer or a component with processing capabilities in the electronic device (such as a chip). This application does not make any limitations in this regard. The following embodiments give an exemplary description with the execution subject being an electronic device.
[0062] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments below can be combined with each other, and for the same or similar concepts or processes, they may not be repeated in some embodiments. The following will describe the embodiments of this application with reference to the drawings.
[0063] Figure 3 It is a schematic flowchart of a cluster load balancing processing method provided by an embodiment of this application.
[0064] As Figure 3 shown, this method of this application may include:
[0065] S101, obtain the first historical access data of the cluster and the first parameter value of the cluster in the previous adjustment period.
[0066] Among them, the first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the first load balancing strategy in the previous adjustment period. The duration of the previous adjustment period can be set by the user, or obtained by the electronic device after statistically analyzing the access data for a period of time. For example, the electronic device can obtain the access data for a period of time, and according to the change of the access data volume, take the time from the occurrence of a peak value to the occurrence of a valley value of the access data volume as an access data fluctuation period, and use the duration of this fluctuation period as the duration of the first adjustment period.
[0067] The above first parameter value can be, for example, the standard deviation σ of the usage rate of the central processing unit (CPU) of each node in the cluster in the previous adjustment period. The larger the standard deviation σ, the more unbalanced the load of each node in the cluster. Or, the above first parameter value can also be, for example, the processing duration of the overall work task of the cluster. The longer the processing duration, the more unbalanced the load of each node in the cluster.
[0068] The above first historical access data can be, for example, the processing operations requested by the user from the cluster in the previous adjustment period and their corresponding times.
[0069] S102, input the first historical access data into N - 1 access models respectively to obtain N - 1 second parameter values of the cluster in the previous adjustment period.
[0070] Among them, the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing strategy in the first test adjustment period. Exemplarily, the second parameter value can be the same as the first parameter value, or the second parameter value can also be different from the first parameter value. Exemplarily, when the second parameter value is different from the first parameter value, the electronic device can map the parameter value selected by the second parameter value to the parameter value selected by the first parameter value, or map the parameter value selected by the first parameter value to the parameter value selected by the second parameter value. The mapping relationship between parameter values can be determined according to the historical data collected by the electronic device. The historical data can be, for example, the parameter values obtained after the cluster processes the same access data in the same time period, and the numerical relationship between the parameter values.
[0071] The duration of the first test adjustment period is the same as that of the previous adjustment period. Exemplarily, the duration of the first test adjustment period can be input by the user together when setting the duration of the adjustment period, or determined by the electronic device itself after obtaining the duration of the adjustment period. Exemplarily, the electronic device can input the duration of the first test adjustment period and the first historical access data into N - 1 access models, so that the N - 1 access models perform simulated access on the first historical access data within the first test adjustment period to obtain N - 1 second parameter values. Using the access model to perform simulated access on the first historical access data within the first test adjustment period with the same duration as the previous adjustment period can ensure that the cluster and the access model process the same access data within the same duration, that is, it can make the access model and the cluster in the same application scenario, thereby increasing the accuracy and reliability of the simulated access of the access model.
[0072] Each of the above access models corresponds to one of the N load balancing policies except the first load balancing policy. Exemplarily, for one load balancing policy, the electronic device can use multiple sample adjustment periods, multiple groups of sample access data within the multiple sample adjustment periods, and multiple sample parameter values obtained by the cluster after processing the multiple groups of sample access data as training samples for training the access model. Among them, the sample parameter values are used to characterize the load balancing situation of each node in the cluster when the cluster processes the sample access data using the corresponding load balancing policy within each sample adjustment period. Exemplarily, the electronic device can use the deep learning framework provided in the open - source artificial neural network library Keras written in Python to perform neural network training on the N load balancing policies to obtain N access models. Regarding how to obtain the access model according to the deep learning framework, reference can be made to the prior art and will not be elaborated here.
[0073] S103. Determine the target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value.
[0074] For example, the electronic device can determine the target load balancing policy from the N load balancing policies based on the actual requirements of the cluster according to the N - 1 second parameter values and the first parameter value.
[0075] Exemplarily, if the actual requirement of the cluster is to require a better load balancing policy to make the load of each node in the cluster more balanced, the electronic device can determine the currently optimal load balancing policy as the target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value, or determine a load balancing policy that is better than the current load balancing policy as the target load balancing policy from the N load balancing policies.
[0076] Exemplarily, if the actual requirement of the cluster is other requirements that sacrifice load balancing, the electronic device may determine the current worst load balancing policy as the target load balancing policy from the N load balancing policies according to the N-1 second parameter values and the first parameter value, or determine a load balancing policy that is worse than the current load balancing policy as the target load balancing policy from the N load balancing policies, etc.
[0077] S104. When the target load balancing policy is different from the first load balancing policy, control the cluster to use the target load balancing policy to process the access data in the current adjustment period.
[0078] Exemplarily, the electronic device may send a load balancing policy switching request to the load balancer of the cluster, and the load balancing policy switching request includes: the identifier of the target load balancing policy.
[0079] Exemplarily, after receiving the load balancing policy switching request, the load balancer may determine the target load balancing policy according to the identifier of the target load balancing policy in the request, and control the cluster to use the target load balancing policy to process the access data in the current adjustment period.
[0080] For example, when all the configuration packages of the N load balancing policies are pre-configured in the load balancer, the load balancer may call the configuration package of the target load balancing policy to control the cluster to use the target load balancing policy to process the access data in the current adjustment period. Or, when all the configuration packages of the N load balancing policies are not pre-configured in the load balancer, the electronic device may send the configuration package of the target load balancing policy to the load balancer together when sending the load balancing policy switching request.
[0081] It should be understood that the above embodiments are exemplary descriptions with the electronic device as the execution subject. When the load balancer is the execution subject in the above method embodiments, the above action of sending the load balancing request is not required. Exemplarily, when the load balancer is the execution subject, the load balancer may directly control the cluster to use the target load balancing policy to process the access data in the current adjustment period after determining the target load balancing policy.
[0082] In addition, it should be noted that if the target load balancing policy is the same as the first load balancing policy, no processing may be performed, so that the cluster continues to use the first load balancing policy to process the access data in the current adjustment period.
[0083] The cluster load balancing processing method provided by this application can automatically obtain the actual load balancing situation of each node in the cluster in the previous adjustment period, and by inputting the first historical access data in the previous adjustment period into the access model corresponding to other load balancing strategies, automatically obtain the load balancing simulation situation of each node in the cluster when using other load balancing strategies to process the first historical access data. This method can automatically select a load balancing strategy suitable for the cluster to use in the current adjustment period by comparing the actual load balancing situation and the simulation situation of each node in the cluster, without manual participation, improving the efficiency and accuracy of the selection of the cluster load balancing strategy. In addition, when the determined target load balancing strategy is different from the first load balancing strategy adopted by the cluster in the previous adjustment period, this method can also automatically control the cluster to use the target load balancing strategy to process access data in the current adjustment period, without manual participation, improving the efficiency and accuracy of the switching of the cluster load balancing strategy.
[0084] Taking the actual demand of the cluster for a better load balancing strategy as an example, how the electronic device determines the target load balancing strategy from N load balancing strategies according to N - 1 second parameter values and the first parameter value will be described in detail. In this scenario, the above step S103 may further include the following implementation manners:
[0085] The first implementation manner: When the load balancing situations corresponding to all the second parameter values among the N - 1 second parameter values are lower than or equal to the load balancing situation corresponding to the first parameter value, the electronic device may use the first load balancing strategy as the target load balancing strategy.
[0086] The second implementation manner: When there are X second parameter values among the N - 1 second parameter values whose corresponding load balancing situations are better than the load balancing situation corresponding to the first parameter value, and X is equal to 1, the electronic device may use the second load balancing strategy corresponding to this second parameter value as the target load balancing strategy.
[0087] The third implementation manner: When there are X second parameter values among the N - 1 second parameter values whose corresponding load balancing situations are better than the load balancing situation corresponding to the first parameter value, and X is greater than or equal to 2 and less than or equal to N - 1, the electronic device may determine the target load balancing strategy from the second load balancing strategies corresponding to these X second parameter values according to the load balancing situations corresponding to these X second parameter values. Exemplarily, in this implementation manner, the ways for the electronic device to determine the target load balancing strategy may include the following situations.
[0088] Situation 1: The electronic device randomly selects the target load balancing strategy from the X second load balancing strategies.
[0089] Case 2: The electronic device selects the second load balancing policy with the optimal load balancing situation from X second load balancing policies as the target load balancing policy.
[0090] In this case, exemplarily, the electronic device may, according to the load balancing situations corresponding to the X second parameter values, use the second load balancing policy corresponding to the second parameter value with the optimal load balancing situation among the X second parameter values as the target load balancing policy.
[0091] Case 3: The electronic device further combines subsequent steps to select the target load balancing policy.
[0092] Figure 4 It is a schematic flowchart of another cluster load balancing processing method provided by an embodiment of the present application. As Figure 4 shown, in this case, the cluster load balancing processing method provided by the present application may further include:
[0093] S1031, obtain the second historical access data of the cluster in the first M adjustment cycles, and the third parameter value of the cluster in the first M adjustment cycles.
[0094] Wherein, M is greater than or equal to 2. Exemplarily, the value of M may be negatively correlated with the duration of the adjustment cycle, that is, the longer the duration of the adjustment cycle, the smaller the value of M may be.
[0095] The above third parameter value is used to characterize the load balancing situation of each node in the cluster when processing the second historical access data of each cycle by adopting the load balancing policy corresponding to each cycle in the first M adjustment cycles of the cluster. The third parameter value may be, for example, the standard deviation σ of the CPU usage rate of each node in the cluster in the first M adjustment cycles or the processing duration of the overall work tasks of the cluster, etc.
[0096] Exemplarily, the above second historical access data may be the processing operations requested by the user from the cluster in the first M adjustment cycles and their corresponding times.
[0097] S1032, respectively input the second historical access data of the cluster in the first M adjustment cycles into X access models to obtain X fourth parameter values of the cluster in the first M adjustment cycles.
[0098] Wherein, each of the X access models corresponds to a second load balancing policy.
[0099] The above fourth parameter value is used to characterize the load balancing situation of each node in the cluster when processing the second historical access data by adopting the corresponding second load balancing strategy during the second test adjustment period. Exemplarily, the above fourth parameter value can be selected as the same parameter value as the third parameter value, or alternatively, a parameter value different from the third parameter value can also be selected. Exemplarily, when the fourth parameter value is selected as a parameter value different from the third parameter value, the electronic device can map the parameter value selected by the fourth parameter value to the parameter value selected by the third parameter value, or map the parameter value selected by the third parameter value to the parameter value selected by the fourth parameter value. Among them, the mapping relationship between the parameter values can be determined according to the historical data collected by the electronic device. The historical data can be, for example, each parameter value obtained after the cluster processes the same access data within the same time period, and the numerical relationship between each parameter value.
[0100] The duration of the above second test adjustment period is the same as the sum of the durations of the previous M adjustment periods. Exemplarily, the electronic device can input the duration of the second test adjustment period and the second historical access data into X access models, so that the X access models simulate access to the second historical access data during the second test adjustment period, and obtain X fourth parameter values. Using the access model to simulate access to the second historical access data during the second test adjustment period with the same duration as the sum of the durations of the previous M adjustment periods can ensure that the cluster and the access model process the same access data within the same duration, that is, it can make the access model and the cluster in the same application scenario, thereby increasing the accuracy and reliability of the access model's simulated access.
[0101] S1033. Determine the target load balancing strategy from N load balancing strategies according to the X fourth parameter values of the cluster in the previous M adjustment periods.
[0102] Exemplarily, the electronic device can, based on the user's instruction, determine the load balancing strategy specified by the user as the target load balancing strategy. Or, the electronic device can also randomly select 1 fourth parameter value from the X fourth parameter values, and then determine the second load balancing strategy corresponding to the fourth parameter value as the target load balancing strategy.
[0103] Exemplarily, after obtaining the X fourth parameter values, the electronic device can determine the target load balancing strategy from N load balancing strategies according to the following several implementation methods.
[0104] Implementation method 1: When there is 1 fourth parameter value corresponding to a load balancing situation among the X fourth parameter values that is better than the load balancing situation corresponding to the third parameter value, the electronic device can use the load balancing strategy corresponding to the fourth parameter value as the target load balancing strategy.
[0105] Implementation method 2: When there are at least two load balancing situations corresponding to the fourth parameter values among the X fourth parameter values, and the load balancing situation is better than that corresponding to the third parameter value, the electronic device may determine the target load balancing strategy from the load balancing strategies corresponding to the at least two fourth parameter values according to the load balancing situation corresponding to the at least two fourth parameter values.
[0106] In this implementation method, exemplarily, the electronic device may, according to the load balancing situation corresponding to at least two fourth parameter values, use the load balancing strategy corresponding to the fourth parameter value with the best load balancing situation among the at least two fourth parameter values as the target load balancing strategy.
[0107] Exemplarily, the electronic device may also randomly select a load balancing strategy from the load balancing strategies corresponding to at least two fourth parameter values as the target load balancing strategy. Alternatively, the electronic device may also determine the load balancing strategy specified by the user as the target load balancing strategy based on the user instruction.
[0108] Implementation method 3: When the load balancing situations corresponding to all the fourth parameter values among the X fourth parameter values are lower than or equal to the load balancing situation corresponding to the third parameter value, the electronic device may use the first load balancing strategy as the target load balancing strategy.
[0109] In the cluster load balancing processing method provided in this application, when there is at least one load balancing strategy corresponding to the load balancing simulation situation of each node in the cluster in the previous adjustment period determined, and the load balancing simulation situation of each node is better than the actual situation, by comparing the actual situation and the simulation situation of the load balancing of each node in the previous M adjustment periods again, the load balancing strategy suitable for the cluster to use in the current adjustment period is determined more accurately.
[0110] Figure 5 It is a schematic structural diagram of a cluster load balancing processing device provided in an embodiment of this application. As Figure 5 shown, the device includes: an acquisition module 21, a processing module 22, a determination module 23, and a control module 24. Among them:
[0111] The acquisition module 21 is configured to acquire the first historical access data of the cluster in the previous adjustment period, and the first parameter value of the cluster in the previous adjustment period; the first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by using the first load balancing strategy in the previous adjustment period of the cluster;
[0112] A processing module 22, configured to input the first historical access data into N - 1 access models respectively, so as to obtain N - 1 second parameter values of the cluster in the previous adjustment period; each access model corresponds to one of the N load balancing policies except the first load balancing policy, and the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing policy in the first test adjustment period; the duration of the first test adjustment period is the same as that of the previous adjustment period;
[0113] A determination module 23, configured to determine a target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value;
[0114] A control module 24, configured to control the cluster to process access data using the target load balancing policy in the current adjustment period when the target load balancing policy is different from the first load balancing policy.
[0115] Optionally, the determination module 23 is specifically configured to, when there are X second parameter values among the N - 1 second parameter values whose corresponding load balancing situations are better than the load balancing situation corresponding to the first parameter value, determine the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values, where X is greater than or equal to 1 and less than or equal to N - 1.
[0116] For example, the determination module 23 is specifically configured to, when X is equal to 1, use the second load balancing policy corresponding to the second parameter value as the target load balancing policy; when X is greater than or equal to 2, determine the target load balancing policy from the second load balancing policies corresponding to the X second parameter values according to the load balancing situations corresponding to the X second parameter values. Exemplarily, the determination module 23 is specifically configured to, according to the load balancing situations corresponding to the X second parameter values, use the second load balancing policy corresponding to the second parameter value with the best load balancing situation among the X second parameter values as the target load balancing policy.
[0117] For another example, the determination module 23 is specifically configured to:
[0118] Obtain the second historical access data of the cluster in the previous M adjustment periods, and the third parameter value of the cluster in the previous M adjustment periods; the third parameter value is used to characterize the load balancing situation of each node in the cluster when processing the second historical access data of each period by adopting the load balancing policy corresponding to each period; M is greater than or equal to 2;
[0119] Input the second historical access data of the first M adjustment cycles of the cluster into X access models respectively to obtain X fourth parameter values of the cluster in the first M adjustment cycles; each access model in the X access models corresponds to a second load balancing policy; the fourth parameter value is used to characterize the load balancing situation of each node in the cluster when processing the second historical access data by adopting the corresponding second load balancing policy in the second test adjustment cycle; the duration of the second test adjustment cycle is the same as the sum of the durations of the first M adjustment cycles;
[0120] When there are Y second parameter values in the X fourth parameter values corresponding to a load balancing situation better than the load balancing situation corresponding to the third parameter value, determine the target load balancing policy according to the load balancing policies corresponding to the Y second parameter values, where Y is greater than or equal to 1 and less than or equal to X; or, when the load balancing situations corresponding to all the fourth parameter values in the X fourth parameter values are lower than or equal to the load balancing situation corresponding to the third parameter value, use the first load balancing policy as the target load balancing policy.
[0121] Exemplarily, the determining module 23 is specifically configured to, when Y = 1, use the load balancing policy corresponding to this fourth parameter value as the target load balancing policy; or, when Y is greater than or equal to 2, determine the target load balancing policy from the load balancing policies corresponding to the Y fourth parameter values according to the load balancing situations corresponding to the Y fourth parameter values. For example, the determining module 23 is specifically configured to, according to the load balancing situations corresponding to the Y fourth parameter values, use the load balancing policy corresponding to the fourth parameter value with the best load balancing situation among the Y fourth parameter values as the target load balancing policy.
[0122] Optionally, the determining module 23 is specifically configured to, when the load balancing situations corresponding to all the second parameter values in N - 1 second parameter values are lower than or equal to the load balancing situation corresponding to the first parameter value, use the first load balancing policy as the target load balancing policy.
[0123] Optionally, the control module 24 is specifically configured to send a load balancing policy switching request to the load balancer of the cluster, and the load balancing policy switching request includes: the identifier of the target load balancing policy.
[0124] The cluster load balancing processing device provided by this application is used to execute the foregoing embodiments of the cluster load balancing processing method. Its implementation principle and technical effects are similar, and will not be elaborated here. The cluster load balancing processing device may be, for example, the electronic device in the foregoing embodiment, or a component with processing functions in the electronic device, such as a chip with processing functions. The cluster load balancing processing device may also be, for example, the load balancer in the foregoing embodiment, or a component with processing functions in the load balancer, such as a chip with processing functions.
[0125] Figure 6 is a schematic structural diagram of an electronic device provided by an embodiment of this application. As Figure 6 shown, the electronic device 400 may include: at least one processor 401 and a memory 402.
[0126] The memory 402 is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions.
[0127] The memory 402 may include a high-speed random access memory (Random Access Memory, RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0128] The processor 401 is used to execute the computer execution instructions stored in the memory 402 to implement the cluster load balancing processing method described in the foregoing method embodiments. The electronic device may be, for example, the load balancer in the foregoing embodiment, or other independent devices with processing capabilities. Among them, the processor 401 may be a central processing unit (Central Processing Unit, CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0129] Optionally, the electronic device 400 may further include a communication interface 403. In a specific implementation, if the communication interface 403, the memory 402, and the processor 401 are implemented independently, the communication interface 403, the memory 402, and the processor 401 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0130] Optionally, in a specific implementation, if the communication interface 403, the memory 402, and the processor 401 are integrated on a single chip, the communication interface 403, the memory 402, and the processor 401 may communicate through an internal interface.
[0131] This application also provides a computer-readable storage medium, which may include: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a RAM memory, a magnetic disk, or an optical disc, etc., that can store program codes. Specifically, the computer-readable storage medium stores program instructions, and the program instructions are used for the method in the foregoing embodiments.
[0132] This application also provides a program product, which includes execution instructions stored in a readable storage medium. At least one processor of the electronic device may read the execution instructions from the readable storage medium, and the at least one processor executes the execution instructions to enable the electronic device to implement the cluster load balancing processing method provided by the foregoing various embodiments.
[0133] This application provides a cluster load balancing processing system, which includes a cluster and a load balancer. The load balancer supports N load balancing policies, where N is an integer greater than or equal to 2; the load balancer is used to execute the foregoing method embodiments to perform load balancing control on the cluster.
[0134] This application provides a cluster load balancing processing system, which includes a cluster, a load balancer, and an electronic device. The load balancer supports N load balancing policies, where N is an integer greater than or equal to 2; the electronic device is used to execute the foregoing method embodiments to control the load balancer to perform load balancing control on the cluster.
[0135] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for processing cluster load balancing, characterized in that, The cluster includes at least two nodes, the cluster supports N load balancing policies, where N is an integer greater than or equal to 2; the cluster adopted the first load balancing policy among the N load balancing policies in the previous adjustment cycle; the method includes: Obtain the first historical access data of the cluster in the previous adjustment cycle, and the first parameter value of the cluster in the previous adjustment cycle; the first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the first load balancing policy in the previous adjustment cycle; Input the first historical access data into N - 1 access models respectively to obtain N - 1 second parameter values of the cluster in the previous adjustment cycle; each access model corresponds to one load balancing policy except the first load balancing policy among the N load balancing policies, and the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing policy in the first test adjustment cycle; the duration of the first test adjustment cycle is the same as that of the previous adjustment cycle; Determine the target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value; If the target load balancing policy is different from the first load balancing policy, control the cluster to use the target load balancing policy to process access data in the current adjustment cycle.
2. The method according to claim 1, characterized in that, The determining the target load balancing policy from the N load balancing policies according to the N - 1 second parameter values and the first parameter value includes: If there are X second parameter values among the N - 1 second parameter values whose corresponding load balancing situations are better than the load balancing situation corresponding to the first parameter value, determine the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values, where X is greater than or equal to 1 and less than or equal to N - 1; Or, if the load balancing situations corresponding to all the second parameter values among the N - 1 second parameter values are lower than or equal to the load balancing situation corresponding to the first parameter value, use the first load balancing policy as the target load balancing policy.
3. The method according to claim 2, characterized in that, The determining the target load balancing policy according to the second load balancing policies corresponding to the X second parameter values includes: If X is equal to 1, use the second load balancing policy corresponding to this second parameter value as the target load balancing policy; If X is greater than or equal to 2, determine the target load balancing policy from the second load balancing policies corresponding to the X second parameter values according to the load balancing situations corresponding to the X second parameter values.
4. The method according to claim 3, characterized in that, The determining the target load balancing policy from the second load balancing policies corresponding to the X second parameter values according to the load balancing situations corresponding to the X second parameter values includes: Based on the load balancing situation corresponding to the X second parameter values, use the second load balancing strategy corresponding to the second parameter value with the best load balancing situation among the X second parameter values as the target load balancing strategy.
5. The method according to claim 2, characterized in that, The determining of the target load balancing strategy according to the second load balancing strategies corresponding to the X second parameter values includes: Obtain the second historical access data of the first M adjustment cycles of the cluster, and the third parameter values of the cluster in the first M adjustment cycles; the third parameter values are used to characterize the load balancing situation of each node in the cluster when processing the second historical access data of each cycle by adopting the load balancing strategy corresponding to each cycle within the first M adjustment cycles; M is greater than or equal to 2; Input the second historical access data of the first M adjustment cycles of the cluster into X access models respectively to obtain X fourth parameter values of the cluster in the first M adjustment cycles; each of the X access models corresponds to a second load balancing strategy; the fourth parameter values are used to characterize the load balancing situation of each node in the cluster when processing the second historical access data by adopting the corresponding second load balancing strategy within the second test adjustment cycle; the duration of the second test adjustment cycle is the same as the sum of the durations of the first M adjustment cycles; If there are Y second parameter values corresponding to the load balancing situation among the X fourth parameter values that are better than the load balancing situation corresponding to the third parameter values, then determine the target load balancing strategy according to the load balancing strategies corresponding to the Y second parameter values, where Y is greater than or equal to 1 and less than or equal to X; Or, if the load balancing situations corresponding to all the fourth parameter values among the X fourth parameter values are lower than or equal to the load balancing situation corresponding to the third parameter values, then use the first load balancing strategy as the target load balancing strategy.
6. The method according to claim 5, characterized in that, The determining of the target load balancing strategy according to the load balancing strategies corresponding to the Y second parameter values includes: If Y is equal to 1, then use the load balancing strategy corresponding to this fourth parameter value as the target load balancing strategy; If Y is greater than or equal to 2, then determine the target load balancing strategy from the load balancing strategies corresponding to the Y fourth parameter values according to the load balancing situations corresponding to the Y fourth parameter values.
7. The method according to claim 6, characterized in that, The determining of the target load balancing strategy from the load balancing strategies corresponding to the Y fourth parameter values according to the load balancing situations corresponding to the Y fourth parameter values includes: Based on the load balancing situations corresponding to the Y fourth parameter values, use the load balancing strategy corresponding to the fourth parameter value with the best load balancing situation among the Y fourth parameter values as the target load balancing strategy.
8. The method according to any one of claims 1-7, characterized in that, The controlling of the cluster to use the target load balancing strategy to process access data in the current adjustment cycle includes: Send a load balancing strategy switching request to the load balancer of the cluster, where the load balancing strategy switching request includes: the identifier of the target load balancing strategy.
9. A device for processing cluster load balancing, characterized in that, The cluster includes at least two nodes, and the cluster supports N load balancing policies, where N is an integer greater than or equal to 2; the cluster adopted the first load balancing policy among the N load balancing policies in the previous adjustment period; the apparatus includes: An obtaining module, configured to obtain the first historical access data of the cluster in the previous adjustment period, and the first parameter value of the cluster in the previous adjustment period; the first parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the first load balancing policy in the previous adjustment period of the cluster; A processing module, configured to input the first historical access data into N-1 access models respectively, to obtain N-1 second parameter values of the cluster in the previous adjustment period; each of the access models corresponds to one load balancing policy other than the first load balancing policy among the N load balancing policies, and the second parameter value is used to characterize the load balancing situation of each node in the cluster when processing the first historical access data by adopting the corresponding load balancing policy in the first test adjustment period; the duration of the first test adjustment period is the same as the duration of the previous adjustment period; A determining module, configured to determine a target load balancing policy from the N load balancing policies according to the N-1 second parameter values and the first parameter value; A control module, configured to control the cluster to use the target load balancing policy to process access data in the current adjustment period when the target load balancing policy is different from the first load balancing policy.
10. An electronic device, characterized in that,The electronic device includes: at least one processor and a memory; The memory stores computer execution instructions; The at least one processor executes the computer execution instructions stored in the memory, so that the electronic device executes the method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, Computer execution instructions are stored in the computer-readable storage medium, and when the computer execution instructions are executed by a processor, they are used to implement the method according to any one of claims 1-8.
Citation Information
Patent Citations
Nginx-based load balancing implementation method and apparatus, computer device, and storage medium
CN108965381A
Measuring responsiveness of a load balancing system
US20160261478A1