CN114928615B - Load balancing method, device, equipment and readable storage medium - Google Patents

Load balancing method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN114928615B
CN114928615B CN202210555137.8A CN202210555137A CN114928615B CN 114928615 B CN114928615 B CN 114928615B CN 202210555137 A CN202210555137 A CN 202210555137A CN 114928615 B CN114928615 B CN 114928615B
Authority
CN
China
Prior art keywords
load balancing
host
load
balancing system
data packet
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210555137.8A
Other languages
Chinese (zh)
Other versions
CN114928615A (en
Inventor
庄煜东
郑斌斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wangsu Science and Technology Co Ltd
Original Assignee
Wangsu Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wangsu Science and Technology Co Ltd filed Critical Wangsu Science and Technology Co Ltd
Priority to CN202210555137.8A priority Critical patent/CN114928615B/en
Publication of CN114928615A publication Critical patent/CN114928615A/en
Application granted granted Critical
Publication of CN114928615B publication Critical patent/CN114928615B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1031Controlling of the operation of servers by a load balancer, e.g. adding or removing servers that serve requests

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a load balancing method, a device, equipment and a readable storage medium, wherein when a host is newly added in a load balancing system, a load balancer receives a data packet, if a five-tuple of the data packet does not exist in a mapping table, effective RSs for load balancing are determined from RSs of all hosts contained in the load balancing system, a target RS is selected from the effective RSs, and the data packet is sent to the target RS, so that the second load balancing is completed. By adopting the scheme, after the host is newly added each time, the load balancer determines the target RS from the effective RS and sends the data packet, so that the load balancer on the newly added host can generate a mapping table aiming at the existing service in sufficient time, the mapping relation between the quintuple and the RS of the existing service is recorded in the mapping table, the load balancer is prevented from sending the data packet of the existing service to the incorrect RS, and the purpose of improving the service quality is realized.

Description

Load balancing method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of load balancing technologies, and in particular, to a load balancing method, device, apparatus, and readable storage medium.
Background
With the development of cloud technology, the number of accesses faced by a server increases rapidly, and the server needs to have a capability of handling large-scale concurrent service accesses. For a server with a large load, the processing capability of a CPU and an I/O becomes a bottleneck soon, and the performance of a single server is always limited, so that the problem cannot be really solved by simply improving the performance of hardware. Therefore, multi-server and Load Balancing (LB) technology must be employed to meet the needs of large-scale concurrent service access.
Load balancing refers to: and a large amount of concurrent access or data traffic is shared to a plurality of real servers by using a load balancer, and the real servers are used for processing, so that the waiting time of a user for response is reduced. In the cloud platform, a Linux virtual Server (Linux Virtual Server, LVS) architecture is generally adopted by a Load Balancer (LB) of a front end and a background Real Server (RS) group. After receiving the service request from the client, the LB dispatches and forwards the service request to the RS according to a preset dispatching and forwarding strategy and a load balancing dispatching algorithm, and the RS processes the service request and returns a response result. However, LVS load balancing techniques suffer from the disadvantage that the performance overhead is large and the LB is susceptible to load spikes.
To overcome the problems of LVS load balancing techniques, the industry introduces a load balancing architecture for the fast data path (eXpress Data Path, XDP). However, based on the XDP architecture, when a host is newly added in a cluster, the connection of the ongoing traffic within the cluster is abnormally disconnected, and the abnormality is proportional to the number of newly added hosts, resulting in an ongoing traffic abnormality.
Disclosure of Invention
The application provides a load balancing method, a device, equipment and a readable storage medium, which solve the problem of influence on the existing service when a host is newly added to an XDP-based architecture by improving a load balancer, and realize the aim of improving service reliability.
In a first aspect, an embodiment of the present application provides a load balancing method, which is applied to a load balancer on a host in a load balancing system, where the method includes:
determining that a newly added host exists in a load balancing system, wherein the load balancing system comprises any one of a plurality of hosts, and each host is provided with the load balancing device and a real server RS;
receiving a data packet;
determining effective RS from the RS of each host included in the load balancing system, wherein the effective RS is the RS involved in the load balancing of the data packet of the existing service by the load balancing device before the host is newly added, and the existing service is the service which is being provided for the user by the load balancing system before the host is newly added;
Determining a target RS from the effective RSs;
and sending the data packet to the target RS.
In a second aspect, an embodiment of the present application provides a load balancing method, applied to a query device in a load balancing system, where the method includes:
receiving an announcement request sent by an RS (remote control) on a newly added host in the load balancing system, wherein the announcement request is used for indicating a virtual IP address VIP of the RS;
recording the VIP and an announcement time point, wherein the announcement time point is the time point when the query device receives the announcement request, the VIP and the announcement time point are used for determining whether the RS on the newly added host is converted into an effective RS, the effective RS in the load balancing system is the RS involved in load balancing the data packet of the existing service by the load balancing system, and the existing service is the service which is provided for the user by the load balancing system before the newly added host.
In a third aspect, an embodiment of the present application provides a load balancing apparatus, a load balancer integrated on a host in a load balancing system, the apparatus including:
a determining module, configured to determine that a newly added host exists in a load balancing system, where the load balancing system is a load balancing on any one of multiple hosts included in the load balancing system, and each host in the multiple hosts is deployed with a load balancing device and a real server RS;
The receiving module is used for receiving the data packet;
the processing module is used for determining effective RSs from RSs of all hosts included in the load balancing system, wherein the effective RSs are RSs involved in load balancing of data packets of existing services by the load balancing device before a host is newly added, the existing services are services which are provided for users by the load balancing system before the host is newly added, and target RSs are determined from the effective RSs;
and the sending module is used for sending the data packet to the target RS.
In a fourth aspect, an embodiment of the present application provides a load balancing apparatus, integrated on a query device in a load balancing system, where the apparatus includes:
the receiving and transmitting module is used for receiving an announcement request sent by an RS (remote control) on a newly added host in the load balancing system, wherein the announcement request is used for indicating a virtual IP address VIP of the RS;
and the processing module is used for recording the VIP and the notification time point, wherein the notification time point is the time point when the query equipment receives the notification request, the effective RS in the load balancing system is the RS involved in the load balancing of the load balancing system for the data packet of the existing service before the newly added host, and the existing service is the service which is provided for the user by the load balancing system before the newly added host.
In a fifth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory and a computer program stored on the memory and executable on the processor, which processor, when executing the computer program, causes the electronic device to carry out the method as described above in the first aspect or in the various possible implementations of the first aspect.
In a sixth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory and a computer program stored on the memory and executable on the processor, when executing the computer program, causing the electronic device to implement the method as described above in the second aspect or the various possible implementations of the second aspect.
In a seventh aspect, embodiments of the present application provide a computer readable storage medium having stored therein computer instructions which, when executed by a processor, are adapted to carry out the method according to the first aspect or the various possible implementations of the first aspect.
In an eighth aspect, embodiments of the present application provide a computer readable storage medium having stored therein computer instructions which, when executed by a processor, are adapted to carry out the method according to the above second aspect or the various possible implementations of the second aspect.
In a ninth aspect, an embodiment of the present application provides a load balancing system, including a switch, a plurality of hosts, and a query device, where the switch establishes a network connection with each of the plurality of hosts, and the query device establishes a network connection with each of the plurality of hosts, where:
the switch is used for executing load balancing so as to determine a target load balancer from the load balancers contained in the plurality of hosts and sending data packets;
a load balancer and a real server RS are deployed on each of the plurality of hosts, the load balancer being configured to perform the load balancing method as described above in the first aspect or various possible implementations of the first aspect.
The querying device is configured to perform the load balancing method as described above in the second aspect or various possible implementations of the second aspect.
In the load balancing method provided by the embodiment of the application, once a load balancer receives a data packet when the load balancer on each host in the load balancing system detects a newly added host in the load balancing system, if no quintuple of the data packet exists in the mapping table, effective RSs for load balancing are determined from RSs of each host contained in the load balancing system, a target RS is selected from the effective RSs, and the data packet is sent to the target RS, so that the second load balancing is completed. By adopting the scheme, after the host is newly added each time, the load balancer determines the target RS from the effective RS and sends the data packet, so that the load balancer on the newly added host has enough time to generate a mapping table aiming at the existing service, the mapping relation between the quintuple of the existing service and the RS is recorded in the mapping table, and the load balancer is prevented from sending the data packet of the existing service to the incorrect RS. That is, after the host is newly added, the load balancer on the host takes effect, but the RS does not participate in load balancing immediately, but after the mapping table of the load balancer on the newly added host stores the mapping relation between the five-tuple and the RS of all the existing services, the RS on the newly added host is used for load balancing, so that the data packet of the existing services after the new host is ensured to be sent to the correct RS, the purpose of improving the service quality is achieved, and meanwhile, a switch is not required to be changed, and the influence surface and the operation complexity are reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a load balancing system to which a load balancing method according to an embodiment of the present application is applicable;
FIG. 2 is a schematic diagram of an operation level of an XDP-based load balancing architecture on a host according to an embodiment of the present application;
fig. 3 is a flowchart of a load balancing method according to an embodiment of the present application;
fig. 4 is another flowchart of a load balancing method according to an embodiment of the present application;
fig. 5 is an application scenario schematic diagram of a load balancing method provided by an embodiment of the present application;
fig. 6 is a schematic diagram of a load balancing device according to an embodiment of the present application;
fig. 7 is a schematic diagram of another load balancing apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
With the development of cluster technology, load balancing is also being widely studied as a core of the cluster technology. The load balancing ensures that the load of the back-end servers is equivalent, and at the same time, the data packets belonging to the same connection need to be transmitted to the same back-end server. The five-tuple belonging to the same connected packet is the same.
Load balancing aims at providing a high-availability and high-performance cluster technology, and provides a cheap, effective and transparent method for expanding the bandwidth of a cluster, increasing the throughput of the cluster, enhancing the processing capacity of the cluster on network data and ensuring the high availability of services.
The existing four-layer load balancing technology uses an LVS architecture, is a load balancing technology based on TCP/IP, is realized through an IP virtual server (IP Virtual Server, IPVS) module and works in a kernel. LVS architecture suffers from the following drawbacks:
first, the performance overhead is severe.
Based on LVS architecture, the forwarding of the data packet can be realized only through the network card and the kernel system. From the design point of view, in order to ensure security and isolation, the operating system experiences when the data packet passes through the kernel: socket Buffer (SKB), socket lock, TCP (or UDP) … … protocol stack, kernel mode and user mode switching. Resulting in significant performance overhead. Meanwhile, the LVS architecture needs to ensure synchronization among all load balancers in the cluster, so that the traffic is abnormally increased and the performance overhead of the load balancers is high.
Second, the load balancer is susceptible to load surges.
Based on the LVS architecture, the possibility of equipment failure is increased when the data traffic is large due to high performance overhead. Therefore, in order to reduce the machine failure rate, by placing the load balancer and the RSs actually serving the backend on different hosts, the number of load balancers is less than the number of RSs, which makes the load balancer susceptible to load surges. This problem is exacerbated by the fact that packets go through a conventional linux network stack before being processed by the load balancer.
To overcome the problem of LVS load balancing technology, the industry introduces a load balancing architecture based on XDP implementation. In the architecture, the data packets are directly filtered or processed before entering the user mode, and compared with the LVS-based load balancing architecture, the XDP-based load balancing architecture has better performance. The XDP-based load balancing architecture has the following advantages:
a. timely and efficient data packet processing.
Under the XDP-based load balancing architecture, after a load balancer is started in a driver mode, the load balancer processes the data packet after the network card receives the data packet and before the kernel intercepts the data packet. During processing, the load balancer calls the berkeley packet filter (Berkeley Packet Filter, BPF) procedure uniformly for each inbound packet. If the network card has a plurality of queues, the load balancer calls the BPF program for each queue in parallel. Moreover, the BPF program for processing the data packet is lock-free, using a BPF map unique to each CPU. Based on the parallel mechanism, the performance of load balancing linearly expands with the number of the receiving queues of the network card.
b. Synchronization between the load balancers within the cluster need not be guaranteed.
The load balancing framework based on XDP adopts a consistent hash (hash) algorithm to replace the traditional load balancing algorithm, so that synchronization among all load balancers in a cluster is ensured by the load balancing framework based on LVS, and the problems of abnormal flow and high performance overhead of the load balancers can be avoided.
c. Providing a fast path
The XDP-based load balancing architecture provides a fast path for processing data packets at high speed, the load balancer and RS deployment run together on the same host, and no degradation in performance occurs. At the same time, the adaptability to load surge, host failure and maintenance is enhanced.
The same points of the XDP-based load balancing architecture and the LVS-based load balancing architecture are that: the load balancer needs a routing protocol with a switch of the machine room, such as an open shortest path first (Open Shortest Path First, OSPF) protocol, in order to notify the outside of a virtual IP address (VIP) of the load balancer. The client can then send the data packets to the corresponding load balancer in the cluster. And finally, the load balancer selects one RS from the plurality of RSs according to a load balancing algorithm and sends the data packet to the RS.
In general, an increase or decrease in the number of hosts in a cluster is unavoidable and frequently occurs when the cluster provides services to the outside. The actual use is found that: when a host is newly added in the cluster, the data packet originally sent to the RS A of the cluster is sent to the RS B, so that the ongoing service in the cluster is abnormal. Moreover, the proportion of anomalies increases as the number of newly added hosts increases.
To add machines to a cluster, industry has considered improvements to the switch. In practice, however, a switch is connected to a number of hosts, each with traffic. If the switch is changed, this means: when machines are needed to be added or replaced in the cluster due to the reasons of planning change, machine downtime and the like, if the change is realized, the flow of the whole cluster is needed to be backed up, otherwise, the ongoing business in the cluster is influenced, manpower and material resources are consumed, the business quality is poor, and customer complaints are caused. Wherein the ongoing traffic is called old traffic, existing traffic, etc., and the connection for transmitting the data packets of the ongoing traffic is called old connection.
Obviously, the existing load balancing architecture based on XDP can not add machines in the cluster, so that the expansibility and usability of the cluster are greatly limited.
Based on this, the embodiment of the application provides a load balancing method, a device, equipment and a readable storage medium, which are used for improving the load balancing device, so that the load balancing device has the function of inquiring the mounting duration of each RS, thereby solving the problem that when a new server is added on the basis of an XDP (X-ray data processing) architecture, the influence on the existing service is solved, and the aim of improving the service reliability is fulfilled without changing a switch.
Fig. 1 is a schematic diagram of a load balancing system to which the load balancing method according to the embodiment of the present application is applicable. Referring to fig. 1, the load balancing system includes a host 11, a query device 12, a switch 13, and a terminal device 14. A network connection is established between the querying device 12 and each host 11. A network connection is established between each host 11 and the switch 13, and a network connection is established between the terminal device 14 and the switch 13.
Hosts 11 are also referred to as machines, servers, etc., with XDP-based load balancers 111 and RS112 deployed on each host 11. The load balancer 111 has a function of querying VIPs of the RSs 112, and can acquire VIPs of the RSs 112 on the hosts 11 and notification time points of the VIPs by the querying device 12. Since the load balancer 111 and the RS12 are disposed on each host 11, VIP of the host 11, the load balancer 111 on the host 11, and VIP of the RS112 on the host 11 are the same.
The querying device 12, also called an IP watch component, may be a machine independent of the host 11, or may be a host 11, where the host 11 deploys the load balancer 111 and the RS112, and stores VIP of each host 11 and an announcement time point of VIP in the load balancing system. Each time the host 11 is newly added in the load balancing system, the RS112 of the newly added host 11 notifies the VIP to the querying device 12, and the querying device 12 records the VIP of the RS112 and the notification time point. It can be seen that the querying device 12 is configured to collect and record VIP and advertising points in time for each RS112 within the load balancing system. The notification time point is the time point of the newly added host 11.
The switch 13 is used to connect the terminal device 14 and the host 11 for the first load balancing. After receiving the data packet from the terminal device 14, the switch 13 selects one host 11 from the plurality of hosts 11 and transmits the data packet. After the load balancer 111 of the selected host 11 receives the data packet, the load balancing method provided by the embodiment of the application is executed to perform load balancing for the second time, select the target RS from the plurality of RSs 112, and send the data packet to the target RS.
The terminal device 14 may be hardware or software. When the terminal device 14 is hardware, the terminal device 14 is, for example, a mobile phone, a tablet computer, a personal computer, an electronic book reader, a laptop, a desktop computer, or the like, in which an android operating system, a microsoft operating system, a saint operating system, a Linux operating system, or an apple iOS operating system is installed. When the terminal device 14 is software, it may be installed in the above-listed hardware device, and in this case, the terminal device 14 is, for example, a plurality of software modules or a single software module, etc., the embodiment of the present application is not limited.
Referring to fig. 1, a load balancer 111 performs peer-to-peer interconnection with a switch 13 using Fast Reroute (FRR), quagga, etc., and notifies the switch 13 of VIP of the load balancer 111. The switch 13 then uses an Equal-cost-Cost Multipath Routing (ECMP) mechanism to select a target one of the VIP-advertised load balancers 111 and send the packet, thereby completing the first load balancing. When the load balancer 111 advertises VIPs to the switch 13, an open shortest path first (Open Shortest Path First, OSPF) routing protocol is generally used.
From the above, it can be seen that: in the embodiment of the present application, there are two VIP advertisements, one is that the load balancer 111 uses the OSPF routing protocol to advertise the VIP of the load balancer 111 to the outside, that is, to the switch 13 and the like. One is that RS112 advertises the VIP of RS112 to querying device 12.
After the first load balancing, the data packet reaches the load balancing 111 through the switch 13, and the load balancing 111 selects a target RS from RSs 112 on the host 11 included in the load balancing system, and sends the data packet to the target RS, thereby completing the second load balancing. To ensure that packets of the same service are sent to the same target RS, the load balancer 111 receives the first packet of a service and then uses a consistent hashing algorithm. And the consistent hash algorithm determines the target RS according to the five-tuple of the data packet, the VIP of each RS in the load balancing system, the number of the RSs and the like. After determining the target RS for the first packet of a service, the load balancer 111 records the mapping relationship between the quintuple of the first packet and the target RS in the local mapping table. Thus, after the subsequent load balancer 111 receives the data packet of the same service each time, the target RS can be determined according to the five-tuple query mapping table of the data packet.
That is, in the embodiment of the present application, after each time the load balancer 111 receives a data packet, it preferentially queries the mapping table according to the quintuple of the data packet, and if the quintuple of the data packet exists in the mapping table, it directly uses the RS corresponding to the quintuple as the target RS. And if the five-tuple of the data packet does not exist in the mapping table, determining an effective RS, and determining a target RS from the effective RSs.
By adopting the scheme, the load balancer preferentially searches the mapping table to determine the target RS when executing the load balancing for the second time each time, and only when the target RS cannot be determined in a mapping table inquiring mode, the target RS is determined from the effective RSs, so that performance consumption caused by repeatedly executing consistent hash is avoided.
Optionally, in the above embodiment, after determining the target RS from the valid RSs, the load balancer further adds a mapping relationship between the quintuple of the data packet and the target RS in the mapping table. Thus, each time a new mapping relationship between the five-tuple and the RS is determined, a record is newly added in the mapping table. Because the five-tuple of the data packets of the same service are the same, the target RS can be determined by directly inquiring the mapping table after the data packets of the same service are received later, and the consistent hash operation is not required to be executed, so that the speed is high and the performance consumption is low.
By adopting the scheme, the mapping relation between the five-tuple and the target RS is stored in the mapping table, so that the performance consumption caused by the subsequent repeated execution of the consistent hash can be avoided.
Optionally, in the above embodiment, when the load balancer determines the target RS from the valid RSs, the load balancer performs consistent hash operation according to VIP of the valid RS, five-tuple of the data packet, the number of valid RSs, and the like, so as to determine the target RS.
In addition, since the five-tuple groups of all the packets of the same service are the same, when the number of RSs in the load balancing system is unchanged, whichever load balancer 111 receives a packet can transmit a packet belonging to the same service to the same target RS. Thus, synchronization of the individual load balancers 111 within the load balancing system is not required.
When the host 11 is newly added in the load balancing system, it is equivalent to adding the load balancers 111 and the RS112 at the same time. The switch 13 performs the first load balancing determination to determine the target load balancer using the OSPF routing protocol, and it is highly likely that the packet will be sent to the load balancer 111 on the newly added host 11, and the mapping table of the load balancer 111 is empty.
The newly added host 11 causes a change in the number of RSs 112, which in turn causes a change in the result of the consistent hashing algorithm. Therefore, in the conventional XDP-based load balancing architecture, when the load balancer 111 receives a packet, and the packet is a packet of an existing service, the load balancer 111 determines that the target RS according to the consistent hashing algorithm is likely to be not the correct RS, for example, the load balancer 111 sends a packet that should be sent to RS a to RS b. After receiving the data packet, the RS b directly discards the data packet or feeds back Reset (RST) because there is no information such as five-tuple of the existing service on the RS b, which causes the existing service to be abnormal. Obviously, the first load balancing of the switch 13 and the second load balancing of the load balancer 111 lead to a surge in the proportion of existing traffic anomalies when the hosts 11 are newly added in the load balancing system.
It will be appreciated that: the existing service means that before the host 11 is newly added, at least one host 11 exists in the load balancing system, and the mapping table of the load balancer 111 on the host 11 has the corresponding relationship between the quintuple and the target RS of the service. For example, before a video service is added to a host 11, there are 3 hosts 11 in the load balancing system, and correspondingly, there are 3 load balancers in the load balancing system. And if the mapping relation between the quintuple of the video service and the target RS is recorded in the mapping table of all or part of the load equalizer, the video service is the existing service.
In the embodiment of the present application, each time the host 11 is newly added, the RS112 on the newly added host 11 reports VIP to the querying device 12, and the querying device 12 records VIP and notification time points of the RS112 on the newly added host 11. Moreover, each time the host 11 is newly added, the function of the load balancer 111 on the newly added host 11 is turned on, and the function of the RS112 on the newly added host 11 is turned on after a predetermined period of time has elapsed instead of the function of the RS112 on the newly added host 11. After the function of the RS112 on the newly added host 11 is turned on, the RS112 is considered when the load balancer 111 performs the consistent hash operation.
After the load balancer 111 receives the data packet, it determines, from the plurality of RSs 112, an RS112 whose mounting duration exceeds a preset duration as an effective RS112. Then, the target RS is determined from the effective RS112 and the data packet is transmitted. That is, after each new host 11 is added, the RS112 on the new host 11 does not immediately participate in the consistent hash algorithm, and participates in the consistent hash algorithm after a preset period of time. The mapping table of the load balancer 111 on the newly added host 11 is empty in the preset time period at the beginning. And after receiving the data packet each time, if the five-tuple of the data packet does not exist in the mapping table, performing consistent hash according to the effective RS112, the five-tuple of the data packet and the like, determining the target RS and transmitting the data packet. Meanwhile, the load balancer 111 on the newly added host 11 records the mapping relationship of the quintuple and the target RS in the mapping table.
In this way, after the new host 11 passes through the preset time, the mapping table of the load balancer 111 on the new host 11 records the mapping relationship between the quintuple and the target RS of all the packets of the existing service. After the preset duration, the RS112 on the newly added host 11 takes effect, and at this time, if the consistent hash algorithm is used to determine the target RS of the data packet of the existing service, an error is likely. However, the load balancer 111 preferentially refers to the mapping table for the packet of the existing service, and thus can determine the correct target RS. For the data packet of the new service, the load balancer 111 performs a consistent hashing algorithm to determine the target RS according to the RS112 that is currently in effect, the quintuple of the data packet of the new service, and the like, and adds a new record in the mapping table.
For the load balancer 111 on the original host 11 in the load balancing system, if there is a mapping relationship between the quintuple of the packet of the existing service and the target RS in the mapping table of the load balancer 111, the correct target RS can be determined by querying the mapping table. If the mapping relation between the quintuple of the data packet of the existing service and the target RS does not exist in the mapping table, the target RS can be determined and the data packet can be sent by executing consistent hash according to the effective RS112, the quintuple of the data packet and the like.
It should be understood that the number of hosts 11, querying devices 12, switches 13, and end devices 14 in fig. 1 is merely illustrative. In practical implementation, any number of hosts 11, querying devices 12, switches 13 and terminal devices 14 are deployed according to practical requirements.
Fig. 2 is a schematic diagram of an operation level of an XDP-based load balancing architecture on a host according to an embodiment of the present application. Referring to fig. 2, the working hierarchy on the host includes: network card drivers, load balancers, kernel (kernel) user processes, etc. The load balancer is an XDP-based load balancer, and the user process is a relevant process in a user state. When the RS on the host is an edge node in the content delivery network (Content Delivery Network, CDN), the user profile has a required cache and a share component, etc.
Referring to fig. 2, the host is enabled in the driver mode, and the packet processing is performed after the network card receives the packet and before the kernel intercepts the packet, so that the overhead caused by switching between the user mode and the kernel mode is avoided.
The load balancing method according to the embodiment of the present application will be described in detail below based on the load balancing system shown in fig. 1. Referring to fig. 3, fig. 3 is a flowchart illustrating a load balancing method according to an embodiment of the present application. The present embodiment is described in terms of a load balancer. The embodiment comprises the following steps:
301. the load balancer determines that there is a newly added host in the load balancing system.
The load balancer is a load balancer on any one of a plurality of hosts included in the load balancing system, and each of the plurality of hosts is provided with the load balancer and a real server RS. Because the load equalizer and the RS are deployed on each host, each new host is added, which means that the load equalizer and the RS are respectively added by one host.
In the embodiment of the present application, load balancing is performed twice, which is hereinafter referred to as first load balancing and second load balancing, where the first load balancing refers to selecting a target load balancer from load balancers of multiple hosts, and sending a data packet to the target load balancer. The second load balancing refers to that the target load balancer selects a target RS from the RSs of the plurality of hosts and sends a data packet to the target RS. The target load balancer and the target RS may be located on the same host or on different hosts.
In the embodiment of the application, after the load balancer is a newly added host, the load balancer on each host in the load balancing system. That is, each load balancer in the load balancing system includes a load balancer on an original host in the load balancing system and a load balancer on a newly added host, and after each load balancer detects the newly added host in the load balancing system, the load balancing method according to the embodiment of the present application is executed.
After the load balancer determines that the load balancing system is newly added with a host, once the load balancer receives a data packet from the switch, the load balancer is indicated to be a target load balancer.
302. The load balancer receives the data packet.
Illustratively, the switch performs a first load balancing, selects a target load balancer from the load balancers of the plurality of hosts, and sends the data packets to the target load balancer. Accordingly, the target load balancer receives the data packet. The data packet may be a service request initiated by a terminal device of the user, etc., and the target RS responds to the service request according to the data packet after receiving the data packet.
From the perspective of the switch, as in the conventional XDP-based load balancing architecture, performing the first load balancing using the OSPF routing protocol to determine the target load balancer is likely to send a packet to the load balancer on the newly added host, where the mapping table of the load balancer is empty. Of course, the switch is also likely to send packets to the load balancer on the original host.
303. The load balancer determines effective RSs from RSs of all hosts included in the load balancing system, wherein the effective RSs are RSs involved in load balancing of data packets of existing services by the load balancer before a new host is added, and the existing services are services which are provided for users by the load balancing system before the new host is added.
In the embodiment of the application, after each time a load balancer receives a data packet, a local mapping table is queried, and if no quintuple of the data packet exists in the mapping table, consistent hash operation is executed to determine a target RS. In the traditional XDP-based load balancing architecture, when a new host is added, the load balancing device executes consistent hash according to the five-tuple of the data packet, the VIP of all RSs in the load balancing system and the number of the RSs, so that the determined target RS is incorrect.
In the embodiment of the application, after each new host is added, the RS on the new host is not immediately effective, i.e. does not immediately participate in load balancing, but is used for load balancing after the mapping relation between the quintuple and the RS of all the existing services is stored in the mapping table of the load balancer on the new host.
Therefore, when the load balancer checks the mapping table and cannot determine the target RS to perform consistent hashing, the valid RS is determined from all RSs. It is possible that the active RS provides at least one RS of the existing service or does not provide the existing service. However, whether or not the existing service is provided, the effective RS is the RS involved in performing consistent hashing on the data packet of the existing service by the load balancer before the new host is added.
For example, in the load balancing system, there are 2 hosts, namely host 1 and host 2, where load balancers 1a and RS1b are deployed on host 1, and load balancers 2a and RS2b are deployed on host 2. Host 3 is newly added, and load balancers 3a and RS3b are deployed on host 3. The load balancer 1a stores a mapping table, the mapping table stores the corresponding relation between the five-tuple A and the RS2b, and the mapping tables on the load balancer 2a and the load balancer 3a are empty, i.e. the RS2b has provided services to the outside, and the RS1b has not provided services.
That is, before the host is newly added, there is an existing service, and the five-tuple of the data packet of the service is five-tuple a. Before the host is newly added, after the load balancer (the load balancer 1a or the load balancer 2 a) receives the data packet with the five-tuple as the five-tuple A for the first time, consistent hash is executed according to the VIP, the RS2b, the RS number and the like of the five-tuple A, RS b, and the target RS is determined to be RS2b. Obviously, before adding the host 3, the RS involved in the load balancer performing the consistent hash on the data packet of the existing service includes RS1b and RS2b. Thus, the active RS includes RS1b and RS2b.
304. And the load balancer determines a target RS from the effective RSs.
For example, the load balancer does not directly select the target RS from all RSs in the load balancing system, but determines the effective RS from all RSs, and then selects the target RS from the effective RSs.
For example, in the load balancing system, there are 2 hosts, namely host 1 and host 2, where load balancers 1a and RS1b are deployed on host 1, and load balancers 2a and RS2b are deployed on host 2. Host 3 is newly added, and load balancers 3a and RS3b are deployed on host 3. The load balancer 1a stores a mapping table, the mapping table stores the corresponding relation between the quintuple a and the RS2B, the mapping table on the load balancer 2a stores the corresponding relation between the quintuple B and the RS1B, and the mapping table on the load balancer 3a is empty. That is, before the host is newly added, there are two existing services, and the five-tuple of the data packets of the two services are respectively five-tuple a and five-tuple B.
Assuming that the switch performs load balancing for the first time to select the load balancer 1a, after the load balancer 1a receives the data packet, it is determined that the quintuple of the data packet is quintuple a. Therefore, the load balancer 1a determines that the target RS is RS2b according to the five-tuple query mapping table.
Assuming that the switch performs load balancing for the first time to select the load balancer 2a, after the load balancer 2a receives the data packet, it is determined that the quintuple of the data packet is quintuple a. However, since the mapping table is empty, the load balancer 2a determines that the RS is valid, which includes RS1b and RS2b. Then, the load balancer 2a executes a consistent hashing algorithm to determine that the target RS is RS2b.
Assuming that the switch performs load balancing for the first time to select the load balancer 3a, after the load balancer 3a receives the data packet, it is determined that the quintuple of the data packet is quintuple a. However, since the mapping table is empty, the load balancer 3a determines that the RS is valid, which includes RS1b and RS2b. After that, the load balancer 3a executes the consistent hashing algorithm to determine that the target RS is RS2b.
For another example, there are originally 100 hosts in the load balancing system, and when newly adding hosts, a batch of hosts is added, and the total number of the hosts is 10, so that there are 110 total hosts in the load balancing system, and the number of the RSs on the 100 hosts is 100 to 110. When a batch of hosts is added, the load balancer on each of the 110 hosts detects the newly added host. When a load balancer on any host receives a data packet, if a target RS cannot be determined by inquiring a mapping table, the load balancer determines an effective RS, and if the number of the RS is 1-90RS which is the RS involved in load balancing the data packet of the existing service before the host is newly added, the load balancer determines the target RS from the five-tuple of the data packet and the number of VIP and RS of each RS in the 90 RSs.
305. And the load balancer sends the data packet to the target RS.
In the embodiment of the application, the load balancer for sending the data packet, namely the target load balancer and the target RS are positioned on the same host or different hosts.
In the load balancing method provided by the embodiment of the application, once a load balancer receives a data packet when the load balancer on each host in the load balancing system detects a newly added host in the load balancing system, if no quintuple of the data packet exists in the mapping table, effective RSs for load balancing are determined from RSs of each host contained in the load balancing system, a target RS is selected from the effective RSs, and the data packet is sent to the target RS, so that the second load balancing is completed. By adopting the scheme, after the host is newly added each time, the load balancer determines the target RS from the effective RS and sends the data packet, so that the load balancer on the newly added host has enough time to generate a mapping table aiming at the existing service, the mapping relation between the quintuple of the existing service and the RS is recorded in the mapping table, and the load balancer is prevented from sending the data packet of the existing service to the incorrect RS. That is, after the host is newly added, the load balancer on the host takes effect, but the RS does not participate in load balancing immediately, but after the mapping table of the load balancer on the newly added host stores the mapping relation between the five-tuple and the RS of all the existing services, the RS on the newly added host is used for load balancing, so that the data packet of the existing services after the new host is ensured to be sent to the correct RS, the purpose of improving the service quality is achieved, and meanwhile, a switch is not required to be changed, and the influence surface and the operation complexity are reduced.
Optionally, in the foregoing embodiment, in determining the effective RS from the RSs of each host included in the load balancing system, the load balancer determines the mounting duration of the RS of each host, and uses the RS with the mounting duration exceeding the preset duration as the effective RS. The mounting time length refers to a time length between an announcement time point and a receiving time point, wherein the announcement time point is a time point when the RS of the host announces the VIP to the inquiring equipment, and the receiving time point is a time point when the load balancer receives the data packet. The aim of accurately determining the effective RS is fulfilled by comparing the mounting time length with the preset time length.
In one mode, each load balancer records the time point when the host joins the load balancing system, and uses the time point as an announcement time point, so that the load balancers in the load balancing system can communicate with each other. Thus, the load balancer can determine the point in time when other hosts join the load balancing system, i.e., the advertising point in time. The notification time point of the host is the notification time point of the RS on the host.
When the load balancer receives the data packet and needs to execute consistency hash, the mounting duration of the RS can be determined according to the notification time point of the RS of each host and the receiving time point of the received data packet. And taking the RS with the mounting time exceeding the preset time as an effective RS. The preset time period is, for example, 10 minutes, 8 minutes, 20 minutes, or the like. The embodiments of the present application are not limited. The preset duration at least can satisfy: and the load balancer on the newly added host executes the second load balancing so as to enable the mapping table of the load balancer to store the mapping relation between the quintuple and the RS of all the existing services.
In another way, as shown in fig. 1, a query device is provided. When the load balancer detects newly added hosts and receives a data packet to execute consistent hash, a query request is sent to query equipment to request to acquire notification time points of RS of all hosts contained in the load balancing system. After receiving the query request, the query device sends a query response to the load balancer, wherein the query response carries the notification time point of the RS of each host computer contained in the load balancing system. And then, the load balancer determines the mounting duration of the RS of each host according to the receiving time point and the notification time point of the RS of each host.
Illustratively, a query_vip function is added to the load balancer, so as to obtain, through the querying device, notification time points of RSs of each host included in the load balancing system. In this way, when the load balancer executes the consistency hash every time, the load balancer does not need to interact with other load balancers in the load balancing system to acquire the notification time point of the RS, but only interacts with the query equipment once, the notification time point of the RS of each host contained in the load balancing system can be determined, and then the mounting duration of the RS of each host is determined.
By adopting the scheme, the VIP query function is added on the load balancing system by arranging the query equipment in the load balancing system, so that the aim of quickly determining the mounting duration of the RS of each host is fulfilled.
Optionally, in the foregoing embodiment, the load balancer may flexibly determine whether a new host exists in the load balancing system.
In one approach, a load balancer detects whether the number of hosts in a load balancing system has changed. When the number of hosts in the load balancing system changes, determining that newly added hosts exist in the load balancing system. When the number of hosts in the load balancing system is unchanged, the load balancing device considers that no new hosts are added in the load balancing system.
Illustratively, each load balancer detects the number of RSs in the load balancing system in real time. Once the number of RSs changes, it indicates that the number of hosts changes. Therefore, the load balancer can quickly determine whether to newly add or subtract hosts in the load balancing system by detecting the number of RSs.
In another mode, when the load balancer determines whether a new host exists in the load balancing system, determining whether an RS with the mounting duration not exceeding the preset duration exists in RSs of all hosts contained in the load balancing system. This is because when the mounting duration of one RS does not exceed the preset duration, the RS cannot participate in the consistent hash operation when it is not effective.
When RS with the mounting time length not exceeding the preset time length exists in the RS of each host contained in the load balancing system, determining that a newly-added host exists in the load balancing system, wherein the newly-added host is the RS with the mounting time length not exceeding the preset time length. When the load balancer receives a data packet and needs to execute consistent hash, determining effective RSs from all RSs contained in the load balancing system, and determining target RSs from the effective RSs.
When the mounting duration in the RS of each host contained in the load balancing system exceeds the preset duration, the load balancing system considers that no newly-added host exists in the load balancing system. When the load balancer receives a data packet and needs to execute consistent hash, the target RS is directly determined from all RSs contained in the load balancing system.
By adopting the scheme, the fact that the RS cannot be used for consistent hash operation when not in effect is considered, so that hosts with the RS of which the mounting duration does not exceed the preset duration are regarded as newly added hosts, errors in the follow-up consistent hash operation are avoided, and the purpose of improving the service quality of the existing service is achieved.
Fig. 4 is another flowchart of a load balancing method according to an embodiment of the present application. The present embodiment is described from the viewpoint of the querying device. The embodiment comprises the following steps:
401. And the query equipment receives an announcement request sent by the RS on the newly added host in the load balancing system, wherein the announcement request is used for indicating the virtual IP address VIP of the RS.
402. Recording the VIP and an announcement time point, wherein the announcement time point is the time point when the query device receives the announcement request, the effective RS in the load balancing system is the RS involved in the load balancing of the load balancing system when the load balancing of the load balancing system performs load balancing on the data packet of the existing service before the new host, and the existing service is the service which is being provided for the user by the load balancing system before the new host.
Illustratively, each time a host is added, the RS on the added host sends an advertisement request to the querying device to pass through the VIP. After receiving the notification request, the query device records the VIP and notification time point of the newly added host. It can be understood that the time point of the newly added host and the time point of the initial mounting of the RS on the newly added host are the notification time point, that is, the time point when the querying device receives the notification request.
By adopting the scheme, the VIP and the notification time point of each newly added host are recorded by setting the query equipment, so that the load balancer can conveniently and quickly acquire the mounting time of each RS from the query equipment, and further, the effective RS can be quickly determined from all the RSs of the load balancing system.
The load balancing method described above will be described in detail with an example. Fig. 5 is a schematic diagram of an application scenario of a load balancing method according to an embodiment of the present application.
Referring to fig. 5, before adding a host, 3 hosts in the load balancing system are host 1, host 2 and host 3, where load balancers 1a and RS1b are deployed on host 1, load balancers 2a and RS2b are deployed on host 2, and load balancers 3a and RS3b are deployed on host 3. And (18) adding a host 4 at the whole time of 18:00, and deploying a load balancer 4a and an RS4b on the host 4. The load balancer 1a stores a mapping table, in which the mapping table stores the correspondence between the five-tuple a and the RS2B, and the mapping table on the load balancer 2a stores the correspondence between the five-tuple B and the RS1B, and the mapping tables on the load balancer 3a and the load balancer 4a are empty.
The querying device 12 is preset to have a preset duration of 10 minutes, that is, from 18:00, the function of the load balancer 4a is turned on, but the function of the RS4b is not turned on, and does not participate in consistent hash operation.
During the period 18:00-18:10, the switch 13 receives the data packet of the terminal device 14, and performs the first load balancing. Wherein the five-tuple of the data packet is five-tuple A, i.e. the data packet is the data packet of the existing service. In case no host 4 is added, the switch 13 sends the data packet to the load balancer 1a. However, since the load balancer 4a is turned on, the switch 13 performs load balancing for the first time, it is highly likely that a packet that should be originally transmitted to the load balancer 1a will be transmitted to the load balancer 2a, the load balancer 3a, or the load balancer 4a.
Regardless of which load balancer is sent to, this load balancer determines that the valid RS includes RS1b, RS2b, and RS3b. Therefore, by performing the consistent hash operation, the target RS is determined to be RS2b, and then the data packet is transmitted to RS2b.
Similarly, when the five-tuple of the data packet is the five-tuple B and the first load balancing should be sent to the load balancer 2a, the switch is likely to send the data packet to the load balancer 1a, the load balancer 3a or the load balancer 4a, and the processing manner is the same as that described above, and the details are not repeated here.
During the period of 18:00-18:10, the load balancer 4a can build a mapping table storing the mapping relation between the quintuple and the RS of all the existing services.
After 18:10, after the switch receives the data packet of the existing service, there is no new load balancer added to the switch (because the new load balancer is turned on at 18:00), so the switch will not split the data packet. After the data packet arrives at the load balancer, the result of the consistent hash operation changes due to the existence of a newly added RS (the newly added RS is started after 18:10). However, since after 18:10, each load balancer, including the load balancer newly added at 18:00, already stores the mapping table of the mapping relationship between the quintuple and the RS of all existing services, the mapping table is preferentially queried. If the five-tuple of the data packet exists in the mapping table, the data packet is the data packet of the existing service, and the RS corresponding to the five-tuple is directly used as the target RS. If the five-tuple of the data packet does not exist in the mapping table, the data packet is a data packet of a new service, the load balancer (the load balancer 1a, the load balancer 2a, the load balancer 3a or the load balancer 4 a) determines that the effective RS includes RS1b, RS2b, RS3b and RS4b, and performs consistent hash operation according to the five-tuple of the data packet of the new service and VIP, number and the like of the effective RS, so as to determine a target RS, which may be RS1b, RS2b, RS3b or RS4b. And then, the load balancer adds the mapping relation between the quintuple of the data packet of the new service and the target RS in the local mapping table.
The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
Fig. 6 is a schematic diagram of a load balancing apparatus according to an embodiment of the present application. The load balancing apparatus 600 includes: a determining module 61, a receiving module 62, a processing module 63 and a transmitting module 64.
A determining module 61, configured to determine that there is a newly added host in a load balancing system, where the load balancing system is a load balancing on any one of multiple hosts included in the load balancing system, and each host in the multiple hosts is deployed with a load balancing device and a real server RS;
a receiving module 62, configured to receive a data packet;
a processing module 63, configured to determine an effective RS from RSs of each host included in the load balancing system, where the effective RS is an RS involved in load balancing a data packet of an existing service by the load balancer before a new host is added, and the existing service is a service that is being provided to a user by the load balancing system before the new host is added, and determine a target RS from the effective RSs;
a sending module 64, configured to send the data packet to the target RS.
In a possible implementation manner, when determining that the RS takes effect from the RSs of each host included in the load balancing system, the processing module 63 is configured to determine a mounting duration of the RS of each host, and take the RS with the mounting duration exceeding a preset duration as the effective RS, where the mounting duration is a duration between an announcement time point and a receiving time point, the announcement time point is a time point when the RS of the host announces the virtual IP address VIP to the querying device, and the receiving time point is a time point when the load balancer receives the data packet.
In a possible implementation manner, the sending module 64 is further configured to send a query request to a querying device to request to obtain an announcement time point of an RS of each host included in the load balancing system;
the receiving module 62 is further configured to receive a query response from the query device, where the query response carries an announcement time point of an RS of each host included in the load balancing system;
the processing module 63 is configured to determine a mounting duration of the RS of each host according to the receiving time point and the notification time point of the RS of each host.
In a possible implementation manner, the determining module 61 is configured to determine whether an RS whose mounting duration does not exceed a preset duration exists in RSs of each host included in the load balancing system; when RS with mounting duration not exceeding preset duration exists in RS of each host contained in the load balancing system, determining that a newly added host exists in the load balancing system.
In a possible implementation manner, the determining module 61 is configured to detect whether the number of RSs in the load balancing system changes; when the number of RS in the load balancing system changes, determining that a newly added host exists in the load balancing system.
In a possible implementation manner, when determining that the RS is effective from RSs of each host included in the load balancing system, the processing module 63 is configured to query a mapping table according to a quintuple of the data packet, where the mapping table stores a correspondence between the quintuple and the RS; and when the five-tuple of the data packet does not exist in the mapping table, determining effective RS from the RS of each host contained in the load balancing system.
In a possible implementation manner, the processing module 63 is further configured to newly add, after determining the target RS from the valid RSs, a mapping relationship between the quintuple of the data packet and the target RS in the mapping table.
In a possible implementation manner, when the processing module 63 determines the target RS from the valid RSs, it is configured to perform consistent hashing according to the five-tuple of the data packet, VIP of each valid RS, and the number of valid RSs to determine the target RS.
The load balancing device provided by the embodiment of the application can execute the action of the load balancer in the embodiment, and the implementation principle and the technical effect are similar, and are not repeated here.
Fig. 7 is a schematic diagram of another load balancing apparatus according to an embodiment of the present application. The load balancing apparatus 700 includes: a transceiver module 71 and a processing module 72.
A transceiver module 71, configured to receive an advertisement request sent by an RS on a newly added host in the load balancing system, where the advertisement request is used to indicate a virtual IP address VIP of the RS;
and a processing module 72, configured to record the VIP and an announcement time point, where the announcement time point is a time point when the query device receives the announcement request, where the VIP and the announcement time point are used to determine whether an RS on the newly added host is converted into an effective RS, where the effective RS in the load balancing system is an RS involved in load balancing a packet of an existing service by a load balancer in the load balancing system, and the existing service is a service that is being provided to a user by the load balancing system before the newly added host.
In a possible implementation manner, the transceiver module 71 is further configured to receive a query request from a load balancer, where the load balancer is a load balancer that receives a data packet in a load balancer of each host included in the load balancing system; and sending a query response to the load balancer, wherein the query response carries the notification time points of the RSs of all hosts contained in the load balancing system.
The load balancing device provided by the embodiment of the application can execute the actions of the query device in the above embodiment, and the implementation principle and the technical effect are similar, and are not repeated here.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 8, the electronic device 800 is, for example, the above-mentioned query device or host, and the electronic device 800 includes:
a processor 81 and a memory 82;
the memory 82 stores computer instructions;
the processor 81 executes the computer instructions stored by the memory 82, causing the processor 81 to perform a load balancing method implemented by a load balancer in the host as above; alternatively, the processor 81 is caused to perform the load balancing method implemented by the querying device as above.
The specific implementation process of the processor 81 can be referred to the above method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
Optionally, the electronic device 800 further comprises a communication component 83. The processor 81, the memory 82, and the communication section 83 may be connected via a bus 84.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores computer instructions which are used for realizing a load balancing method implemented by a load balancer in a host when being executed by a processor; or, the load balancing method implemented by the query device is realized.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program realizes the load balancing method implemented by the load balancer in the host when being executed by a processor; or, the load balancing method implemented by the query device is realized.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (12)

1. A method of load balancing, for use with a load balancer on a host in a load balancing system, the method comprising:
Determining that a newly added host exists in a load balancing system, wherein the load balancing system comprises any one of a plurality of hosts, and each host is provided with the load balancing device and a real server RS;
receiving a data packet;
according to the five-tuple query mapping table of the data packet, when the five-tuple of the data packet does not exist in the mapping table, determining effective RS from the RS of each host contained in the load balancing system, wherein the mapping table stores the corresponding relation between the five-tuple and the RS, the effective RS is the RS involved in the load balancing of the data packet of the existing service by the load balancing system before the host is newly added, and the existing service is the service which is being provided for the user by the load balancing system before the host is newly added;
determining a target RS from the effective RSs;
and sending the data packet to the target RS.
2. The method of claim 1, wherein determining the valid RS from RSs of each host included in the load balancing system comprises:
determining the mounting duration of the RSs of the hosts, taking the RSs with the mounting duration exceeding the preset duration as effective RSs, wherein the mounting duration refers to the duration between an announcement time point and a receiving time point, the announcement time point is the time point when the RSs of the hosts announce virtual IP addresses VIP to inquiring equipment, and the receiving time point is the time point when the load equalizer receives the data packet.
3. The method of claim 2, wherein the determining the mounting duration of the RS of each host includes:
sending a query request to query equipment to request to acquire notification time points of RS of each host contained in the load balancing system;
receiving a query response from the query device, wherein the query response carries notification time points of RSs of all hosts contained in the load balancing system;
and determining the mounting duration of the RS of each host according to the receiving time point and the notification time point of the RS of each host.
4. A method according to any one of claims 1-3, wherein determining that there is an additional host in the load balancing system comprises:
determining whether RS with mounting duration not exceeding preset duration exists in the RS of each host computer contained in the load balancing system;
when RS with mounting duration not exceeding preset duration exists in RS of each host contained in the load balancing system, determining that a newly added host exists in the load balancing system.
5. A method according to any one of claims 1-3, wherein determining that there is an additional host in the load balancing system comprises:
detecting whether the number of RS in the load balancing system changes or not;
When the number of RS in the load balancing system changes, determining that a newly added host exists in the load balancing system.
6. The method of claim 1, wherein after determining the target RS from the valid RSs, further comprising:
and a mapping relation between the quintuple of the data packet and the target RS is newly added in the mapping table.
7. A method according to any one of claims 1-3, wherein said determining a target RS from said validated RSs comprises:
and executing consistent hash according to the five-tuple of the data packet, the VIP of each effective RS and the number of the effective RSs to determine the target RS.
8. A method for load balancing, applied to a query device in a load balancing system, the method comprising:
receiving an announcement request sent by an RS (remote control) on a newly added host in the load balancing system, wherein the announcement request is used for indicating a virtual IP address VIP of the RS;
recording the VIP and an announcement time point, wherein the announcement time point is the time point when the query device receives the announcement request, the VIP and the announcement time point are used for determining whether the RS on the newly-added host is converted into an effective RS, the effective RS in the load balancing system is the RS involved in load balancing the data packet of the existing service by the load balancer in the load balancing system, the existing service is the service which is provided for a user by the load balancing system before the newly-added host, the load balancer queries a mapping table according to the quintuple of the received data packet, and the mapping table stores the corresponding relation between the quintuple and the RS; and when the five-tuple of the data packet does not exist in the mapping table, determining effective RS from the RS of each host contained in the load balancing system.
9. The method as recited in claim 8, further comprising:
receiving a query request from a load balancer, wherein the load balancer is the load balancer of each host machine in the load balancing system for receiving data packets;
and sending a query response to the load balancer, wherein the query response carries the notification time points of the RSs of all hosts contained in the load balancing system.
10. A load balancing system, comprising: the system comprises a switch, a plurality of hosts and query equipment, wherein the switch establishes network connection with each host in the hosts, and the query equipment establishes network connection with each host in the hosts, wherein:
the switch is used for executing load balancing so as to determine a target load balancer from the load balancers contained in the plurality of hosts and sending data packets;
deploying a load balancer and a real server RS on each of the plurality of hosts, the load balancer to perform the method of any of claims 1-7;
the querying device is configured to perform the method of claim 8 or 9.
11. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, characterized in that the processor, when executing the computer program, causes the electronic device to implement the method of any one of claims 1 to 9.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method according to any one of claims 1 to 9.
CN202210555137.8A 2022-05-19 2022-05-19 Load balancing method, device, equipment and readable storage medium Active CN114928615B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210555137.8A CN114928615B (en) 2022-05-19 2022-05-19 Load balancing method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210555137.8A CN114928615B (en) 2022-05-19 2022-05-19 Load balancing method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN114928615A CN114928615A (en) 2022-08-19
CN114928615B true CN114928615B (en) 2023-10-24

Family

ID=82811225

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210555137.8A Active CN114928615B (en) 2022-05-19 2022-05-19 Load balancing method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114928615B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10425473B1 (en) * 2017-07-03 2019-09-24 Pure Storage, Inc. Stateful connection reset in a storage cluster with a stateless load balancer

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201518488U (en) * 2008-04-15 2010-06-30 丛林网络公司 Server load equalizer and system thereof
CN104184819A (en) * 2014-08-29 2014-12-03 城云科技(杭州)有限公司 Multi-hierarchy load balancing cloud resource monitoring method
US9055076B1 (en) * 2011-06-23 2015-06-09 Amazon Technologies, Inc. System and method for distributed load balancing with load balancer clients for hosts
CN106095532A (en) * 2016-06-12 2016-11-09 北京大学 A kind of virtual machine load balancing sacurity dispatching method in cloud environment
US9807016B1 (en) * 2015-09-29 2017-10-31 Juniper Networks, Inc. Reducing service disruption using multiple virtual IP addresses for a service load balancer
CN108768878A (en) * 2018-06-06 2018-11-06 北京奇艺世纪科技有限公司 A kind of SiteServer LBS, method, apparatus and load-balancing device
CN109842651A (en) * 2017-11-27 2019-06-04 中国移动通信集团上海有限公司 A kind of continual load-balancing method of business and system
CN110708393A (en) * 2019-10-21 2020-01-17 北京百度网讯科技有限公司 Method, device and system for transmitting data
CN111327647A (en) * 2018-12-13 2020-06-23 北京金山云网络技术有限公司 Method and device for providing service to outside by container and electronic equipment
CN114500545A (en) * 2022-01-24 2022-05-13 杭州博盾习言科技有限公司 Network load balancing method and device suitable for container and electronic equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040260745A1 (en) * 2003-06-18 2004-12-23 Gage Christopher A. S. Load balancer performance using affinity modification
US8326956B2 (en) * 2006-03-31 2012-12-04 Cisco Technology, Inc. System and method for handling persistence information in a network
US8755283B2 (en) * 2010-12-17 2014-06-17 Microsoft Corporation Synchronizing state among load balancer components
CN108769271A (en) * 2018-08-20 2018-11-06 北京百度网讯科技有限公司 Method, apparatus, storage medium and the terminal device of load balancing
US11611613B2 (en) * 2020-07-24 2023-03-21 Vmware, Inc. Policy-based forwarding to a load balancer of a load balancing cluster

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201518488U (en) * 2008-04-15 2010-06-30 丛林网络公司 Server load equalizer and system thereof
US9055076B1 (en) * 2011-06-23 2015-06-09 Amazon Technologies, Inc. System and method for distributed load balancing with load balancer clients for hosts
CN104184819A (en) * 2014-08-29 2014-12-03 城云科技(杭州)有限公司 Multi-hierarchy load balancing cloud resource monitoring method
US9807016B1 (en) * 2015-09-29 2017-10-31 Juniper Networks, Inc. Reducing service disruption using multiple virtual IP addresses for a service load balancer
CN106095532A (en) * 2016-06-12 2016-11-09 北京大学 A kind of virtual machine load balancing sacurity dispatching method in cloud environment
CN109842651A (en) * 2017-11-27 2019-06-04 中国移动通信集团上海有限公司 A kind of continual load-balancing method of business and system
CN108768878A (en) * 2018-06-06 2018-11-06 北京奇艺世纪科技有限公司 A kind of SiteServer LBS, method, apparatus and load-balancing device
CN111327647A (en) * 2018-12-13 2020-06-23 北京金山云网络技术有限公司 Method and device for providing service to outside by container and electronic equipment
CN110708393A (en) * 2019-10-21 2020-01-17 北京百度网讯科技有限公司 Method, device and system for transmitting data
CN114500545A (en) * 2022-01-24 2022-05-13 杭州博盾习言科技有限公司 Network load balancing method and device suitable for container and electronic equipment

Also Published As

Publication number Publication date
CN114928615A (en) 2022-08-19

Similar Documents

Publication Publication Date Title
US10791168B1 (en) Traffic aware network workload management system
CN110113441B (en) Computer equipment, system and method for realizing load balance
EP3503503B1 (en) Health status monitoring for services provided by computing devices
Araújo et al. Balancing on the edge: Transport affinity without network state
US10887276B1 (en) DNS-based endpoint discovery of resources in cloud edge locations embedded in telecommunications networks
CN109802985B (en) Data transmission method, device, equipment and readable storage medium
US20150189009A1 (en) Distributed multi-level stateless load balancing
US9659075B2 (en) Providing high availability in an active/active appliance cluster
US20130159487A1 (en) Migration of Virtual IP Addresses in a Failover Cluster
US11770359B2 (en) Maintaining communications in a failover instance via network address translation
US10313247B2 (en) System, method, and device for network load balance processing
US11095534B1 (en) API-based endpoint discovery of resources in cloud edge locations embedded in telecommunications networks
US11233737B2 (en) Stateless distributed load-balancing
US10735250B2 (en) Dynamic distributor selection for network load balancing
US20160261505A1 (en) Localized service chaining in nfv clouds
CN111698158A (en) Method and device for electing master equipment and machine-readable storage medium
CN113839862B (en) Method, system, terminal and storage medium for synchronizing ARP information between MCLAG neighbors
CN114928615B (en) Load balancing method, device, equipment and readable storage medium
EP4369181A1 (en) Node for running container group, and management system and method of container group
US11743325B1 (en) Centralized load balancing of resources in cloud edge locations embedded in telecommunications networks
CN112532714B (en) Data processing method, processing device, server and storage medium
CN116962441A (en) Cloud storage control method and device and cloud storage system
US8209421B2 (en) Computer telephony system
US11757987B2 (en) Load balancing systems and methods
CN114826887B (en) Private network connection communication method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant