Load balancing method, apparatus, electronic device, storage medium and product
By determining the port priority and routing path of the NAT device cluster in the cloud computing data center network, and dynamically selecting NAT devices for data forwarding, the problem of uneven overall network traffic distribution in existing technologies is solved, flexible load balancing and failover are achieved, and the efficiency of the data center network is improved.
Patent Information
- Application Number
- CN202410340973.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-03-25
AI Technical Summary
Existing load balancing solutions in cloud computing data center networks only consider the traffic load balancing of switches, which cannot be applied to data center networks containing a large number of fixed destination network address translation and source network address translation rules, resulting in an uneven distribution of overall network traffic.
By responding to data forwarding requests from the NAT service, the set of devices in the NAT device cluster used for data forwarding is determined, the port priority information of each device is obtained, the priority of the routing path is determined, and data is forwarded through the routing path with the highest priority. The NAT device is flexibly selected to achieve load balancing, and dynamic adjustments are made when a device fails.
It enables flexible load balancing when service levels change, reduces network latency, improves the overall traffic distribution efficiency of data center networks, and is suitable for network environments with a large number of transition rules.
Smart Images

Figure CN118802762B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of cloud computing, and particularly relates to a load balancing method and device, electronic equipment, storage medium and product. BACKGROUND
[0002] In a cloud computing data center network, a Virtual Private Cloud (VPC) is a customizable, private and isolated network environment provided for users. In the process of communication with an external network, the VPC needs to provide a Network Address Translation (NAT) service for converting an internal address through a NAT gateway.
[0003] In a related load balancing scheme, load balancing is usually performed according to service load, network delay and other parameters after traffic reaches a switch. This load balancing scheme only considers load balancing of traffic out of the switch, and is only applicable to a network environment with a small scale or a network environment in which a single client is connected to multiple servers for NAT conversion. Therefore, the load balancing scheme cannot be applied to a data center network containing a large number of fixed destination Network Address Translation (SNAT) and source Network Address Translation (DNAT) conversion rules. Therefore, a load balancing method capable of reasonably distributing overall network traffic to different NAT devices is needed. SUMMARY
[0004] The present disclosure provides a load balancing method, device, electronic equipment, storage medium and product to solve the problems in the related art.
[0005] A first aspect embodiment of the present disclosure provides a load balancing method, which comprises:
[0006] In response to a first data forwarding request of a first NAT service, a first NAT device set for forwarding the first data in a NAT device cluster is determined based on a service level of the first NAT service contained in the first data forwarding request, wherein the first NAT service refers to a newly registered NAT service, and the service level is used to indicate the number of NAT devices for forwarding the first data;
[0007] Port priority information of each NAT device in the NAT device cluster is obtained;
[0008] Based on the port priority information of each first NAT device in the first NAT device set, a priority of a routing path corresponding to the port priority of each first NAT device is determined;
[0009] The first data is forwarded through the first NAT device corresponding to the routing path with the highest priority.
[0010] In some embodiments of the present disclosure, after the first data is forwarded by the first NAT device corresponding to the highest-priority routing path, the load balancing method provided by the present disclosure further comprises:
[0011] In the case where the highest-priority routing path fails, at least one second NAT device with a delay greater than a preset delay is selected from the first NAT device set, and a third NAT device with the lowest delay is selected;
[0012] A fourth NAT device corresponding to the highest-priority routing path in the at least one second NAT device is determined;
[0013] The priority of the routing path corresponding to the fourth NAT device is updated to the priority of the routing path corresponding to the third NAT device;
[0014] The first data is forwarded by the third NAT device.
[0015] In some embodiments of the present disclosure, in response to a first data forwarding request of a first NAT service, based on a service level of the first NAT service contained in the first data forwarding request, a first NAT device set for forwarding the first data in a NAT device cluster is determined, comprising:
[0016] In response to a first data forwarding request of a first NAT service, the calculation pressure corresponding to the current routing strategy is determined by using the Dinic algorithm, and it is judged whether the calculation pressure corresponding to the current routing strategy is less than a preset calculation pressure threshold;
[0017] If the judgment result is yes, based on the service level of the first NAT service contained in the first data forwarding request, a first NAT device set for forwarding the first data in a NAT device cluster is determined.
[0018] In some embodiments of the present disclosure, the port priority information of each NAT device in the NAT device cluster is obtained, comprising:
[0019] The priority information of each routing path in at least one routing path corresponding to each NAT device in the NAT device cluster and the service demand information of the second NAT service corresponding to each routing path are obtained;
[0020] Based on the priority information of the routing path corresponding to each NAT device, the priorities of all routing paths corresponding to each NAT device are summed to obtain a first priority coefficient corresponding to each NAT device;
[0021] Based on the service requirement information of the second NAT service corresponding to each routing path corresponding to each NAT device, the first priority coefficient corresponding to each NAT device, and the mask information of the IP address of each NAT device, the port priority information of each NAT device in the NAT device cluster is determined.
[0022] In some embodiments of the present disclosure, before obtaining the port priority information of each NAT device in the NAT device cluster, the load balancing method provided by the present disclosure further comprises:
[0023] Obtaining the first load information of each NAT device in the NAT device cluster;
[0024] After forwarding the first data through the first NAT device corresponding to the routing path with the highest priority, the load balancing method provided by the present disclosure further comprises:
[0025] Obtaining the port priority information of each first NAT device in the first NAT device set;
[0026] Based on the port priority information of each first NAT device and the first load information of each first NAT device, the second load information of each first NAT device is obtained;
[0027] Based on the second load information of each first NAT device and the first sum value, the actual usage rate of each first NAT device is determined; wherein the first sum value refers to the sum value of the highest priority item in the second NAT service priority information carried by each first NAT device.
[0028] In some embodiments of the present disclosure, obtaining the first load information of each NAT device in the NAT device cluster comprises:
[0029] Based on the expected usage rate of the NAT device at the next data forwarding request distribution time, the expected usage rate of the current NAT device, the actual usage rate of the NAT device, and the smoothing coefficient, an exponential smoothing model is constructed;
[0030] The smoothing coefficient is obtained by using a gradient descent algorithm;
[0031] Based on the smoothing coefficient and the exponential smoothing model, the first load information of each NAT device in the NAT device cluster is obtained.
[0032] In some embodiments of the present disclosure, selecting at least one second NAT device with a delay greater than a preset delay from the first NAT device set comprises:
[0033] Obtaining the delay of each first NAT device in the first NAT device set within a preset delay detection period;
[0034] obtain an average latency of the first NAT device in the preset latency detection period based on the latency of each first NAT device in the preset latency detection period;
[0035] select at least one second NAT device with a latency greater than the average latency from the first NAT device set.
[0036] A second aspect embodiment of the present disclosure provides a load balancing device, which comprises:
[0037] a first determination unit configured to determine a first NAT device set in a NAT device cluster for forwarding first data in response to a first data forwarding request of a first NAT service based on a service level of the first NAT service contained in the first data forwarding request; wherein the first NAT service refers to a newly registered NAT service, and the service level is used to indicate the number of NAT devices for forwarding the first data;
[0038] an obtaining unit configured to obtain port priority information of each NAT device in the NAT device cluster;
[0039] a second determination unit configured to determine a priority of a routing path corresponding to a port priority of each first NAT device in the first NAT device set based on the port priority information of each first NAT device in the first NAT device set;
[0040] a forwarding unit configured to forward the first data through the first NAT device corresponding to the routing path with the highest priority.
[0041] A third aspect embodiment of the present disclosure provides an electronic device, which comprises:
[0042] at least one processor; and a memory connected with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect embodiment of the present disclosure.
[0043] A fourth aspect embodiment of the present disclosure provides a non-transitory computer readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to perform the method described in the first aspect embodiment of the present disclosure.
[0044] A fifth aspect embodiment of the present disclosure provides a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement the method described in the first aspect embodiment of the present disclosure.
[0045] To sum up, the disclosure provides a load balancing method, device, electronic equipment, storage medium and product. The method comprises: in response to a first data forwarding request of a first NAT service, determining a first NAT device set for forwarding the first data in a NAT device cluster based on a service level of the first NAT service contained in the first data forwarding request; wherein the first NAT service refers to a newly registered NAT service, and the service level is used to indicate the number of NAT devices for forwarding the first data; obtaining port priority information of each NAT device in the NAT device cluster; determining the priority of a routing path corresponding to the port priority of each first NAT device based on the port priority information of each first NAT device in the first NAT device set; and forwarding the first data through the first NAT device corresponding to the routing path with the highest priority.
[0046] Through the scheme provided by the disclosure, in response to the first data forwarding request of the first NAT service in the network, by determining all NAT devices in the NAT device cluster that can forward the first data based on the service level of the first NAT service contained in the first data forwarding request, the port priority information of all first NAT devices that can forward the first data can be obtained by obtaining the port priority information of each NAT device in the NAT device cluster. By determining the priority of the routing path corresponding to the port priority of each first NAT device, the routing path that can forward the first data can be determined; by forwarding the first data through the first NAT device corresponding to the routing path with the highest priority, the NAT device for forwarding the first data can be flexibly selected when the service level changes, the load balancing of the ingress switch traffic can be realized, and the load balancing of the overall network traffic including the egress switch and the ingress switch can be realized.
[0047] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0048] The accompanying drawings incorporated in the specification and forming a part of it illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure without imposing undue limitation on the disclosure.
[0049] Figure 1 An application scenario diagram is provided for the embodiments of the disclosure.
[0050] Figure 2 A flowchart of the load balancing method is provided for the embodiments of the disclosure.
[0051] Figure 3 A flowchart of the load balancing method when the routing path with the highest priority fails is provided for the embodiments of the disclosure.
[0052] Figure 4 A flowchart of a method for determining port priority information of a NAT device according to an embodiment of the present disclosure is shown in FIG. 1.
[0053] Figure 5 A flowchart of a load balancing method according to an application example of the present disclosure is shown in FIG. 2.
[0054] Figure 6 A flowchart of a SNAT service flow path load balancing method according to an embodiment of the present disclosure is shown in FIG. 3.
[0055] Figure 7 A flowchart of a DNAT service flow path load balancing method according to an embodiment of the present disclosure is shown in FIG. 4.
[0056] Figure 8 A structural diagram of a load balancing device according to an embodiment of the present disclosure is shown in FIG. 5.
[0057] Figure 9 A hardware composition structural diagram of an electronic device according to an embodiment of the present disclosure is shown in FIG. 6. DETAILED DESCRIPTION
[0058] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, in which the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by reference to the accompanying drawings are exemplary and are intended to explain the present disclosure, and cannot be understood as a limitation of the present disclosure.
[0059] In a cloud computing data center network, a VPC is a customizable, private, and isolated network environment provided for users, and in the process of communication with an external network, a NAT gateway is needed to provide a NAT service to convert a cloud address.
[0060] In a related load balancing scheme, load balancing is usually performed according to service load, network delay, and other parameters after traffic reaches a switch, but the related load balancing scheme only considers load balancing of traffic out of the switch and does not consider load balancing of overall network traffic containing traffic into the switch. Therefore, a load balancing method is needed that can reasonably distribute overall network traffic to different NAT devices.
[0061] A scheme of a load balancing method in related technologies is briefly introduced below:
[0062] The scheme proposes to maintain a NAT rule table based on a data plane development kit (DPDK) environment. The hash value of the source and destination IP and port in the received data packet is calculated, and then the hash value is matched in the NAT rule table. If the IP and port information of the internal server is matched, the data is forwarded. If no match is found, the server with the largest remaining load in the environment is selected. The hash value is matched with the IP and port information of the server, and the NAT rule table is updated.
[0063] The above scheme has the following defects:
[0064] First, in the above scheme, although the load balancing is used as a consideration parameter of network load, the object of load balancing is only the traffic of the out-switch, and the overall network traffic containing the in-switch traffic is not considered.
[0065] Second, it is not applicable to data center networks that require fixed cloud IP conversion results.
[0066] In order to solve the problems existing in the related art, the present disclosure provides a load balancing method. In response to a first data forwarding request of a first NAT service existing in a network, all NAT devices in a NAT device cluster that can forward the first data can be determined based on the service level of the first NAT service contained in the first data forwarding request. By obtaining the port priority information of each NAT device in the NAT device cluster, the port priority information of all first NAT devices that can forward the first data can be obtained. By determining the priority of the routing path corresponding to the port priority of each first NAT device, the routing path that can forward the first data can be determined. By forwarding the first data through the first NAT device corresponding to the routing path with the highest priority, the NAT device that forwards the first data can be flexibly selected to achieve load balancing when the service level changes.
[0067] The load balancing method provided by the embodiments of the present disclosure can be applied to the scenario as shown in Figure 1 Figure 1 The network includes both the public network and the data center network. The data center network comprises a border gateway cluster, a NAT (Network Address Translation) cluster, a compute node cluster, and a management node cluster. The border gateway cluster can include multiple switch or router clusters, and both the border gateway cluster and the compute node cluster include data forwarding modules. The NAT cluster consists of multiple NAT devices, with NAT devices providing the same NAT service collectively forming a NAT tenant service cluster, operating between the compute node cluster and the border gateway cluster. When a tenant in the data center network needs to access the public network, the service request is first forwarded by the data forwarding module in the compute node cluster to a NAT device in the NAT tenant service cluster, and then the service request is sent to the public network via the data forwarding module in the border gateway cluster.
[0068] The present disclosure will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0069] like Figure 2 As shown, Figure 2 This is a flowchart illustrating the load balancing method provided in this embodiment of the disclosure. The load balancing method provided in this embodiment includes the following steps:
[0070] Step 201: In response to the first data forwarding request of the first NAT service, determine the set of first NAT devices in the NAT device cluster used for forwarding the first data based on the service level of the first NAT service contained in the first data forwarding request;
[0071] In one embodiment, the first NAT service refers to the newly registered NAT service.
[0072] In one embodiment, the NAT service is used to perform address translation between private and public networks.
[0073] In one embodiment, the NAT service includes SNAT service and DNAT service.
[0074] In one embodiment, the SNAT service is used to translate source IP addresses in the internal network into IP addresses that are routable on the public network.
[0075] In one embodiment, the DNAT service is used to translate the destination IP address of an external request into a specific IP address within the internal network.
[0076] In one embodiment, the first data forwarding request includes an outbound data forwarding request and an inbound data forwarding request.
[0077] In one embodiment, the service level is used to indicate the number of NAT devices that forward the first data.
[0078] In one embodiment, the service level of each first NAT service may be the same or different.
[0079] In an embodiment, the NAT device cluster is a cluster composed of all the NAT devices.
[0080] In an embodiment, the first NAT device set refers to a set of all the NAT devices carrying the first NAT service.
[0081] In an embodiment, each NAT device in the first NAT device set corresponds to a first NAT service with different service levels.
[0082] In step 202, port priority information of each NAT device in the NAT device cluster is obtained.
[0083] In an embodiment, the port priority information of the NAT device is used to indicate the priority order of the newly registered NAT service in forwarding data through the current NAT device, such as the newly registered NAT service usually being forwarded through the NAT device with high port priority.
[0084] In an embodiment, the port priority information of each NAT device can be obtained by obtaining the port priority information of each NAT service carried on each NAT device.
[0085] In step 203, the priority of the routing path corresponding to the port priority of each first NAT device in the first NAT device set is determined based on the port priority information of each first NAT device in the first NAT device set.
[0086] In an embodiment, the port priority information of each first NAT device in the first NAT device set can be obtained from the port priority information of each NAT device in the NAT device cluster.
[0087] In an embodiment, by determining the priority of the routing path corresponding to the port priority of each first NAT device, the first NAT device corresponding to the priority of the routing path can be quickly determined when determining the priority of the routing path.
[0088] In step 204, the first data is forwarded through the first NAT device corresponding to the routing path with the highest priority.
[0089] In an embodiment, each first NAT device in the first NAT device set can forward the first data, but usually the first data is forwarded through the first NAT device corresponding to the routing path with the highest priority.
[0090] In an embodiment, when the network environment changes, the aforementioned forwarding of the first data according to the routing information may cause problems such as sudden change of the NAT device load and sharp increase of the network delay.
[0091] In an embodiment, asFigure 3 As shown, after step 204, the load balancing method further comprises:
[0092] Step 301, in the case where the highest-priority routing path fails, selecting at least one second NAT device with a latency greater than a preset latency and a third NAT device with the lowest latency from the first set of NAT devices;
[0093] In an embodiment, the preset latency refers to a preset maximum latency that can satisfy load balancing.
[0094] In an embodiment, the latency refers to an average latency in a detection period.
[0095] In an embodiment, the second NAT device is a first NAT device with an average latency greater than the preset latency.
[0096] In an embodiment, the third NAT device is a first NAT device with the lowest average latency.
[0097] Step 302, determining a fourth NAT device corresponding to the highest-priority routing path in the at least one second NAT device;
[0098] In an embodiment, the fourth NAT device is a second NAT device corresponding to the highest-priority routing path.
[0099] In an embodiment, the fourth NAT device is a first NAT device with the highest priority but a larger average latency.
[0100] Step 303, updating the priority of the routing path corresponding to the fourth NAT device to be the priority of the routing path corresponding to the third NAT device;
[0101] In an embodiment, exchanging the priority of the routing path corresponding to the fourth NAT device and the priority of the routing path corresponding to the third NAT device, and the priority of the routing path corresponding to the third NAT device is the highest and the average latency is the lowest after the exchange.
[0102] Step 304, forwarding the first data through the third NAT device.
[0103] In an embodiment, the priority of the routing path corresponding to the third NAT device is the highest and the average latency is the lowest, so the first data is preferentially forwarded through the third NAT device.
[0104] In an embodiment, step 201 comprises:
[0105] In response to a first data forwarding request of the first NAT service, determining the calculation pressure corresponding to the current routing strategy by using the Dinic algorithm, and judging whether the calculation pressure corresponding to the current routing strategy is less than a preset calculation pressure threshold.
[0106] In an embodiment, the Dinic algorithm can be used to calculate the pressure of the data forwarding module in a period of time.
[0107] In an embodiment, the pre-designed calculation pressure threshold refers to the maximum calculation pressure that the current routing strategy can bear.
[0108] In an embodiment, if the calculation pressure corresponding to the current routing strategy is not less than the pre-designed calculation pressure threshold, the data forwarding needs to be completed by means of hardware.
[0109] In an embodiment, the Equal-Cost Multi-Path (ECMP) can be used to complete the data forwarding.
[0110] If the determination result is yes, based on the service level of the first NAT service contained in the first data forwarding request, a first NAT device set in the NAT device cluster for forwarding the first data is determined.
[0111] In an embodiment, if the calculation pressure corresponding to the current routing strategy is less than the pre-designed calculation pressure threshold, the data forwarding can be completed according to the load balancing method provided in the present disclosure.
[0112] In an embodiment, as shown in FIG. 2, step 202 comprises: Figure 4
[0113] Step 401: Obtain the priority information of each routing path corresponding to each NAT device in the NAT device cluster, and the service demand information of the second NAT service corresponding to each routing path.
[0114] In an embodiment, each NAT device can correspond to the priority information of one, two or multiple routing paths.
[0115] In an embodiment, the priority of each routing path corresponding to each NAT device can be the same or different.
[0116] In an embodiment, the second NAT service refers to the NAT service that has been carried on the NAT device.
[0117] In an embodiment, the service demand information includes tenant traffic demand information and host access demand information.
[0118] In an embodiment, the tenant traffic demand is the main factor affecting the load balancing of the NAT device in the network environment in the cloud-out direction.
[0119] In an embodiment, the host access demand is the main factor affecting the load balancing of the NAT device in the network environment in the cloud-in direction.
[0120] In an embodiment, the service requirement information refers to quantized information.
[0121] In step 402, the priority of all the routing paths corresponding to each NAT device is summed based on the priority information of the routing paths corresponding to each NAT device, to obtain a first priority coefficient corresponding to each NAT device.
[0122] In an embodiment, the routing paths corresponding to each NAT device are different, and thus the sum of the priorities of all the routing paths corresponding to each NAT device can also be different, i.e., the first priority coefficient corresponding to each NAT device can be different.
[0123] In step 403, the port priority information of each NAT device in the NAT device cluster is determined based on the service requirement information of the second NAT service corresponding to each routing path corresponding to each NAT device, the first priority coefficient corresponding to each NAT device, and the mask information of the IP address of each NAT device.
[0124] In an embodiment, the DNAT in the data center network provides a public IP for each tenant.
[0125] In an embodiment, for the purpose of saving public IP, the SNAT in the data center network allocates a public address for a tenant according to the network ID of the IP address of the tenant, i.e., the same network segment shares one public IP.
[0126] In an embodiment, the length of the network segment is determined by the mask of the IP address of the NAT device.
[0127] In an embodiment, the data port abnormal devices in the overall NAT cluster are excluded, and each NAT device in all the NAT service clusters is sorted according to the sum of the data port priorities, to find the N devices with the smallest sum of data port priorities.
[0128] In an embodiment, before step 202, the load balancing method further includes:
[0129] In step 201, first load information of each NAT device in the NAT device cluster is obtained.
[0130] In an embodiment, the first load information refers to the load information of the NAT services currently carried by each NAT device in the NAT device cluster.
[0131] In an embodiment, the initial first load information of each NAT device is the same, and the initial first load information is 0.
[0132] In an embodiment, the first load information of each NAT device in the NAT device cluster can be obtained by determining the load information of all NAT services on the current NAT device.
[0133] After the first data is forwarded by the first NAT device corresponding to the highest priority routing path, the load balancing method further comprises:
[0134] Obtaining port priority information of each first NAT device in the first NAT device set;
[0135] In an embodiment, the port priority information of the first NAT device refers to the priority information of all NAT services carried on the first NAT device.
[0136] In an embodiment, the port priority information of each first NAT device can be obtained by obtaining the priority information of each NAT service carried on the first NAT device.
[0137] Based on the port priority information of each first NAT device and the first load information of each first NAT device, second load information of each first NAT device is obtained;
[0138] In an embodiment, the second load information refers to the total load information of the load information of the NAT services already carried on the current first NAT device and the load information of the newly registered NAT services.
[0139] Based on the second load information of each first NAT device and the first sum value, an actual usage rate of each first NAT device is determined;
[0140] In an embodiment, the first sum value refers to the sum value of the highest priority item in the second NAT service priority information carried on each first NAT device.
[0141] In an embodiment, the actual usage rate refers to the percentage of the bandwidth actually provided by the device to the total load of the device, such as the actual usage rate of the first NAT device being the percentage of the first sum value of the first NAT device to the second load of the first NAT device.
[0142] In an embodiment, by calculating the actual usage rate of the NAT device, the consumption of the current NAT device resources can be evaluated.
[0143] In an embodiment, obtaining the first load information of each NAT device in the NAT device cluster comprises:
[0144] Based on the expected usage rate of the NAT device at the next data forwarding request distribution, the expected usage rate of the current NAT device, the actual usage rate of the NAT device, and the smoothing coefficient, an exponential smoothing model is constructed;
[0145] In an embodiment, the expected usage rate of the current NAT device is the expected usage rate of the NAT device after the last allocation of the data forwarding request.
[0146] In an embodiment, the initial value of the expected usage rate of each NAT device is the same before the first allocation of the data forwarding request, but as the increase of the NAT service containing the data forwarding request carried by each NAT device, the expected usage rate of each NAT device can be the same or different.
[0147] In an embodiment, the BP neural network can be used to obtain the smoothing coefficient.
[0148] In an embodiment, the Sigmoid function can be used as the activation function of the BP neural network.
[0149] In an embodiment, the initial activation value of the neuron is obtained based on the expected usage rate of the current NAT device.
[0150] In an embodiment, the loss function value is calculated based on the actual usage rate of the NAT device and the predicted value obtained by the BP neural network.
[0151] In an embodiment, in order to integrate the processing capacity of the NAT gateway cluster into the solution of the smoothing coefficient, the 2 in the standard loss function can be replaced by the number N of the NAT cluster devices in the present application.
[0152] In an embodiment, since the proportion of the host computing service in the cloud has an important influence on the load balancing of the NAT service, the proportion of the host computing service in the cloud can be quantified and applied to the Sigmoid function to achieve a more accurate load balancing strategy.
[0153] In an embodiment, in the exponential smoothing model, the expected usage rate of the NAT device is the sum of the product of the actual usage rate of the NAT device and the smoothing coefficient, and the product of the difference between the current expected usage rate of the NAT device and 1 and the smoothing coefficient.
[0154] The gradient descent algorithm is used to obtain the smoothing coefficient;
[0155] In an embodiment, the smoothing coefficient obtained by the gradient descent algorithm is the difference between the original smoothing coefficient and the product of the gradient descent step and the partial derivative of the loss function on the original smoothing coefficient.
[0156] Based on the smoothing coefficient and the exponential smoothing model, the first load information of each NAT device in the NAT device cluster is obtained.
[0157] In an embodiment, based on the smoothing coefficient and the exponential smoothing model, the expected usage rate of each NAT device in the NAT device cluster is obtained.
[0158] In an embodiment, the N NAT devices with the smallest sum of data port priorities in the preceding embodiments are arranged in order of increasing expected usage rate, and the port priority information of the NAT devices is corresponded one by one, the corresponding mode is that the highest priority corresponds to the device with the lowest expected usage rate, and then the first load information of each NAT device in the NAT device cluster is reacquired.
[0159] In an embodiment, at least one second NAT device with a delay greater than a preset delay is selected from the first NAT device set, including:
[0160] The delay of each first NAT device in the first NAT device set within a preset delay detection period is acquired.
[0161] In an embodiment, the preset delay detection period refers to a preset delay detection period, for example, the preset delay detection period is 60s.
[0162] In an embodiment, the preset delay detection period can be obtained from historical data of related delay detection documents, or can be obtained from multiple delay detection experiments.
[0163] In an embodiment, by acquiring the delay of each first NAT device in the first NAT device set within the preset delay detection period, the time required for each first NAT device from data request forwarding to receiving a response can be understood.
[0164] Based on the delay of each first NAT device within the preset delay detection period, the average delay of the first NAT device within the preset delay detection period is acquired.
[0165] In an embodiment, the average delay of the first NAT device within the preset delay detection period is the ratio of the sum of the delays of all first NAT devices within the preset delay detection period to the number of first NAT devices.
[0166] In an embodiment, the average delay of the first NAT device within the preset delay detection period is used to measure the average time required for the first NAT device from data request forwarding to receiving a response within the preset delay detection period.
[0167] At least one second NAT device with a delay greater than the average delay is selected from the first NAT device set.
[0168] In an embodiment, there can be one, two or more second NAT devices in the first NAT device set.
[0169] In summary, the scheme provided by the present disclosure has the following advantages:
[0170] First, in response to a first data forwarding request for a first NAT service existing in the network, all NAT devices in the NAT device cluster capable of forwarding the first data can be determined based on the service level of the first NAT service contained in the first data forwarding request. By obtaining the port priority information of each NAT device in the NAT device cluster, the port priority information of all first NAT devices capable of forwarding the first data can be obtained. By determining the priority of the routing path corresponding to the port priority of each first NAT device, the routing path capable of forwarding the first data can be determined. Forwarding the first data through the first NAT device corresponding to the highest priority routing path allows for flexible selection of the NAT device for forwarding the first data to achieve load balancing when the service level changes.
[0171] Secondly, by determining whether the computational pressure corresponding to the current routing policy is less than the preset computational pressure threshold, it can be determined whether hardware is needed to complete data forwarding, thereby reducing the workload of the data forwarding module.
[0172] Furthermore, by replacing 2 in the standard loss function with the number of NAT cluster devices N in this application, the processing capacity of the NAT gateway cluster can be incorporated into the solution of the smoothing coefficient.
[0173] The following application example further illustrates the load balancing method provided in this disclosure:
[0174] like Figure 5 As shown, Figure 5 This is a flowchart illustrating the load balancing method provided in this application example. The load balancing method provided in this application example includes the following steps:
[0175] Step 501: In response to the first data forwarding request of the first NAT service, the Dinic algorithm is used to determine the computational pressure corresponding to the current routing policy, and it is determined whether the computational pressure corresponding to the current routing policy is less than the preset computational pressure threshold.
[0176] If the judgment result is yes, proceed to step 502;
[0177] If the result is negative, proceed to step 503;
[0178] Step 502: Based on the service level of the first NAT service contained in the first data forwarding request, determine the set of first NAT devices in the NAT device cluster used to forward the first data.
[0179] Step 503: Use ECMP to perform hardware routing and forward the first data.
[0180] Step 504, constructing an exponential smoothing model based on the expected usage rate of the NAT device at the next data forwarding request distribution time, the expected usage rate of the current NAT device, the actual usage rate of the NAT device, and a smoothing coefficient;
[0181] Step 505, obtaining the smoothing coefficient by using a gradient descent algorithm;
[0182] Step 506, obtaining the first load information of each NAT device in the NAT device cluster based on the smoothing coefficient and the exponential smoothing model.
[0183] Step 507, obtaining the priority information of each routing path in at least one routing path corresponding to each NAT device in the NAT device cluster, and the service demand information of the second NAT service corresponding to each routing path;
[0184] Step 508, summing up the priorities of all routing paths corresponding to each NAT device based on the priority information of the routing path corresponding to each NAT device, to obtain a first priority coefficient corresponding to each NAT device;
[0185] Step 509, determining the port priority information of each NAT device in the NAT device cluster based on the service demand information of the second NAT service corresponding to each routing path corresponding to each NAT device, the first priority coefficient corresponding to each NAT device, and the mask information of the IP address of each NAT device.
[0186] Step 510, determining the priority of the routing path corresponding to the port priority of each first NAT device in the first NAT device set based on the port priority information of each first NAT device in the first NAT device set;
[0187] Step 511, forwarding the first data through the first NAT device corresponding to the routing path with the highest priority.
[0188] In an embodiment, after step 511, the load balancing method provided by the present disclosure also includes:
[0189] obtaining the port priority information of each first NAT device in the first NAT device set;
[0190] obtaining the second load information of each first NAT device based on the port priority information of each first NAT device and the first load information of each first NAT device;
[0191] determining the actual usage rate of each first NAT device based on the second load information of each first NAT device and the first sum;
[0192] In response to the highest priority routing path failing, obtain the latency of each first NAT device in the first NAT device set within a preset latency detection period;
[0193] In an embodiment, based on the latency of each first NAT device within the preset latency detection period, obtain the average latency of the first NAT device within the preset latency detection period;
[0194] Select at least one second NAT device with latency greater than the average latency and a third NAT device with the lowest latency from the first NAT device set;
[0195] Determine the fourth NAT device corresponding to the highest priority routing path in the at least one second NAT device;
[0196] Update the priority of the routing path corresponding to the fourth NAT device to the priority of the routing path corresponding to the third NAT device;
[0197] Forward the first data through the third NAT device.
[0198] In an embodiment, the SNAT service traffic path is as shown in Figure 6 When the data packet is sent from the tenant, i.e., VPC, to the data forwarding module, the data forwarding module selects a path for the data packet based on the routing algorithm and routing information, which can achieve the load balancing and fault switching functions.
[0199] In an embodiment, the DNAT service traffic path is as shown in Figure 7 The DNAT service traffic path also has the load balancing and fault switching functions.
[0200] In order to achieve the load balancing method provided by the embodiments of the present disclosure, the embodiments of the present disclosure also provide a load balancing device, as shown in Figure 8 The load balancing device 800 provided by the embodiments of the present disclosure includes: Figure 8 The load balancing device 800 provided by the embodiments of the present disclosure includes:
[0201] The first determination unit 801 is configured to, in response to a first data forwarding request of a first NAT service, determine a first NAT device set for forwarding the first data in a NAT device cluster based on a service level of the first NAT service contained in the first data forwarding request; wherein the first NAT service refers to a newly registered NAT service, and the service level is used to indicate the number of NAT devices for forwarding the first data.
[0202] The obtaining unit 802 is configured to obtain port priority information of each NAT device in the NAT device cluster;
[0203] The second determining unit 803 is configured to determine a priority of a routing path corresponding to a port priority of each first NAT device in the first NAT device set based on the port priority information of each first NAT device in the first NAT device set.
[0204] The forwarding unit 804 is configured to forward the first data through the first NAT device corresponding to the routing path with the highest priority.
[0205] In an embodiment, the load balancing apparatus 800 further comprises a first data forwarding unit, which is configured to:
[0206] In the case where the routing path with the highest priority fails, at least one second NAT device with a delay greater than a preset delay and a third NAT device with the lowest delay are selected from the first NAT device set;
[0207] A fourth NAT device corresponding to the routing path with the highest priority in the at least one second NAT device is determined;
[0208] The priority of the routing path corresponding to the fourth NAT device is updated to the priority of the routing path corresponding to the third NAT device;
[0209] The first data is forwarded through the third NAT device.
[0210] In an embodiment, the first determining unit 801 is specifically configured to:
[0211] In response to a first data forwarding request of the first NAT service, the Dinic algorithm is used to determine a calculation pressure corresponding to the current routing strategy, and it is determined whether the calculation pressure corresponding to the current routing strategy is less than a preset calculation pressure threshold;
[0212] If the determination result is yes, a first NAT device set in the NAT device cluster for forwarding the first data is determined based on a service level of the first NAT service contained in the first data forwarding request.
[0213] In an embodiment, the obtaining unit 802 is specifically configured to:
[0214] Obtain priority information of each routing path in at least one routing path corresponding to each NAT device in the NAT device cluster and service demand information of a second NAT service corresponding to each routing path;
[0215] Sum the priorities of all routing paths corresponding to each NAT device based on the priority information of the routing paths corresponding to each NAT device, to obtain a first priority coefficient corresponding to each NAT device;
[0216] Based on the service requirement information of the second NAT service corresponding to each routing path corresponding to each NAT device, the first priority coefficient corresponding to each NAT device, and the mask information of the IP address of each NAT device, the port priority information of each NAT device in the NAT device cluster is determined.
[0217] In an embodiment, the load balancing apparatus 800 further comprises a load information acquisition unit, configured to:
[0218] acquire the first load information of each NAT device in the NAT device cluster;
[0219] Correspondingly,
[0220] In an embodiment, the load balancing apparatus 800 further comprises a third determination unit, configured to:
[0221] acquire the port priority information of each first NAT device in the first NAT device set;
[0222] based on the port priority information of each first NAT device and the first load information of each first NAT device, obtain the second load information of each first NAT device;
[0223] based on the second load information of each first NAT device and the first sum value, determine the actual usage rate of each first NAT device; wherein the first sum value refers to the sum value of the highest priority item in the second NAT service priority information carried by each first NAT device.
[0224] In an embodiment, the load information acquisition unit is further configured to:
[0225] based on the expected usage rate of the NAT device at the next data forwarding request allocation time, the expected usage rate of the current NAT device, the actual usage rate of the NAT device, and the smoothing coefficient, construct an exponential smoothing model;
[0226] obtain the smoothing coefficient by using a gradient descent algorithm;
[0227] based on the smoothing coefficient and the exponential smoothing model, acquire the first load information of each NAT device in the NAT device cluster.
[0228] In an embodiment, the first data forwarding unit is further configured to:
[0229] acquire the latency of each first NAT device in the first NAT device set within a preset latency detection period;
[0230] based on the latency of each first NAT device within the preset latency detection period, obtain the average latency of the first NAT device within the preset latency detection period;
[0231] select at least one second NAT device with latency greater than the average latency from the first set of NAT devices.
[0232] It should be noted that the load balancing device 800 provided in the above embodiments is only used for load balancing, and the above division of the program modules is used as an example. In actual applications, the above processing can be completed by different program modules according to needs, that is, the internal structure of the load balancing device 800 is divided into different program modules to complete all or part of the above processing. In addition, the load balancing device 800 provided in the above embodiments and the load balancing method embodiments provided in the embodiments of the present disclosure belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0233] Figure 9 The hardware component structure diagram of the electronic device provided in the embodiments of the present disclosure is shown in FIG. 9. Figure 9 As shown in FIG. 9, the electronic device 900 includes at least one processor 902, and a memory 901 connected with the at least one processor 902 in communication. The memory 901 stores instructions executable by the at least one processor 902, and the instructions are executed by the at least one processor 902 to implement the steps of the load balancing method provided in the embodiments of the present disclosure.
[0234] Optionally, the electronic device can be the load balancing device of the embodiments of the present application, and the electronic device can implement the corresponding processes implemented by the load balancing device in each method of the embodiments of the present application. For brevity, details are not repeated here.
[0235] It can be understood that the electronic device further includes a communication interface 903. The various components in the electronic device are coupled together through a bus system 904. It can be understood that the bus system 904 is used to realize the connection and communication between the components. The bus system 904 includes a data bus, a power bus, a control bus and a status signal bus in addition to the data bus. However, for the purpose of clear illustration, all kinds of buses are marked as the bus system 904 in the Figure 9 .
[0236] It can be understood that the memory 901 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a ferromagnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example but not limitation, many forms of RAM can be used, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 901 described in the embodiments of the present application is intended to include, but not limited to, these and any other suitable type of memory.
[0237] The method disclosed in the embodiments of the present application can be applied to the processor 902 or implemented by the processor 902. The processor 902 can be an integrated circuit chip having a processing capability. In the implementation process, each step of the above method can be completed by the integrated logic circuit of hardware in the processor 902 or the instruction in the form of software. The processor 902 described above can be a general processor, a DSP, or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The processor 902 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiments of the present application, the hardware decoding processor can be directly embodied to execute the above method, or the combination of hardware and software modules in the decoding processor can be executed. The software module can be located in the storage medium, which is located in the memory 901, and the processor 902 reads the information in the memory 901 to complete the above method in combination with the hardware.
[0238] In the exemplary embodiments, the electronic device can be implemented by one or more ASICs (Application Specific Integrated Circuit), DSPs, PLDs (Programmable Logic Device), CPLDs (Complex Programmable Logic Device), FPGAs, general-purpose processors, controllers, MCUs, microprocessors (Microprocessor), or other electronic elements, for executing the above method.
[0239] The embodiments of the present application also provide a non-transitory computer readable storage medium storing computer instructions, which are used to make a computer execute the steps of the load balancing method provided by the embodiments of the present application.
[0240] Optionally, the computer readable storage medium can be applied to the load balancing device in the embodiments of the present application, and the computer instructions make the computer execute the corresponding processes implemented by the load balancing device in the various methods of the embodiments of the present application. For brevity, details are not described here.
[0241] The embodiments of the present application also provide a computer program product, which includes a computer program, and the computer program implements the steps of the load balancing method provided by the embodiments of the present application when executed by a processor.
[0242] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other manners. The above described device embodiments are merely exemplary. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the components shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0243] The units described as separate components above can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0244] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
[0245] Those of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by a program instructing related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program executes the steps of the above method embodiments when executed; and the foregoing storage medium includes mobile storage devices, ROM, RAM, magnetic discs or optical discs and various storage media that can store program codes.
[0246] Alternatively, the integrated unit of the present application, if implemented in the form of a software functional module and sold or used as an independent product, can also be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods of the embodiments of the present application. The foregoing storage medium includes mobile storage devices, ROM, RAM, magnetic discs or optical discs and various storage media that can store program codes.
[0247] The above merely illustrates the specific embodiments of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of the changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A load balancing method, characterized by, The method comprises the following steps: determining a first NAT device set for forwarding the first data in the NAT device cluster based on a service level of a first NAT service contained in the first data forwarding request in response to a first data forwarding request of the first NAT service; wherein the first NAT service refers to a newly registered NAT service; obtaining port priority information of each NAT device in the NAT device cluster; determining a priority of a routing path corresponding to the port priority of each first NAT device in the first NAT device set based on the port priority information of each first NAT device in the first NAT device set; forwarding the first data through the first NAT device corresponding to the routing path with the highest priority.
2. The method of claim 1, wherein, After the first data is forwarded through the first NAT device corresponding to the routing path with the highest priority, the method further comprises the following steps: in the case that the routing path with the highest priority fails, selecting at least one second NAT device with a delay greater than a preset delay and a third NAT device with the lowest delay from the first NAT device set; determining a fourth NAT device corresponding to the routing path with the highest priority in the at least one second NAT device; updating the priority of the routing path corresponding to the fourth NAT device to the priority of the routing path corresponding to the third NAT device; forwarding the first data through the third NAT device.
3. The method of claim 1, wherein, The step of determining the first NAT device set for forwarding the first data in the NAT device cluster based on the service level of the first NAT service contained in the first data forwarding request in response to the first data forwarding request of the first NAT service comprises the following steps: determining a calculation pressure corresponding to a current routing strategy by using the Dinic algorithm in response to the first data forwarding request of the first NAT service, and judging whether the calculation pressure corresponding to the current routing strategy is less than a preset calculation pressure threshold; if the judgment result is yes, determining the first NAT device set for forwarding the first data in the NAT device cluster based on the service level of the first NAT service contained in the first data forwarding request.
4. The method of claim 1, wherein, The step of obtaining the port priority information of each NAT device in the NAT device cluster comprises the following steps: obtaining priority information of each routing path in at least one routing path corresponding to each NAT device in the NAT device cluster and service demand information of a second NAT service corresponding to each routing path; summing up priorities of all routing paths corresponding to each NAT device based on the priority information of the routing paths corresponding to each NAT device to obtain a first priority coefficient corresponding to each NAT device; determining the port priority information of each NAT device in the NAT device cluster based on the service demand information of the second NAT service corresponding to each routing path corresponding to each NAT device, the first priority coefficient corresponding to each NAT device, and mask information of an IP address of each NAT device.
5. The method of claim 4, wherein, Before the step of obtaining the port priority information of each NAT device in the NAT device cluster, the method further comprises the following steps: obtaining first load information of each of the NAT devices in the NAT device cluster; after the first data is forwarded by the first NAT device corresponding to the route path with the highest priority, the method further comprises: obtaining port priority information of each of the first NAT devices in the first NAT device set; obtaining second load information of each of the first NAT devices based on the port priority information of each of the first NAT devices and the first load information of each of the first NAT devices; determining actual usage rates of each of the first NAT devices based on the second load information of each of the first NAT devices and a first sum value, wherein the first sum value refers to a sum value of the highest priority items in the second NAT service priority information carried by each of the first NAT devices.
6. The method of claim 5, wherein, The obtaining of the first load information of each of the NAT devices in the NAT device cluster comprises: constructing an exponential smoothing model based on an expected usage rate of the NAT device at the next data forwarding request distribution, an expected usage rate of the NAT device at present, an actual usage rate of the NAT device and a smoothing coefficient; obtaining the smoothing coefficient by using a gradient descent algorithm; obtaining the first load information of each of the NAT devices in the NAT device cluster based on the smoothing coefficient and the exponential smoothing model.
7. The method of claim 2, wherein, The selection of at least one second NAT device with a time delay greater than a preset time delay from the first NAT device set comprises: obtaining a time delay of each of the first NAT devices in the first NAT device set within a preset time delay detection period; obtaining an average time delay of each of the first NAT devices in the first NAT device set within the preset time delay detection period based on the time delay of each of the first NAT devices within the preset time delay detection period; selecting at least one second NAT device with a time delay greater than the average time delay from the first NAT device set.
8. A load balancing apparatus, characterized by, The method comprises: a first determination unit configured to, in response to a first data forwarding request of a first NAT service, determine a first NAT device set in a NAT device cluster for forwarding the first data based on a service level of the first NAT service contained in the first data forwarding request, wherein the first NAT service refers to a newly registered NAT service; an obtaining unit configured to obtain port priority information of each NAT device in the NAT device cluster; a second determination unit configured to determine a priority of a route path corresponding to the port priority of each of the first NAT devices based on the port priority information of each of the first NAT devices in the first NAT device set; a forwarding unit configured to forward the first data by a first NAT device corresponding to the route path with the highest priority.
9. An electronic device, comprising: The method comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to execute the method of any one of claims 1 to 7.
11. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Message processing method and device, equipment and storage medium
CN112087533A
Session synchronization method and device, equipment and storage medium
CN115484272A