A virtual load balancing system and working method thereof

By providing a virtual load balancing system in a virtualized environment, using request queues and answer queues to distribute and process request and answer packets, the existing load balancing methods are solved in the problem of high cost and low efficiency in the virtualized environment, and the network request load balancing and dynamic scaling support for virtual machines is realized.

CN114020417BActive Publication Date: 2025-05-09MASSCLOUDS +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111363414.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-17
Publication Date
2025-05-09
Estimated Expiration
2041-11-17

AI Technical Summary

Technical Problem

The existing load balancing methods have high cost and low efficiency problems in virtualized environments, and the existing software load balancers are complex and work-intensive, making it difficult to support the dynamic scaling of virtual machine clusters.

Method used

A virtual load balancing system is provided. By running a load balancer virtual network card, a virtual load balancer and multiple virtual machines in the host, and using a request queue and an answer queue to distribute and process request and reply packets, realizing load balancing of network requests for virtual machines.

Benefits of technology

It realizes load balancing of network requests for multiple virtual machines on the same host, reduces the workload of the load balancer, simplifies implementation complexity, and supports dynamic scaling of virtual machine clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020417B_ABST
    Figure CN114020417B_ABST
Patent Text Reader

Abstract

The present disclosure provides a virtual load balancing system and a working method thereof, which runs in a host machine. The system includes a load balancer virtual network card, a virtual load balancer and a plurality of virtual machines running on the host machine, wherein the virtual load balancer includes a request module and a response module; the request module is used to obtain an external service request based on the load balancer virtual network card, and deliver the request data packet to a request queue; the virtual machine is used to apply for obtaining a request data packet from the request queue using its virtual network card, generate a response data packet after being processed by a service application in the virtual machine, and deliver it to the response queue through its virtual network card; the response module is used to take out the response data packet from the response queue, and return it to the client that issued the service request through the load balancer virtual network card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of cloud computing technology, and in particular, relates to a virtual load balancing system and a working method thereof. Background Art

[0002] The statements in this section merely provide background information related to the present disclosure and do not necessarily constitute prior art.

[0003] In cloud computing / virtualization scenarios, it is very common to use virtual machine clusters to process business, and load balancing is a key link. Load balancing solves two problems: one is to automatically identify the currently active virtual machines and distribute business requests only to them; the other is to give priority to those active virtual machines with light current load or strong processing capabilities.

[0004] The inventors found that the existing load balancing methods mainly include:

[0005] (1) Use a hardware load balancer to distribute the business load to each virtual machine. That is, treat all virtual machines as physical machines and directly use the traditional solution. However, there are two problems with using traditional hardware load balancers in a virtualized environment: first, the cost of purchasing hardware is very high; second, the difference between traditional environments and virtualized environments is not taken into account, resulting in low work efficiency.

[0006] (2) Implement a virtual load balancer at the software level, but the push mode is currently the main one used. That is, the load balancer needs to actively poll to detect active virtual machines and select the ones with lighter load as the target, and then forward the business data to the target virtual machine in a push manner. However, the current various virtual load balancer implementations need to detect whether all virtual machines are online and working normally, and further, they need to detect their respective load conditions before selecting the target to forward business data. According to this technology, the workload of the load balancer is heavy and the implementation is relatively complex. In addition, the load balancer must know the exact number of virtual machines and the IP address of each virtual machine to support polling detection, which brings great inconvenience to the dynamic scaling of virtual machine clusters. Summary of the invention

[0007] In order to solve the above problems, the present disclosure provides a virtual load balancing system and a working method thereof, wherein the solution can realize load balancing of network requests for any number of virtual machines on the same host machine.

[0008] According to a first aspect of an embodiment of the present disclosure, a virtual load balancing system is provided, which runs in a host machine, the system comprising a load balancer virtual network card, a virtual load balancer and a plurality of virtual machines running on the host machine, wherein the virtual load balancer comprises a request module and a response module;

[0009] The request module is used to obtain external service requests based on the load balancer virtual network card and deliver the request data packet to the request queue;

[0010] The virtual machine is used to apply for a request data packet from a request queue using its virtual network card, generate a response data packet after being processed by a business application in the virtual machine, and deliver it to the response queue through its virtual network card;

[0011] The response module is used to take out the response data packet from the response queue and return it to the client that issued the service request through the load balancer virtual network card.

[0012] Furthermore, the load balancer virtual network card is a TAP device bridged on the host machine physical network card.

[0013] Furthermore, the specific steps of the virtual network cards of the plurality of virtual machines obtaining the request data packets from the request queue are: when the request queue is empty, all virtual machines enter a waiting state; when the request queue is not empty, the request data packets are allocated in order according to the application time of the virtual machines;

[0014] Or, when the request queue is not empty, a virtual machine is selected randomly to allocate the request data packet;

[0015] Or, when the request queue is not empty, the request data packets are allocated according to the priority order of the virtual machines, and virtual machines with the same priority are selected randomly.

[0016] Furthermore, the virtual machine that applies to obtain the request data packet from the request queue has the following constraints:

[0017] (1) Only virtual machines in the running state participate in obtaining request packets;

[0018] (2) Based on the processing capacity and running status of the virtual machine, priority control is performed when different virtual machines apply to obtain request data packets, and the one with higher priority obtains the request data packet first.

[0019] Furthermore, the priority control is specifically as follows: a virtual machine in an idle state has a higher priority than a virtual machine in a busy state, and a virtual machine with a strong processing capability has a higher priority than a virtual machine with a weak processing capability.

[0020] According to a second aspect of an embodiment of the present disclosure, a working method of a virtual load balancing system is provided, including:

[0021] The client uses the IP of the load balancer virtual network card as the target IP and sends a service request data packet;

[0022] The virtual load balancer delivers the request data packet to the request queue;

[0023] The virtual machine in the host machine obtains the request data packet based on the priority policy and uses the business application in the virtual machine to perform business processing. The virtual network card delivers the response data packet obtained by the business processing to the response queue;

[0024] The virtual load balancer returns the response data packet to the client of the service request.

[0025] Compared with the prior art, the beneficial effects of the present invention are:

[0026] (1) The solution disclosed in the present disclosure provides a virtual load balancing system, which provides network request load balancing services for multiple virtual machines on the same host machine by introducing a virtual load balancer.

[0027] (2) Compared with existing software load balancer implementations, the solution disclosed in the present invention does not require the load balancer to query the operating status and load conditions of each virtual machine, and the implementation difficulty is relatively low.

[0028] (3) Compared with the existing software load balancer implementation, this method does not require the load balancer to know the number of virtual machine clusters and the IP address of each virtual machine, which is conducive to the dynamic scaling of virtual machine clusters.

[0029] Advantages of additional aspects of the present disclosure will be given in part in the following description and in part will become apparent from the following description or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure.

[0031] Figure 1 This is a schematic diagram of the structure of the virtual load balancing system described in the first embodiment of the present disclosure;

[0032] Figure 2 This is a flow chart of a virtual load balancer processing a request as described in Embodiment 2 of the present disclosure;

[0033] Figure 3 This is a flowchart of the virtual load balancing processing request and returning response described in the second embodiment of the present disclosure;

[0034] Figure 4 This is a flow chart of the virtual load balancing processing response described in the second embodiment of the present disclosure. DETAILED DESCRIPTION

[0035] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0036] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.

[0037] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0038] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0039] Explanation of professional terms:

[0040] The TAP device is a virtual network device at the link layer, equivalent to an Ethernet device, which can send and receive layer 2 data packets, such as Ethernet data frames. The most common use of TAP is as a network card for virtual machines, because it is more similar to an ordinary physical network card and is often used as a virtual network card for ordinary machines.

[0041] Embodiment 1:

[0042] The purpose of this embodiment is to provide a virtual load balancing system.

[0043] A virtual load balancing system, which runs in a host machine, comprises a load balancer virtual network card, a virtual load balancer and several virtual machines running on the host machine, wherein the virtual load balancer comprises a request module and a response module;

[0044] The request module is used to obtain external service requests based on the load balancer virtual network card and deliver the request data packet to the request queue;

[0045] The virtual machine is used to apply for a request data packet from a request queue using its virtual network card, generate a response data packet after being processed by a business application in the virtual machine, and deliver it to the response queue through its virtual network card;

[0046] The response module is used to take out the response data packet from the response queue and return it to the client that issued the service request through the load balancer virtual network card.

[0047] Furthermore, the load balancer virtual network card is a TAP device bridged on the host machine physical network card.

[0048] Furthermore, each virtual machine running in the host machine has an independent virtual network card.

[0049] Furthermore, the specific steps of the virtual network cards of the plurality of virtual machines obtaining the request data packets from the request queue are: when the request queue is empty, all virtual machines enter a waiting state; when the request queue is not empty, the request data packets are allocated in order according to the application time of the virtual machines;

[0050] Or, when the request queue is not empty, a virtual machine is selected randomly to allocate the request data packet;

[0051] Or, when the request queue is not empty, the request data packets are allocated according to the priority order of the virtual machines, and virtual machines with the same priority are selected randomly.

[0052] Furthermore, the virtual machine that applies to obtain the request data packet from the request queue has the following constraints:

[0053] (1) Only virtual machines in the running state participate in obtaining request packets;

[0054] (2) Based on the processing capacity and running status of the virtual machine, priority control is performed when different virtual machines apply to obtain request data packets, and the one with higher priority obtains the request data packet first.

[0055] Furthermore, the priority control is specifically as follows: a virtual machine in an idle state has a higher priority than a virtual machine in a busy state, and a virtual machine with a strong processing capability has a higher priority than a virtual machine with a weak processing capability.

[0056] Furthermore, the processing capability is specifically reflected in the memory and the number of CPU cores allocated to the virtual machine.

[0057] Specifically, for ease of understanding, the solution disclosed in the present disclosure is described in detail below with reference to the accompanying drawings:

[0058] like Figure 1 As shown, the present disclosure provides a virtual load balancing system, the system comprising a load balancer virtual network card, a virtual load balancer and a plurality of virtual machines running on a host machine, wherein:

[0059] Bridge a TAP device to the host's physical network card as the virtual network card of the load balancer, and then set an IP address as the IP address of the load balancing external service.

[0060] The virtual load balancer is a process running on a host machine, which includes two working threads, a request thread and a response thread, corresponding to the request module and the response module mentioned above.

[0061] At the same time, two queues are set on the host machine, where: the request queue stores service request data packets from customers, and the response queue stores response data packets fed back after being processed by the virtual machine.

[0062] Furthermore, the entire system process consists of three asynchronous and concurrent parts:

[0063] (1) The process of load balancer delivering requests

[0064] The request thread of the virtual load balancer waits for external service requests on the TAP device and then delivers the request data packet to the request queue.

[0065] (2) The process of the virtual machine responding to the request and returning a response

[0066] Each virtual machine has a virtual network card, which takes the request data packet from the request queue and transfers it to the virtual machine through the virtual network card driver. After the business application processes the request, it generates response data, which is then passed to the virtual network card through the virtual network card driver and finally delivered to the response queue by the virtual network card.

[0067] (3) The process of the load balancer returning a response

[0068] The response thread of the virtual load balancer takes the response data packet from the response queue and returns it to the client who issued the service request through the network.

[0069] Furthermore, on the virtual machine side, there are usually multiple virtual machines running, and the specific steps for their virtual network cards to obtain request data packets from the request queue are as follows:

[0070] The specific steps of the virtual network cards of the plurality of virtual machines obtaining the request data packets from the request queue are as follows: when the request queue is empty, all virtual machines enter a waiting state; when the request queue is not empty, the request data packets are allocated in order according to the application time of the virtual machines;

[0071] Or, when the request queue is not empty, a virtual machine is selected randomly to allocate the request data packet;

[0072] Or, when the request queue is not empty, the request data packets are allocated according to the priority order of the virtual machines, and virtual machines with the same priority are selected randomly.

[0073] Further, according to the above principle, the virtual machine that applies to obtain the request data packet from the request queue has the following constraints:

[0074] (1) Only virtual machines in the running state participate in obtaining request packets;

[0075] (2) Based on the processing capacity and running status of the virtual machine, priority control is performed when different virtual machines apply to obtain request data packets, and the one with higher priority obtains the request data packet first.

[0076] To sum up the above two points, the virtual machines will automatically coordinate to achieve the effect of load balancing, and the load balancer only needs to send and receive data to the queue, without having to detect the operating status and load conditions of each virtual machine.

[0077] Embodiment 2:

[0078] The purpose of this embodiment is to provide a working method of a virtual load balancing system.

[0079] A working method of a virtual load balancing system, comprising:

[0080] The client uses the IP of the load balancer virtual network card as the target IP and sends a service request data packet;

[0081] The virtual load balancer delivers the request data packet to the request queue;

[0082] The virtual machine in the host machine obtains the request data packet based on the priority policy and uses the business application in the virtual machine to perform business processing. The virtual network card delivers the response data packet obtained by the business processing to the response queue;

[0083] The virtual load balancer returns the response data packet to the client of the service request.

[0084] Furthermore, the priority strategy is as follows: a virtual machine in an idle state has a higher priority than a virtual machine in a busy state, a virtual machine with a strong processing capability has a higher priority than a virtual machine with a weak processing capability, and a request data packet with a high priority is obtained before a request packet with a low priority.

[0085] Furthermore, each virtual machine running in the host machine has an independent virtual network card.

[0086] Specifically, for ease of understanding, the solution disclosed in the present disclosure is described in detail below with reference to the accompanying drawings:

[0087] like Figure 1-Figure 3 As shown, the working method of the virtual load balancing system disclosed in the present invention includes four aspects: preparation process, request process, processing process and response process. The following will explain these four aspects respectively:

[0088] Preparation process: Create a TAP device, which is connected to the host physical network card in bridge mode. Configure the IP of the TAP device, which is the IP address of the load balancer's external service.

[0089] 1. Load balancer processing request process (such as Figure 2(shown)

[0090] 1.1 The customer uses the external IP of the load balancer (i.e. the TAP device IP) as the target IP and sends a service request data packet.

[0091] 1.2 The service request data packet reaches the TAP device through the host network card (bridge mode).

[0092] 1.3 The load balancer takes the request data packet from the TAP device.

[0093] 1.4 The load balancer delivers the request data packet to the request queue.

[0094] 2. The virtual machine processes the request and returns the response process (such as Figure 3 (shown)

[0095] 2.1 The virtual network card competes for the request packet on the request queue. If successful, it goes to 2.2, otherwise it continues to compete for the next one.

[0096] 2.2 The virtual network card notifies the virtual network card driver. The virtual driver stores the request data packet in the network data buffer managed by the operating system inside the virtual machine; at the same time, the source IP of the request data packet remains unchanged and the target IP is changed to the IP of the virtual network card.

[0097] 2.3 The virtual network card driver notifies the business application through the Socket interface. After the business application is awakened, it reads the request from the system network data buffer through the Socket interface and then performs business processing.

[0098] 2.4 After processing the request, the business application passes the response data packet to the virtual network card driver for processing through the Socket interface.

[0099] 2.5 The virtual network card driver submits the response data packet to the virtual network card.

[0100] 2.6 The virtual network card delivers the response data packet to the response queue.

[0101] 3. Load balancer handles the response process (such as Figure 4 (shown)

[0102] 3.1 The load balancer waits in the reply queue and takes out a reply packet when the queue is not empty.

[0103] 3.2 The load balancer changes the source IP of the response data packet to its own IP (i.e. the IP of the load balancing external service), and then sends the response through the TAP device.

[0104] 3.3 The response data packet is sent to the external network via the host network card (bridge mode).

[0105] 3.4 The response data packet is finally returned to the service request client.

[0106] The virtual load balancing system and the working method thereof provided by the above embodiment can be implemented and have broad application prospects.

[0107] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A virtual load balancing system, which runs in a host machine, characterized in that: The system includes a load balancer virtual network card, a virtual load balancer and a plurality of virtual machines running on a host machine, wherein the virtual load balancer includes a request module and a response module; The request module is used to obtain external service requests based on the load balancer virtual network card and deliver the request data packet to the request queue; The virtual machine is used to apply for a request data packet from a request queue using its virtual network card, generate a response data packet after being processed by a business application in the virtual machine, and deliver it to the response queue through its virtual network card; The response module is used to take out the response data packet from the response queue and return it to the client that issued the service request through the load balancer virtual network card; The load balancer processes the request as follows: The client uses the external IP of the load balancer as the target IP and sends a service request data packet; The service request data packet reaches the TAP device through the host network card; The load balancer takes the request data packet from the TAP device; The load balancer delivers the request data packet to the request queue; The virtual machine processes the request and returns the response as follows: The virtual network card competes for the request data packet on the request queue and proceeds to the next step if successful, otherwise it continues to compete for the next one; The virtual network card notifies the virtual network card driver, which stores the request data packet in the network data buffer managed by the operating system inside the virtual machine; at the same time, the source IP of the request data packet remains unchanged, and the target IP is changed to the IP of the virtual network card; The virtual network card driver notifies the business application through the Socket interface. After the business application is awakened, it reads the request from the system network data buffer through the Socket interface and then performs business processing. After processing the request, the business application passes the response data packet to the virtual network card driver for processing through the Socket interface; The virtual network card driver submits the response data packet to the virtual network card; The virtual network card delivers the reply data packet to the reply queue; The load balancer handles the response process as follows: The load balancer waits in the reply queue and takes out a reply packet when the queue is not empty; The load balancer changes the source IP of the response data packet to its own IP, and then sends the response data packet through the TAP device; The reply data packet is sent to the external network via the host network card; The response data packet is eventually returned to the service requesting client.

2. A virtual load balancing system as claimed in claim 1, characterized in that: The load balancer virtual network card is a TAP device bridged on the host machine physical network card.

3. A virtual load balancing system as claimed in claim 1, characterized in that: Each virtual machine running on the host machine has an independent virtual network card.

4. A virtual load balancing system as claimed in claim 1, characterized in that: The specific steps of the virtual network cards of the plurality of virtual machines obtaining the request data packets from the request queue are as follows: when the request queue is empty, all virtual machines enter a waiting state; when the request queue is not empty, the request data packets are allocated in order according to the application time of the virtual machines; Or, when the request queue is not empty, a virtual machine is selected randomly to allocate the request data packet; Or, when the request queue is not empty, the request data packets are allocated according to the priority order of the virtual machines, and virtual machines with the same priority are selected randomly.

5. A virtual load balancing system as claimed in claim 1, characterized in that: The virtual machine that applies for a request packet from the request queue has the following constraints: (1) Only virtual machines in the running state participate in obtaining request data packets; (2) Based on the processing capacity and operating status of the virtual machine, priority control is performed when different virtual machines apply to obtain request data packets, and the one with higher priority obtains the request data packet first.

6. A virtual load balancing system as claimed in claim 5, characterized in that: The priority control is specifically as follows: a virtual machine in an idle state has a higher priority than a virtual machine in a busy state, and a virtual machine with a strong processing capability has a higher priority than a virtual machine with a weak processing capability.

7. A virtual load balancing system as claimed in claim 6, characterized in that: The processing capability is specifically reflected in the memory and the number of CPU cores allocated to the virtual machine.

8. A working method of a virtual load balancing system, characterized in that: include: The client uses the IP of the load balancer virtual network card as the target IP and sends a service request data packet; The virtual load balancer delivers the request data packet to the request queue; The virtual machine in the host machine obtains the request data packet based on the priority policy and uses the business application in the virtual machine to perform business processing. The virtual network card delivers the response data packet obtained by the business processing to the response queue; The virtual load balancer returns the response data packet to the client of the service request; The load balancer processes the request as follows: The client uses the external IP of the load balancer as the target IP and sends a service request data packet; The service request data packet reaches the TAP device through the host network card; The load balancer takes the request data packet from the TAP device; The load balancer delivers the request data packet to the request queue; The virtual machine processes the request and returns the response as follows: The virtual network card competes for the request data packet on the request queue and proceeds to the next step if successful, otherwise it continues to compete for the next one; The virtual network card notifies the virtual network card driver, which stores the request data packet in the network data buffer managed by the operating system inside the virtual machine; at the same time, the source IP of the request data packet remains unchanged, and the target IP is changed to the IP of the virtual network card; The virtual network card driver notifies the business application through the Socket interface. After the business application is awakened, it reads the request from the system network data buffer through the Socket interface and then performs business processing. After processing the request, the business application passes the response data packet to the virtual network card driver for processing through the Socket interface; The virtual network card driver submits the response data packet to the virtual network card; The virtual network card delivers the reply data packet to the reply queue; The load balancer handles the response process as follows: The load balancer waits in the reply queue and takes out a reply packet when the queue is not empty; The load balancer changes the source IP of the response data packet to its own IP, and then sends the response data packet through the TAP device; The reply data packet is sent to the external network via the host network card; The response data packet is eventually returned to the service requesting client.

9. A working method of a virtual load balancing system as claimed in claim 8, characterized in that: The priority strategy is specifically as follows: a virtual machine in an idle state has a higher priority than a virtual machine in a busy state, a virtual machine with a strong processing capability has a higher priority than a virtual machine with a weak processing capability, and a request data packet with a high priority is obtained before a request packet with a low priority.

10. A working method of a virtual load balancing system as claimed in claim 8, characterized in that: Each virtual machine running on the host machine has an independent virtual network card.

Citation Information

Patent Citations

  • A micro-service business processing method and an nginx server

    CN109831466A

  • Load balancing method and device and electronic equipment

    CN113010314A