Load balancing method, device, equipment and storage medium based on core load
By dynamically adjusting the weight of the backend system IP, based on the changes in core load traffic, the problem of difficult to dynamically adjust the existing load balancing strategy is solved, achieving better load balancing effects and server load reduction.
Patent Information
- Application Number
- CN202211098366.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-08
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-09-08
AI Technical Summary
The existing load balancing strategies are difficult to adjust dynamically and cannot effectively deal with changes in real loads, resulting in poor load balancing effects and increasing server load.
By obtaining the client's service request and loading the service request to the backend system based on the pre-configured backend service's address and initial weight. Collect load data corresponding to service requests, count the core load traffic of each backend system IP, and judge whether weight updates are needed based on the core load traffic, and dynamically adjust the weights.
The dynamic load balancing strategy is implemented, the effect of load balancing is improved, the server load is reduced, and load changes can be better responded to.
Smart Images

Figure CN115643264B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of load balancing, and in particular to a load balancing method, device, equipment and storage medium based on core load. Background Art
[0002] Load balancing refers to the distribution of loads to multiple operating units, such as Web servers, FTP servers, enterprise key application servers, and other mission-critical servers, so as to complete work tasks together. With the popularization of informatization, system integration has put forward the load balancing requirements for back-end services in the enterprise service bus system. The common load balancing strategies are polling, weighted polling, random access, weighted random, and source address hash. The existing load balancing strategies all set fixed distribution strategies. Once set, they are difficult to modify and cannot change dynamically with the actual load execution, resulting in poor load balancing effects and increased server load. Summary of the invention
[0003] The purpose of the embodiments of the present application is to propose a load balancing method, device, equipment and storage medium based on core load to implement a dynamic load balancing strategy, improve the load balancing effect and reduce server load.
[0004] In order to solve the above technical problems, the embodiment of the present application provides a load balancing method based on core load, including:
[0005] Obtaining a service request from a client, and based on a pre-configured address and initial weight of a backend service, loading the service request to a backend system;
[0006] Collecting the load data corresponding to the service request through a service processing data collection component;
[0007] When the backend system completes processing the service request, it generates response data and returns the response data to the client;
[0008] Counting the core load flow of each backend system IP in the load data, and judging whether weight update is required based on the core load flow, to obtain a first judgment result;
[0009] If the first judgment result is that weight update is required, the IP weight to be updated is determined, and the IP weight to be updated is updated.
[0010] Further, the counting of the core load flow of each backend system IP in the load data, and judging whether weight update is required based on the core load flow, to obtain a first judgment result, includes:
[0011] Counting the traffic of each backend system IP in the load data;
[0012] Obtaining an initial weight corresponding to each of the backend system IPs, and dividing the core load flow by the initial weight to obtain a core load flow data set, wherein the core load flow data includes the core load flow data corresponding to each of the backend system IPs;
[0013] Obtaining the maximum nuclear load flow in the nuclear load flow data set, and determining a benchmark nuclear load flow based on the maximum nuclear load flow;
[0014] The first judgment result is obtained by judging whether the reference core load flow is less than any core load flow in the core load flow data set to judge whether weight update is required.
[0015] Furthermore, the counting of traffic of each backend system IP in the load data includes:
[0016] Determine the statistical window period;
[0017] From the load data, obtain the single service request size and request number of each backend system IP within the statistical window period;
[0018] For any of the backend system IPs, the size of the single service request is multiplied by the number of requests to obtain the traffic of the backend system IP.
[0019] Further, the obtaining the maximum core load flow in the core load flow data set and determining a reference core load flow based on the maximum core load flow includes:
[0020] Obtaining the maximum nuclear load flow in the nuclear load flow data set by traversal;
[0021] Obtaining an initial weight corresponding to the maximum nuclear load flow as a basic weight, and dividing the maximum nuclear load flow by the basic weight to obtain a nuclear load deviation;
[0022] The maximum nuclear load flow rate minus the nuclear load deviation is used as the reference nuclear load flow rate.
[0023] Further, the determining whether the reference core load flow is less than any core load flow in the core load flow data set to determine whether weight update is required to obtain the first determination result includes:
[0024] Determine whether the reference core load flow is less than any core load flow in the core load flow data set to obtain a second determination result;
[0025] If the second judgment result is that the reference core load flow is less than any core load flow in the core load flow data set, then the first judgment result is that weight update is required;
[0026] If the second judgment result is that the benchmark core load flow is not less than any core load flow in the core load flow data set, then the first judgment result is that no weight update is required, and the weight update calculation is postponed to the next statistical window period.
[0027] Further, the IP weight to be updated includes a first IP weight to be updated and a second IP weight to be updated, and if the first judgment result is that a weight update is required, the IP weight to be updated is determined, and the IP weight to be updated is updated, including:
[0028] If the first judgment result is that weight update is required, the initial weight corresponding to the reference core load flow is used as the first weight to be updated;
[0029] In the core load flow data set, the core load flows except the maximum core load flow are taken as basic core load flows to obtain a basic core load flow set, wherein the basic core load flow set includes a plurality of the basic core load flows;
[0030] Taking the initial weight corresponding to the basic core load flow as a comparison weight, and for each basic core load flow, dividing the basic core load flow by the comparison weight to obtain a comparison core load deviation;
[0031] Adding any of the basic core load flows to the comparison core load deviation to obtain a new core load flow set, and obtaining the minimum new load flow in the new core load flow set;
[0032] Using the initial weight corresponding to the minimum new load flow as the second weight to be updated;
[0033] The first weight to be updated is reduced by a preset weight value, and the second weight to be updated is increased by the preset weight value, so as to update the IP weight to be updated.
[0034] Further, the obtaining of the service request from the client and, based on the pre-configured address and initial weight of the backend service, loading the service request to the backend system includes:
[0035] Obtaining the service request of the client, and obtaining the pre-configured address and initial weight of the backend service;
[0036] Parse the service request to obtain the backend system IP corresponding to the service request from the address of the backend service, obtain the target backend system IP, and obtain the initial weight corresponding to the target backend system IP as the target weight;
[0037] Based on the target backend system IP and the target weight, the service request is loaded to the backend system.
[0038] In order to solve the above technical problems, the embodiment of the present application provides a load balancing device based on core load, including:
[0039] A service request acquisition module, used to acquire the service request from the client and load the service request to the backend system based on the address and initial weight of the pre-configured backend service;
[0040] A load data collection module, used to collect the load data corresponding to the service request through a service processing data collection component;
[0041] A response data returning module, used for generating response data and returning the response data to the client when the back-end system completes processing of the service request;
[0042] A weight update judgment module, used to count the core load flow of each backend system IP in the load data, and judge whether the weight needs to be updated based on the core load flow to obtain a first judgment result;
[0043] The weight updating module is used to determine the IP weight to be updated and update the IP weight to be updated if the first judgment result is that weight updating is required.
[0044] In order to solve the above technical problems, the embodiment of the present application provides a load balancing device based on core load, including:
[0045] A service request acquisition module, used to acquire the service request from the client and load the service request to the backend system based on the address and initial weight of the pre-configured backend service;
[0046] A load data collection module, used to collect the load data corresponding to the service request through a service processing data collection component;
[0047] A response data returning module, used for generating response data and returning the response data to the client when the back-end system completes processing of the service request;
[0048] A weight update judgment module, used to count the core load flow of each backend system IP in the load data, and judge whether the weight needs to be updated based on the core load flow to obtain a first judgment result;
[0049] The weight updating module is used to determine the IP weight to be updated and update the IP weight to be updated if the first judgment result is that weight updating is required.
[0050] To solve the above technical problems, a technical solution adopted by the present invention is: to provide a computer device, including one or more processors; a memory for storing one or more programs, so that one or more processors can implement any one of the above-mentioned core load-balancing methods.
[0051] To solve the above technical problems, a technical solution adopted by the present invention is: a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements any one of the above-mentioned core load-based load balancing methods.
[0052] The embodiment of the present invention provides a load balancing method, device, equipment and storage medium based on core load. The method includes: obtaining the service request of the client, and based on the address and initial weight of the pre-configured back-end service, loading the service request to the back-end system; collecting the load data corresponding to the service request through the service processing data acquisition component; when the back-end system completes the service request, generating response data, and returning the response data to the client; counting the core load flow of each back-end system IP in the load data, and judging whether the weight needs to be updated based on the core load flow, to obtain a first judgment result; if the first judgment result is that the weight needs to be updated, then determining the weight of the IP to be updated, and updating the weight of the IP to be updated. The embodiment of the present invention collects the load data of the back-end system, and counts the load data when completing the service request to judge whether the weight needs to be updated, thereby realizing a dynamic load balancing strategy, improving the effect of load balancing, and helping to reduce the server load. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0054] Figure 1 This is a flow chart of an implementation of a load balancing method based on core load provided in an embodiment of the present application;
[0055] Figure 2 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0056] Figure 3 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0057] Figure 4 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0058] Figure 5 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0059] Figure 6 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0060] Figure 7 It is another implementation flow chart of a sub-process in the load balancing method based on core load provided in an embodiment of the present application;
[0061] Figure 8 is a schematic diagram of a load balancing device based on core load provided in an embodiment of the present application;
[0062] Fig. 9 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0064] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0065] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0066] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0067] It should be noted that the core load-based load balancing method provided in the embodiment of the present application is generally executed by an enterprise service bus, and accordingly, the core load-based load balancing device is generally configured in the enterprise service bus.
[0068] See also Figure 1 , Figure 1 A specific implementation of a load balancing method based on core load is shown.
[0069] It should be noted that if there are substantially the same results, the method of the present invention is not limited to Figure 1 The process sequence shown is limited to the following steps:
[0070] S1: Get the client's service request and load the service request to the backend system based on the pre-configured backend service address and initial weight.
[0071] Specifically, the embodiment of the present application is based on weighted polling load, and during the load process, the load of the back-end service is monitored by statistics, and then the weight is dynamically adjusted. Furthermore, before step S1, the embodiment of the present application also includes configuring the address and initial weight of the back-end service through the console through the enterprise service bus. The client requests the enterprise service bus system so that the enterprise service bus obtains the client's service request, and based on the pre-configured address and initial weight of the back-end service, loads the service request to the back-end system. Among them, the enterprise service bus, that is, ESB, stands for Enterprise Service Bus, which refers to the product of the combination of traditional middleware technology and technologies such as XML and Web services. ESB provides the most basic connection center in the network and is an essential element in building the enterprise nervous system.
[0072] See also Figure 2 , Figure 2 A specific implementation of step S1 is shown, which is described in detail as follows:
[0073] S11: Obtain the service request from the client, and obtain the address and initial weight of the pre-configured backend service.
[0074] S12: Parse the service request to obtain the backend system IP corresponding to the service request from the address of the backend service, obtain the target backend system IP, and obtain the initial weight corresponding to the target backend system IP as the target weight.
[0075] S13: Based on the target backend system IP and target weight, the service request is loaded to the backend system.
[0076] Specifically, since the address and initial weight of the backend service are pre-configured, when the customer's service request is obtained, the service request is parsed, so as to obtain the backend system IP corresponding to the service request from the address of the configured backend service, obtain the target backend system IP, and then obtain the initial weight corresponding to the target backend system IP as the target weight.
[0077] S2: Collect the load data corresponding to the service request through the service processing data collection component.
[0078] Specifically, the enterprise service bus system sends the load data of this call to the service processing data collection component, so that the service processing data collection component collects the load data corresponding to the service request. The service processing data collection component can be Scribe, Chukwa, Kafka, or Flume.
[0079] S3: When the backend system completes processing of the service request, it generates response data and returns the response data to the client.
[0080] Specifically, the service request is processed by the backend system. After the processing is completed, the backend system returns response data. The enterprise service bus system encapsulates the response data and sends the encapsulated response data to the client.
[0081] S4: Count the core load flow of each backend system IP in the load data, and determine whether weight update is required based on the core load flow to obtain a first determination result.
[0082] Specifically, since the service processing data collection component has collected the load data of this service call, it is determined whether the weight of the backend system IP needs to be updated by performing statistical analysis on the load data.
[0083] See also Figure 3 , Figure 3 A specific implementation of step S4 is shown, which is described in detail as follows:
[0084] S41: Count the traffic of each backend system IP in the load data.
[0085] See also Figure 4 , Figure 4 A specific implementation of step S41 is shown, which is described in detail as follows:
[0086] S411: Determine the statistical window period.
[0087] S412: Obtain the single service request size and number of requests of each backend system IP within the statistical window period from the load data.
[0088] S413: For any backend system IP, multiply the size of a single service request by the number of requests to obtain the traffic of the backend system IP.
[0089] In the embodiment of the present application, the statistical window period of this service call is first determined, and the unit of the statistical window period is seconds. In the embodiment of the present application, the preset time period can be used as a statistical window period, and the preset time period can be set according to the actual situation, which is not limited here. Then, in the load data, the single service request size and the number of requests of each backend system IP within the statistical window period are counted; then for any backend system IP, the single service request size is multiplied by the number of requests to obtain the flow F of each backend system IP.
[0090] S42: Obtain an initial weight corresponding to each backend system IP, and divide the initial weight by the core load flow to obtain a core load flow data set, wherein the core load flow data includes the core load flow data corresponding to each backend system IP.
[0091] Specifically, since the initial weight of the backend system IP is preconfigured, the initial weight corresponding to each backend system IP of this call is obtained. Then, the core load flow data set is obtained by dividing the core load flow by the initial weight, wherein the core load flow data includes the core load flow data Fw corresponding to each backend system IP. The core load flow data refers to the data obtained by dividing the flow within the statistical window period of the service call by the initial weight of the backend system IP.
[0092] S43: Obtain the maximum core load flow in the core load flow data set, and determine a benchmark core load flow based on the maximum core load flow.
[0093] See also Figure 5 , Figure 5 A specific implementation of step S43 is shown, which is described in detail as follows:
[0094] S431: Obtain the maximum core load flow in the core load flow data set by traversal.
[0095] S432: Obtain an initial weight corresponding to the maximum core load flow as a basic weight, and divide the maximum core load flow by the basic weight to obtain a core load deviation.
[0096] S433: Subtract the core load deviation from the maximum core load flow to obtain a reference core load flow.
[0097] Specifically, the largest nuclear load flow Fwmax in the nuclear load flow data set is identified, and the initial weight of the nuclear load flow Fwmax is used as the basic weight W; then the largest nuclear load flow Fwmax is divided by the basic weight W, that is, Fwmax / W, to obtain the nuclear load deviation Fd, and finally the largest nuclear load flow Fwmax is subtracted from the nuclear load deviation Fd, that is, Fwmax-Fd, as the benchmark nuclear load flow Fwnew.
[0098] S44: Determine whether weight update is required by determining whether the reference core load flow is less than any core load flow in the core load flow data set, and obtain a first determination result.
[0099] See also Figure 6 , Figure 6 A specific implementation of step S44 is shown, which is described in detail as follows:
[0100] S441: Determine whether the reference core load flow is less than any core load flow in the core load flow data set to obtain a second determination result.
[0101] S442: If the second judgment result is that the reference core load flow is less than any core load flow in the core load flow data set, then the first judgment result is that weight update is required.
[0102] S443: If the second judgment result is that the benchmark core load flow is not less than any core load flow in the core load flow data set, then the first judgment result is that no weight update is required, and the weight update calculation is postponed to the next statistical window period.
[0103] Specifically, determine whether the benchmark core load flow Fwnew is less than any core load flow in the core load flow data set, and obtain a second judgment result. If the benchmark core load flow Fwnew is less than any core load flow in the core load flow data set, then the first judgment result is that weight update is required; if the second judgment result is that the benchmark core load Fwnew flow is not less than any core load flow in the core load flow data set, then the first judgment result is that weight update is not required, and this update is invalidated, and the weight update calculation is re-performed in the next statistical window period to re-determine whether weight update is required.
[0104] S5: If the first judgment result is that the weight needs to be updated, the IP weight to be updated is determined, and the IP weight to be updated is updated.
[0105] Specifically, if it is determined that a weight update is required, the weight of the IP to be updated in the backend system IP is determined, and then the weight of the IP to be updated is updated according to the corresponding preset weight value.
[0106] See also Figure 7 , Figure 7 A specific implementation of step S5 is shown, which is described in detail as follows:
[0107] S51: If the first judgment result is that weight update is required, the basic weight is used as the first weight to be updated.
[0108] S52: In the core load flow data set, the core load flows except the largest core load flow are taken as basic core load flows to obtain a basic core load flow set, wherein the basic core load flow set includes multiple basic core load flows.
[0109] S53: taking the initial weight corresponding to the basic core load flow as a comparison weight, and for each basic core load flow, dividing the basic core load flow by the comparison weight to obtain a comparison core load deviation;
[0110] S54: Add any basic core load flow and the comparison core load deviation to obtain a new core load flow set, and obtain the minimum new load flow in the new core load flow set.
[0111] S55: taking the initial weight corresponding to the minimum new load flow as the second weight to be updated;
[0112] S56: The first weight to be updated is reduced by a preset weight value, and the second weight to be updated is increased by a preset weight value, so as to update the IP weight to be updated.
[0113] Specifically, if the first judgment result is that the weight needs to be updated, the weights of the backend system IP with the largest load and the backend system IP with the smallest load need to be updated. Since the above steps have identified the weight corresponding to the backend system IP with the largest load, that is, the basic weight, the basic weight is used as the first weight to be updated. Then it is necessary to identify the weight corresponding to the backend system IP with the smallest load. The initial weight corresponding to the basic core load flow is used as the comparison weight, and for each basic core load flow, the basic core load flow is divided by the comparison weight to obtain the comparison core load deviation; any basic core load flow is added to the comparison core load deviation to obtain a new core load flow set, and the minimum new load flow in the new core load flow set is obtained, and then the minimum new load flow Fwnew in the new core load flow set is identified, and the initial weight corresponding to the minimum new load flow Fwnew is used as the second weight to be updated. Finally, the first weight to be updated is reduced by the preset weight value, and the second weight to be updated is increased by the preset weight value to update the weight of the IP to be updated. Among them, the preset weight value is set according to the actual situation and is not limited here. In a specific embodiment, the preset weight value is 1.
[0114] As shown in Table 1, in a specific embodiment, assuming that in a certain service request call, the initial weights W of the backend system IP are 2, 3, 4, and 4, respectively, and the traffic corresponding to each initial weight is 20, 24, 110, and 120, respectively, then the calculated core load traffic is 10, 8, 27.5, and 30, respectively. Therefore, the maximum core load traffic is 30, and the calculated core load deviation is 30 / 4=7.5, and the baseline core load traffic is 30-7.5=22.5; since the baseline core load traffic 22.5 is not the minimum core load traffic, it is determined that the weight needs to be updated, and the second weight to be updated 3 is identified, and the first weight to be updated is 4, and the first weight to be updated 4 is subtracted by 1, and the weight is 3; the second weight to be updated 3 is added by 1, and the weight is 4.
[0115]
[0116] Table 1
[0117] In this embodiment, the service request of the client is obtained, and based on the address and initial weight of the pre-configured backend service, the service request is loaded to the backend system; the load data corresponding to the service request is collected through the service processing data acquisition component; when the backend system completes processing the service request, response data is generated and the response data is returned to the client; the core load flow of each backend system IP in the load data is counted, and based on the core load flow, it is determined whether the weight needs to be updated to obtain a first judgment result; if the first judgment result is that the weight needs to be updated, the weight of the IP to be updated is determined, and the weight of the IP to be updated is updated. The embodiment of the present invention collects the load data of the backend system, and counts the load data when completing the service request to determine whether the weight needs to be updated, thereby realizing a dynamic load balancing strategy, improving the effect of load balancing, and helping to reduce server load.
[0118] Please refer to Figure 8 , as a response to the above Figure 1 The present application provides an embodiment of a load balancing device based on core load, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0119] like Figure 8 As shown, the core load-based load balancing device of this embodiment includes: a service request acquisition module 61, a load data collection module 62, a response data return module 63, a weight update judgment module 64 and a weight update module 65, wherein:
[0120] The service request acquisition module 61 is used to acquire the service request of the client and load the service request to the backend system based on the address and initial weight of the pre-configured backend service;
[0121] A load data collection module 62, used to collect load data corresponding to the service request through a service processing data collection component;
[0122] The response data returning module 63 is used to generate response data and return the response data to the client when the backend system completes processing the service request;
[0123] The weight update judgment module 64 is used to count the core load flow of each backend system IP in the load data, and judge whether the weight needs to be updated based on the core load flow to obtain a first judgment result;
[0124] The weight updating module 65 is used to determine the IP weight to be updated and update the IP weight to be updated if the first judgment result is that the weight update is required.
[0125] Furthermore, the weight update determination module 64 includes:
[0126] Traffic statistics unit, used to count the traffic of each backend system IP in the load data;
[0127] A core load flow data set generation unit is used to obtain an initial weight corresponding to each backend system IP, and divide the core load flow by the initial weight to obtain a core load flow data set, wherein the core load flow data includes the core load flow data corresponding to each backend system IP;
[0128] A reference nuclear load flow determination unit, used to obtain the maximum nuclear load flow in the nuclear load flow data set, and determine the reference nuclear load flow based on the maximum nuclear load flow;
[0129] The first judgment result generating unit is used to determine whether the reference core load flow is less than any core load flow in the core load flow data set to determine whether weight update is required to obtain a first judgment result.
[0130] Furthermore, the traffic statistics unit includes:
[0131] A statistical window period determination subunit, used to determine the statistical window period;
[0132] The service request data acquisition subunit is used to obtain the single service request size and number of requests of each backend system IP within the statistical window period from the load data;
[0133] The multiplication processing subunit is used to multiply the size of a single service request by the number of requests for any backend system IP to obtain the traffic of the backend system IP.
[0134] Further, the reference core load flow determination unit includes:
[0135] A maximum core load flow acquisition subunit is used to acquire the maximum core load flow in the core load flow data set by traversing;
[0136] The nuclear load deviation calculation subunit is used to obtain the initial weight corresponding to the maximum nuclear load flow as the basic weight, and divide the maximum nuclear load flow by the basic weight to obtain the nuclear load deviation;
[0137] The benchmark nuclear load flow rate production subunit is used to subtract the nuclear load deviation from the maximum nuclear load flow rate to obtain the benchmark nuclear load flow rate.
[0138] Furthermore, the first judgment result generating unit includes:
[0139] A second judgment result generating subunit is used to judge whether the reference core load flow is less than any core load flow in the core load flow data set to obtain a second judgment result;
[0140] A first situation processing subunit, configured to, if the second judgment result is that the reference core load flow is less than any core load flow in the core load flow data set, then the first judgment result is that weight update is required;
[0141] The second situation processing subunit is used to, if the second judgment result is that the benchmark core load flow is not less than any core load flow in the core load flow data set, then the first judgment result is that no weight update is required, and the weight update calculation is postponed to the next statistical window period.
[0142] Further, the weight updating module 65 includes:
[0143] A first weight to be updated determining unit, configured to use the initial weight corresponding to the reference core load flow as the first weight to be updated if the first judgment result is that the weight needs to be updated;
[0144] A basic core load flow set generating unit is used to use the core load flows except the largest core load flow in the core load flow data set as basic core load flows to obtain a basic core load flow set, wherein the basic core load flow set includes a plurality of basic core load flows;
[0145] A comparison core load deviation generating unit, used for taking the initial weight corresponding to the basic core load flow as the comparison weight, and for each basic core load flow, dividing the basic core load flow by the comparison weight to obtain a comparison core load deviation;
[0146] An addition processing unit, used for adding any basic core load flow and the comparison core load deviation to obtain a new core load flow set, and obtaining the minimum new load flow in the new core load flow set;
[0147] A second weight to be updated determining unit, configured to use the basic weight as the second weight to be updated;
[0148] The updated weight updating unit is used to reduce the first updated weight by a preset weight value and increase the second updated weight by a preset weight value, so as to update the updated IP weight.
[0149] Furthermore, the service request acquisition module 61 includes:
[0150] An initial weight configuration unit, used to obtain a service request from a client, and obtain an address and an initial weight of a pre-configured backend service;
[0151] A target weight determination unit is used to parse the service request to obtain the backend system IP corresponding to the service request from the address of the backend service, obtain the target backend system IP, and obtain the initial weight corresponding to the target backend system IP as the target weight;
[0152] The service request load unit is used to load the service request to the backend system based on the target backend system IP and target weight.
[0153] To solve the above technical problems, the present application also provides a computer device. Fig. 9 , Fig. 9 This is a basic structural block diagram of the computer device in this embodiment.
[0154] The computer device 7 includes a memory 71, a processor 72, and a network interface 73 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 7 having three components: a memory 71, a processor 72, and a network interface 73, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.
[0155] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.
[0156] The memory 71 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 71 can be an internal storage unit of the computer device 7, such as a hard disk or memory of the computer device 7. In other embodiments, the memory 71 can also be an external storage device of the computer device 7, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 7. Of course, the memory 71 can also include both the internal storage unit of the computer device 7 and its external storage device. In this embodiment, the memory 71 is generally used to store the operating system and various application software installed on the computer device 7, such as the program code of the load balancing method based on the core load, etc. In addition, the memory 71 can also be used to temporarily store various types of data that have been output or are to be output.
[0157] The processor 72 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 72 is generally used to control the overall operation of the computer device 7. In this embodiment, the processor 72 is used to run the program code stored in the memory 71 or process data, such as running the program code of the load balancing method based on the core load, so as to implement various embodiments of the load balancing method based on the core load.
[0158] The network interface 73 may include a wireless network interface or a wired network interface, and the network interface 73 is generally used to establish a communication connection between the computer device 7 and other electronic devices.
[0159] The present application also provides another implementation, namely, providing a computer-readable storage medium, which stores a computer program, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of a load balancing method based on core load as described above.
[0160] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0161] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A load balancing method based on core load, characterized in that: include: Obtaining a service request from a client, and based on a pre-configured address and initial weight of a backend service, loading the service request to a backend system; Collecting the load data corresponding to the service request through a service processing data collection component; When the backend system completes processing the service request, it generates response data and returns the response data to the client; Counting the core load flow of each backend system IP in the load data, and judging whether weight update is required based on the core load flow, to obtain a first judgment result; If the first judgment result is that weight update is required, determining the IP weight to be updated, and updating the IP weight to be updated; The IP weight to be updated includes a first IP weight to be updated and a second IP weight to be updated. If the first judgment result is that a weight update is required, the IP weight to be updated is determined, and the IP weight to be updated is updated, including: If the first judgment result is that the weight needs to be updated, the initial weight corresponding to the benchmark core load flow is used as the first IP weight to be updated; In the core load flow data set, the core load flows except the maximum core load flow are taken as basic core load flows to obtain a basic core load flow set, wherein the basic core load flow set includes a plurality of the basic core load flows; Taking the initial weight corresponding to the basic core load flow as a comparison weight, and for each basic core load flow, dividing the basic core load flow by the comparison weight to obtain a comparison core load deviation; Adding any of the basic core load flows to the comparison core load deviation to obtain a new core load flow set, and obtaining the minimum new load flow in the new core load flow set; Using the initial weight corresponding to the minimum new load flow as the second IP weight to be updated; The first IP weight to be updated is reduced by a preset weight value, and the second IP weight to be updated is increased by the preset weight value, so as to update the IP weight to be updated.
2. The load balancing method based on core load according to claim 1, characterized in that: The counting of the core load flow of each backend system IP in the load data, and judging whether weight update is required based on the core load flow, to obtain a first judgment result, includes: Counting the traffic of each backend system IP in the load data; Obtaining an initial weight corresponding to each of the backend system IPs, and dividing the core load flow by the initial weight to obtain a core load flow data set, wherein the core load flow data includes the core load flow data corresponding to each of the backend system IPs; Obtaining the maximum nuclear load flow in the nuclear load flow data set, and determining a benchmark nuclear load flow based on the maximum nuclear load flow; The first judgment result is obtained by judging whether the reference core load flow is less than any core load flow in the core load flow data set to judge whether weight update is required.
3. The load balancing method based on core load according to claim 2, characterized in that: The counting of the traffic of each backend system IP in the load data includes: Determine the statistical window period; From the load data, obtain the single service request size and request number of each backend system IP within the statistical window period; For any of the backend system IPs, the size of the single service request is multiplied by the number of requests to obtain the traffic of the backend system IP.
4. The load balancing method based on core load according to claim 2, characterized in that: The obtaining of the maximum core load flow in the core load flow data set and determining a reference core load flow based on the maximum core load flow includes: Obtaining the maximum nuclear load flow in the nuclear load flow data set by traversal; Obtaining an initial weight corresponding to the maximum nuclear load flow as a basic weight, and dividing the maximum nuclear load flow by the basic weight to obtain a nuclear load deviation; The maximum nuclear load flow rate minus the nuclear load deviation is used as the reference nuclear load flow rate.
5. The load balancing method based on core load according to claim 3, characterized in that: The determining whether the reference core load flow is less than any core load flow in the core load flow data set to determine whether weight update is required to obtain the first determination result includes: Determine whether the reference core load flow is less than any core load flow in the core load flow data set to obtain a second determination result; If the second judgment result is that the reference core load flow is less than any core load flow in the core load flow data set, then the first judgment result is that weight update is required; If the second judgment result is that the benchmark core load flow is not less than any core load flow in the core load flow data set, then the first judgment result is that no weight update is required, and the weight update calculation is postponed to the next statistical window period.
6. The load balancing method based on core load according to any one of claims 1 to 5, characterized in that: The obtaining of the service request from the client and loading the service request to the backend system based on the pre-configured address and initial weight of the backend service includes: Obtaining the service request of the client, and obtaining the pre-configured address and initial weight of the backend service; Parse the service request to obtain the backend system IP corresponding to the service request from the address of the backend service, obtain the target backend system IP, and obtain the initial weight corresponding to the target backend system IP as the target weight; Based on the target backend system IP and the target weight, the service request is loaded to the backend system.
7. A load balancing device based on core load, characterized in that: include: A service request acquisition module, used to acquire the service request from the client and load the service request to the backend system based on the address and initial weight of the pre-configured backend service; A load data collection module, used to collect the load data corresponding to the service request through a service processing data collection component; A response data returning module, used for generating response data and returning the response data to the client when the back-end system completes processing of the service request; A weight update judgment module, used to count the core load flow of each backend system IP in the load data, and judge whether the weight needs to be updated based on the core load flow to obtain a first judgment result; A weight updating module, configured to determine the IP weight to be updated and update the IP weight to be updated if the first judgment result is that a weight update is required; The IP weight to be updated includes a first IP weight to be updated and a second IP weight to be updated, and the weight updating module includes: a first to-be-updated weight determination unit, configured to use the initial weight corresponding to the reference core load flow as the first to-be-updated IP weight if the first judgment result is that the weight needs to be updated; A basic core load flow set generating unit, configured to use the core load flows other than the maximum core load flow in the core load flow data set as basic core load flows to obtain a basic core load flow set, wherein the basic core load flow set includes a plurality of the basic core load flows; a comparison core load deviation generating unit, configured to use the initial weight corresponding to the basic core load flow as a comparison weight, and for each basic core load flow, divide the basic core load flow by the comparison weight to obtain a comparison core load deviation; An addition processing unit, used for adding any of the basic core load flows and the comparison core load deviation to obtain a new core load flow set, and obtaining the minimum new load flow in the new core load flow set; A second to-be-updated weight determination unit, configured to use the initial weight corresponding to the minimum new load flow as the second to-be-updated IP weight; The updated weight updating unit is used to reduce the first IP weight to be updated by a preset weight value, and increase the second IP weight to be updated by the preset weight value, so as to update the IP weight to be updated.
8. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the load balancing method based on core load as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the core load-balancing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Load balancing method and load balancer
CN110233866A
Load balancing system, method, medium and device based on intelligent cloud platform
CN114157666A