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

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

Info

Publication number
CN116781625A
CN116781625A CN202211093599.9A CN202211093599A CN116781625A CN 116781625 A CN116781625 A CN 116781625A CN 202211093599 A CN202211093599 A CN 202211093599A CN 116781625 A CN116781625 A CN 116781625A
Authority
CN
China
Prior art keywords
target
load balancer
layer load
address
application
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.)
Pending
Application number
CN202211093599.9A
Other languages
Chinese (zh)
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.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software 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 China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202211093599.9A priority Critical patent/CN116781625A/en
Publication of CN116781625A publication Critical patent/CN116781625A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The application discloses a load balancing method, a device, equipment and a computer readable storage medium, comprising the following steps: determining a target four-layer load balancer from the four-layer load balancer cluster based on a destination Media Access Control (MAC) address in an access message sent by the client; receiving an access message by using a target four-layer load equalizer; controlling the target four-layer load balancer to determine the target seven-layer load balancer and the MAC address of the target seven-layer load balancer from the seven-layer load balancer cluster based on the target IP address; the target MAC address is adjusted to the MAC address of the target seven-layer load balancer through the target four-layer load balancer; and controlling the target four-layer load balancer to send an access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer so that the target seven-layer load balancer obtains the target IP address. In this way, the target seven-layer load balancer can be based on the destination IP address, thereby realizing mutual isolation between applications.

Description

Load balancing method, device, equipment and computer readable storage medium
Technical Field
The present application relates to the field of cloud computing technologies, and in particular, but not limited to, to a load balancing method, apparatus, device, and computer readable storage medium.
Background
With the increasing number of business products and the exponential increase of user quantity, the products need a high-performance and multifunctional load balancer. The system has extremely high performance and capacity expansion capability, and meets the requirements of diversified services, such as providing an application program interface (Application Program Interface, API) for service parties to use, supporting the linkage of an open source container arrangement system (kubernetes), supporting gray scale, blue-green release and the like.
In the related art, however, a request sent by a client first passes through four layers of soft load balancers and then passes through seven layers of soft load balancers, and finally reaches an application server; and the response returned by the application server sequentially passes through a seven-layer soft load equalizer and a four-layer soft load equalizer and finally reaches the client. In the process of interaction of the four-layer soft load equalizer and the seven-layer soft load equalizer, four address translations are performed in total, and the seven-layer soft load equalizer cannot acquire the virtual internet protocol address (Virtual Internet Protocol, VIP), so that mutual isolation between applications cannot be performed.
Disclosure of Invention
In view of this, embodiments of the present application provide a load balancing method, apparatus, device, and computer readable storage medium.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides a load balancing method which is applied to a distributed system, wherein the distributed system comprises a four-layer load balancing cluster and a seven-layer load balancing cluster, and the method comprises the following steps:
determining a target four-layer load balancer from the four-layer load balancer cluster based on a destination Media Access Control (MAC) address in an access message sent by a client;
receiving the access message by using the target four-layer load equalizer, wherein the access message carries a source IP address and a destination IP address;
controlling the target four-layer load balancer to determine a target seven-layer load balancer and MAC addresses of the target seven-layer load balancer from the seven-layer load balancer cluster based on the target IP address;
the target MAC address is adjusted to the MAC address of the target seven-layer load balancer through the target four-layer load balancer;
and controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the target IP address.
The embodiment of the application provides a load balancing device, which comprises:
the first determining module is used for determining a target four-layer load balancer from the four-layer load balancer cluster based on a destination Media Access Control (MAC) address in an access message sent by the client;
the first receiving module is used for receiving the access message by utilizing the target four-layer load equalizer, wherein the access message carries a source IP address and a destination IP address;
the second determining module is used for controlling the target four-layer load balancer to determine a target seven-layer load balancer and MAC addresses of the target seven-layer load balancer from a seven-layer load balancer cluster based on the target IP address;
the first adjusting module is used for adjusting the target MAC address to the MAC address of the target seven-layer load balancer through the target four-layer load balancer;
and the first sending module is used for controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer so as to enable the target seven-layer load balancer to obtain the target IP address.
The embodiment of the application provides load balancing equipment, which comprises the following components:
a processor; and
a memory for storing a computer program executable on the processor;
wherein the computer program when executed by the processor implements the load balancing method described above.
Embodiments of the present application provide a computer-readable storage medium having stored therein computer-executable instructions configured to perform the above-described load balancing method.
The embodiment of the application provides a load balancing method, a device, equipment and a computer readable storage medium, wherein the load balancing method is applied to a distributed system, the distributed system comprises a four-layer load balancing cluster and a seven-layer load balancing cluster, and based on the load balancing method, the load balancing method comprises the following steps: the distributed system acquires a destination media access control (Media Access Control, MAC) address carried in a client sending access message, and determines a target four-layer load balancer from a four-layer load balancer cluster based on the destination MAC address; then, receiving an access message by using the target four-layer load equalizer, wherein the access message carries an active (Internet Protocol, IP) address and a destination IP address; then, the target four-layer load balancer is controlled to determine a target seven-layer load balancer from the seven-layer load balancer cluster based on the target IP address, and the MAC address of the target seven-layer load balancer is also determined, so that the target IP address can be accessed through the target seven-layer load balancer; based on the above, the target four-layer load balancer adjusts the target MAC address to the MAC address of the target seven-layer load balancer; and finally, controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the destination IP address in the access message, and mutual isolation among different applications is realized based on the destination IP address, thereby ensuring efficient and stable operation of each application.
Drawings
In the drawings (which are not necessarily drawn to scale), like numerals may describe similar components in different views. The drawings illustrate generally, by way of example and not by way of limitation, various embodiments discussed herein.
FIG. 1 is a schematic diagram of a soft load balancing system according to the related art;
FIG. 2 is a schematic flow chart of an implementation principle of the FULLNAT mode in the related art;
fig. 3 is a schematic flow chart of an implementation of a load balancing method according to an embodiment of the present application;
FIG. 4 is a schematic flow chart of one implementation of the method for determining the target seven-layer load balancer and the MAC address of the target seven-layer load balancer according to the embodiment of the present application;
fig. 5 is a schematic flow chart of another implementation of the load balancing method according to the embodiment of the present application;
FIG. 6 is a schematic flow chart of an implementation of a method for determining a target application server according to an embodiment of the present application;
FIG. 7 is a schematic flow chart of an implementation of an interaction method between a distributed system and an application deployment platform according to an embodiment of the present application;
fig. 8 is a schematic diagram of an apiix architecture structure according to an embodiment of the present application;
FIG. 9 is a schematic flow chart of an implementation of an interaction method of a kubernetes platform and a distribution system according to an embodiment of the present application;
Fig. 10 is a schematic diagram of a composition structure of a load balancing device according to an embodiment of the present application;
fig. 11 is a schematic diagram of a composition structure of a load balancing device according to an embodiment of the present application.
Detailed Description
The present application will be further described in detail with reference to the accompanying drawings, for the purpose of making the objects, technical solutions and advantages of the present application more apparent, and the described embodiments should not be construed as limiting the present application, and all other embodiments obtained by those skilled in the art without making any inventive effort are within the scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, the terms "first", "second", "third" and the like are merely used to distinguish similar objects and do not represent a particular ordering of the objects, it being understood that the "first", "second", "third" may be interchanged with a particular order or sequence, as permitted, to enable embodiments of the application described herein to be practiced otherwise than as illustrated or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the application only and is not intended to be limiting of the application.
A schematic structure of a related art soft load balancing system is shown in fig. 1, and the soft load balancing system includes a client 101, a four-layer load balancer cluster (a load balancer cluster generally includes a plurality of four-layer load balancers 102), a seven-layer load balancer cluster (a seven-layer load balancer cluster generally includes a plurality of seven-layer load balancers 103), and a plurality of application servers 104. Wherein the four-layer load balancer 102 employs a high performance load balancer based on a data plane development suite (Data Plane Development Kit, DPDK). The seven-layer load balancer 103 uses a high-performance hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) and a reverse proxy global Wide area network (Web) server, which can be denoted as nginnx; seven-layer load balancer 103 may also employ openResity.
Referring to fig. 1, the soft load balancing system architecture adopts DPVS as a four-layer soft load balancer, and uses nginnx or OpenResty as a seven-layer soft load balancer, and a request sent by a user through a client 101 passes through the four-layer soft load balancer 102 and then passes through the seven-layer soft load balancer 103, so as to finally reach an application server 104; the response returned by the application server 104 is sequentially passed through the seven-layer soft load balancer 103 and the four-layer soft load balancer 102, and finally delivered to the user through the client 101.
The four-layer soft load equalizer is used for configuring independent VIP for each application, and the independent VIP and the ports are distributed to the seven-layer soft load equalizer, so that the performance is extremely high. The seven-layer load balancer configures load balancing strategies according to domain names, access paths, headers/cookies and the like.
In the related art, the existing common operation mode of DPVS is the FULLNAT mode, and the implementation principle of the FULLNAT is shown in fig. 2:
the client 201 sends the access VIP message to the DPVS server 202; the DPVS server 202 modifies the destination address of the request message into a back-end real server (DNAT), changes the source address into its own IP address (snap), and sends the IP address to the back-end real server 203; the backend server 203 returns a response message to the DPVS server 202 after processing is completed; the DPVS server 202 changes the source address of the returned packet to itself (SNAT), changes the destination address to the client (DNAT), and sends it to the client 201. The back-end real server 203 refers to a seven-layer load balancer.
Referring to fig. 2, the VIP address to be accessed by the client 201 is 10.87.5.45, but when transmitted to the DPVS server 202, the source IP address is the actual VIP address, and the destination IP address changes to 220.67.8.10; next, when the DPVS server 202 transmits to the backend real server 203, the source IP address changes to 192.168.1.10 and the destination IP address changes to 192.168.10.11. In this way, the backend server 203 is rendered unable to obtain the VIP address 10.87.5.45 to be accessed.
The DPVS FULLNAT mode is similar to the NAT mode, but is different from the NAT mode in that the NAT mode performs address translation only twice, and in the above process, the FULLNAT mode performs address translation four times, so that the backend real server 203 cannot acquire the VIP.
For the DPVS FULLNAT mode, the user request IP address can be obtained by adding a toa module; however, neither the seven-layer load balancer uses Nginx, openresty nor APISIX, nor VIP is available, and thus mutual isolation between applications is not possible.
Based on the problems existing in the related art, the embodiment of the application provides a load balancing method, and the method provided by the embodiment of the application can be realized by a computer program, and the computer program completes the load balancing method provided by the embodiment of the application when being executed. In some embodiments, the computer program may be executed by a processor in a distributed system. Fig. 3 is a flow chart of an implementation of a load balancing method according to an embodiment of the present application, where the load balancing method is applied to a distributed system, and the distributed system includes a four-layer load balancing cluster and a seven-layer load balancing cluster, and based on this, as shown in fig. 3, the load balancing method includes:
Step S301 determines a target four-layer load balancer from the four-layer load balancer cluster based on the destination MAC address in the access message sent by the client.
Here, the client refers to a terminal accessing an application, and the client may be a computer, a smart phone, an intelligent wearable device, or the like.
In the embodiment of the application, the access message carries a destination MAC address, and the destination MAC address is used to indicate a destination location of the access message sent at this stage, that is, the destination MAC address is the MAC address of the target four-layer load balancer. Based on this, the target load balancer can be determined from the four-layer load balancer cluster based on the destination MAC address.
When the client and the four-layer load balancer cluster are in the same network in actual implementation, the MAC address in the access message sent by the client is the MAC address of the target four-layer load balancer; when the client and the four-layer load balancer cluster are not in the same network, the MAC address in the access message changes every time the access message passes through a router or a three-layer switch, and the changed MAC address is the MAC address of the target four-layer load balancer.
Step S302, receiving an access message by using the target four-layer load equalizer.
Here, after the target four-layer load balancer is determined, the target four-layer load balancer is utilized to receive the access message, and when the access message is actually implemented, the four-layer load balancers except the target four-layer load balancer do not receive the access message.
In the embodiment of the application, the access message carries a source IP address and a destination IP address, wherein the source IP address refers to the IP address of the client, and the destination IP address refers to the IP address of the destination application to be accessed. When creating an application, the four-layer load balancer cluster configures an independent VIP address for each application, and the VIP address is the destination IP address.
In step S303, the target four-layer load balancer is controlled to determine the MAC addresses of the target seven-layer load balancer and the target seven-layer load balancer from the seven-layer load balancer cluster based on the destination IP address.
Here, after the access message reaches the target four-layer load balancer, the target four-layer load balancer is controlled to determine the target seven-layer load balancer based on the destination IP address, and the MAC address of the target seven-layer load balancer is also determined.
When the method is actually realized, a first mapping relation table of the IP address and the MAC address can be obtained by utilizing the target four-layer load balancer, and then the target four-layer load balancer is controlled to determine the MAC address of the seven-layer load balancer corresponding to the target IP address based on the first mapping relation table, namely the MAC address of the target seven-layer load balancer. In addition, the target four-layer load balancer also determines a seven-layer load balancer corresponding to the MAC address of the target seven-layer load balancer as the target seven-layer load balancer.
Step S304, the destination MAC address is adjusted to the MAC address of the destination seven-layer load balancer through the destination four-layer load balancer.
Here, the destination MAC address of the access message is adjusted from the MAC address of the original target four-layer load balancer to the MAC address of the target seven-layer load balancer by the target four-layer load balancer, so as to send the access message to the target seven-layer load balancer.
In step S305, the target four-layer load balancer is controlled to send an access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the destination IP address.
Here, the control target load balancer transmits an access message to the target load balancer based on the MAC address of the target seven-layer load balancer. When the target seven-layer load balancer receives the access message, the target seven-layer load balancer also receives the destination IP address carried by the access message.
In some embodiments, the target seven-layer load balancer will also send access messages to the corresponding target application servers based on the destination IP addresses to enable successful access to the desired applications based on the target application servers.
The embodiment of the application provides a load balancing method, which is applied to a distributed system, wherein the distributed system comprises four-layer load balancing clusters and seven-layer load balancing clusters, and based on the load balancing method, the load balancing method comprises the following steps: the distributed system acquires an access message carrying a destination media access control (Media Access Control, MAC) address sent by a client, and determines a target four-layer load balancer from a four-layer load balancer cluster based on the destination MAC address; then, receiving an access message by using the target four-layer load equalizer, wherein the access message carries an active (Internet Protocol, IP) address and a destination IP address; then, the target four-layer load balancer is controlled to determine a target seven-layer load balancer from the seven-layer load balancer cluster based on the target IP address, and the MAC address of the target seven-layer load balancer is also determined, so that the target IP address can be accessed through the target seven-layer load balancer; based on the above, the target four-layer load balancer adjusts the target MAC address to the MAC address of the target seven-layer load balancer; and finally, controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the destination IP address in the access message, and mutual isolation among different applications is realized based on the destination IP address, thereby ensuring efficient and stable operation of each application.
In some embodiments, as shown in fig. 4, the step S303 "controlling the target four-layer load balancer to determine the MAC addresses of the target seven-layer load balancer and the target seven-layer load balancer from the seven-layer load balancer cluster based on the destination IP address" may be implemented by the following steps S3031 to S3034:
step S3031, a first mapping relationship table of the IP address and the MAC address is obtained by using the target four-layer load balancer.
Here, when each application is created, the target seven-layer load balancer corresponding to each application is also built and completed, and apiix software for matching the destination IP address may also be deployed on the target seven-layer load balancer. Based on this, a first mapping relation table between the IP address of each application and the MAC address of the corresponding target seven-layer load balancer is stored in the four-layer load cluster.
Step S3032, the control target four-layer load balancer determines the MAC address of the seven-layer load balancer corresponding to the destination IP address based on the first mapping relationship table.
Here, the target four-layer load balancer may be controlled to determine the MAC address corresponding to the destination IP address from the first mapping table.
In step S3033, the control target four-layer load balancer determines the MAC address of the seven-layer load balancer corresponding to the destination IP address as the MAC address of the target seven-layer load balancer.
Here, the MAC address corresponding to the destination IP address is the MAC address of the target seven-layer load balancer.
In step S3034, the target four-layer load balancer is controlled to determine the seven-layer load balancer corresponding to the MAC address of the target seven-layer load balancer as the target seven-layer load balancer.
Here, the target seven-layer load balancer can be determined by the MAC address of the target seven-layer load balancer.
In the embodiment of the present application, through the steps S3031 to S3034, the first mapping relation table between the IP address and the MAC address can be obtained by the target four-layer load balancer, and then the target four-layer load balancer is controlled to determine the MAC address corresponding to the destination IP address based on the first mapping relation table, that is, the MAC address of the target seven-layer load balancer, and the target seven-layer load balancer is determined accordingly, so that the MAC address of the target seven-layer load balancer and the target seven-layer load balancer can be determined rapidly and accurately, and a preparation condition is provided for forwarding the subsequent access message.
In some embodiments, the client sends an access message to the destination application server to obtain a corresponding resource, that is, there is interaction between the target seven-layer load balancer and the target application server, based on which, the distributed system further includes a plurality of application servers, as shown in fig. 5, after the step S305 "controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer so that the target seven-layer load balancer obtains the destination IP address", the load balancing method further includes the following steps S306 to S309:
In step S306, the control target seven-layer load balancer determines a target application server from the plurality of target servers based on the destination IP address.
In actual implementation, as shown in fig. 6, the above step S306 may be implemented by the following steps S3061 to S3063:
step S3061, a second mapping relation table between the destination IP address and the deployment unit IP address list sent by the application deployment platform is received by using the target seven-layer load balancer.
Here, the application deployment platform may send a second mapping relationship table between the destination IP address and the deployment unit IP address list to the target seven-layer load balancer based on the trigger instruction, and for example, the application deployment platform may be a containerized application deployment platform.
In the embodiment of the present application, the deployment unit IP address may be an IP address of an application container engine, and, for example, when the application deployment platform is kubernetes, the deployment unit IP address may be a pod IP address, where a correspondence exists between the pod IP address and the application server. The second mapping relation table is used for representing the relation between the destination IP address and the deployment unit IP address list.
Step S3062, the control target seven-layer load balancer determines a target deployment unit IP address list corresponding to the target IP address based on the second mapping relation table.
Here, because the second mapping relationship table stores the mapping relationship between the destination IP address and the deployment unit IP address list, based on this, the target deployment unit IP address list corresponding to the destination IP address may be determined from the second mapping relationship table by the target seven-layer load balancer.
In practical implementation, the IP addresses and the applications are in one-to-one correspondence, and in addition, one application can be deployed in a plurality of deployment units, that is, the application and the deployment units are in one-to-many correspondence. Based on this, there is a one-to-many correspondence between IP addresses and deployment units.
In step S3063, the control target seven-layer load balancer determines a target application server based on the target deployment unit IP address list.
Here, based on the corresponding relationship between the deployment unit IP address and the application server, the target seven-layer load balancer may be controlled to determine the corresponding target application server based on the target deployment unit IP address list. The correspondence between the deployment unit IP addresses and the application servers may be a one-to-one correspondence.
Step S307, the access message is sent to the target application server by using the target seven-layer load balancer.
Here, the access message is forwarded to the target application server using the target seven-layer load balancer to make the client access successful.
Step S308, the target application server is utilized to respond to the received access message to acquire the access resource.
Here, after the target application server receives the access message, the target application server may acquire corresponding resource information from itself based on the access message, that is, acquire the access resource.
In step S309, the control target application server returns the access resource to the client through the target seven-layer load balancer.
Here, when the access resource is returned to the client, the return path of the access resource passes through the target seven-layer load balancer, and finally reaches the client.
In the embodiment of the present application, through the steps S306 to S309, a second mapping relation table between the destination IP address and the deployment unit IP address list sent by the application deployment platform is received by using the target seven-layer load balancer, and the target deployment unit IP address list and the target application server are sequentially determined based on the second mapping relation table; then, sending the access message to a target application server through a target seven-layer load balancer; then, the target application server responds to the received access message by acquiring the access resource; finally, the access resource sequentially passes through the target seven-layer load equalizer and the target four-layer load equalizer, and finally returns to the client to finish one-time access of the client. In the whole access process, the target four-layer load balancer sends the target IP address to the target seven-layer load balancer in a direct routing mode, so that the target seven-layer load balancer can acquire the target IP address, and further the target seven-layer load balancer can realize mutual isolation between different target IP addresses based on the target IP address, namely, mutual isolation between different applications.
In some embodiments, the application deployment platform may construct the second mapping table in advance, based on which the following steps one and two may be further performed before the step S306 is performed, so that the application deployment platform completes constructing the second mapping table.
And step one, a target four-layer load balancer is utilized to send the target IP address to an application deployment platform.
Here, when creating the target application, the target four-layer load balancer configures a destination IP address for the target application, based on which the client can use the destination IP address to achieve access to the target application.
In the embodiment of the application, the target four-layer load balancer also sends the target IP address to the application deployment platform. The application deployment platform is used for deploying various applications on the distributed system.
And step two, the application deployment platform builds a second mapping relation table between the destination IP address and the deployment unit IP address list based on the destination IP address.
After the application deployment platform acquires the destination IP address, the application deployment platform automatically establishes a second mapping relationship between the destination IP address and the deployment unit IP address list, and also completes the deployment work of the target application, that is, deploys the target application to the target application server.
In some embodiments, to obtain the second mapping table of the deployed new application, the distributed system further has an interaction process with the application deployment platform, as shown in fig. 7, where the interaction process includes:
step S701, determining whether the distributed system deploys a new application on a plurality of application servers.
Here, it may be determined whether the distributed system deploys a new application by implementing monitoring of the status of each application server, and if it is monitored that application registration and related resource information are written into the application servers, it is determined that the distributed system deploys a new application on a plurality of application servers, step S702 is entered; if it is detected that the application registration and the related resource information are not written to any application server, that is, the data stored in all application servers are not changed, it is determined that the distributed system does not deploy new applications on a plurality of application servers, and step S706 is performed.
In step S702, the four-layer load balancer cluster is controlled to create a new destination IP address corresponding to the new application.
Here, the distributed system deploys a new application on a plurality of application servers, and then controls the four-layer load balancer cluster to create a new destination IP address for the new application, where the new destination IP address is different from an existing destination IP address.
In step S703, the four-layer load balancer cluster is controlled to send the new destination IP address to the application deployment platform.
Here, in order to realize automatic linkage between the distributed platform and the application deployment platform, the four-layer load balancer cluster also sends a new destination IP address to the application deployment platform.
In step S704, the application deployment platform constructs a new second mapping relationship table between the new destination IP address and the deployment unit IP address list based on the new destination IP address.
Here, the implementation of step S704 is similar to that of step S described above, and thus, the implementation of step S704 may refer to that of step S described above.
Step S705, the seven-layer load balancer cluster is controlled to receive the new second mapping relation table through the API interface.
Here, to simplify the configuration process and improve the configuration efficiency, the distributed system may further control the seven-layer load balancer cluster to receive the new second mapping table through the API interface. In this way, the entire configuration file does not need to be modified, nor is it required to be reloaded.
In step S706, it is determined whether there is a failed application server among the plurality of application servers in the distributed system.
Here, the distributed system does not deploy new applications on the plurality of application servers, and at this time, it is further determined whether there is a failed application server in the plurality of application servers, and when actually implemented, it may be determined whether there is a failed application server by heartbeat detection.
In the embodiment of the present application, if there is a failed application server, step S707 is entered; and if there is no failed application server, returns to step S701.
Step S707, the deployment unit IP address list of the application deployment platform changes, and the application deployment platform updates the second mapping relationship table corresponding to the fault application based on the changed deployment unit IP address list, to obtain an updated second mapping relationship table.
Here, if there is a fault application server, the deployment unit IP address list will be changed, and the application deployment platform updates the second mapping relationship table corresponding to the fault application based on the changed deployment unit IP address list, that is, replaces the deployment unit IP address with the changed deployment unit IP address list, thereby obtaining an updated second mapping relationship table including the changed deployment unit IP address list. The fault application is an application deployed in the fault application server.
Step S708, the seven-layer load balancer cluster is controlled to receive the updated second mapping relation table through the API interface.
Here, the implementation of step S708 is similar to that of step S705 described above, and therefore, the implementation of step S708 may refer to that of step S705 described above.
In the embodiment of the present application, through the steps S701 to S708, on the one hand, when a new application is deployed, the four-layer load balancer cluster creates a new destination IP address of the new application, and sends the new destination IP address to the application deployment platform, so that the application deployment platform builds a new second mapping relationship table between the new destination IP address and the deployment unit IP address list, and finally controls the seven-layer load balancer cluster to receive the new second mapping relationship table through the API interface, on the other hand, when there is a failed application server, the application deployment platform updates the second mapping relationship table of the failed application based on the changed deployment unit IP address list, thereby obtaining an updated second mapping relationship table, and the seven-layer load balancer cluster still receives the updated second mapping relationship table through the API interface. Therefore, when the second mapping relation table is created or changed, the automatic linkage of the distributed system and the application deployment platform can be realized, external intervention is not needed, and the running efficiency of the distributed system is improved; and moreover, the configuration process can be simplified based on the API, the configuration efficiency is improved, and the whole configuration file is not required to be modified and loaded.
Based on the above embodiment, the embodiment of the present application further provides a load balancing method, where the load balancing method includes:
first, a micro service API gateway (apifix) is used instead of the traditional nginnx or openness.
Here, apimix is an open source cloud native API gateway, but takes the apimix as a seven-layer soft load equalizer, and has the advantages of supporting API call modification configuration, enabling the modification configuration to take effect in real time, using a database as a configuration center, expanding rapidly and laterally, and the like on the premise of meeting performance requirements. The architecture of the apimix architecture is shown in fig. 8, and includes an API client 801, a four-layer Load Balancer (LB) 802, a seven-layer load balancer (APISIX API Gateway) 803, and a database (etcd) 804. The seven-layer load balancer (APISIX API Gateway) 803 includes a plurality of application servers (realservers) 8031.
Second, four-layer DPVS uses Direct Routing (DR) mode.
Here, the four-layer DPVS uses a DR mode instead of the usual FULLNAT mode, wherein the principle of the DR mode is as follows:
the client sends the access VIP message to the DPVS server; the DPVS server modifies the destination mac of the request message into the mac address of the back-end APISIX server, and the source and destination IP addresses APISIX server returns the response message to the user after processing.
In the embodiment of the application, after the DR mode is used, the destination mac address of the data packet is only modified after the data packet is subjected to DPVS, and the source IP (i.e. client IP) and the destination IP (i.e. VIP) are reserved, so that the seven-layer load equalizer can acquire the VIP.
Thirdly, linkage with a four-layer DPVS platform is added on the basis of an open source apisix-ingress.
Here, when creating an application, applying VIP to the four-layer platform using the application name as a unique identifier; after the application was successful, the VIP was recorded. And developing an Agent, calling a RestAPI interface of the Agent, and binding the VIP to the network card of each seven-layer soft load balancing node. Wherein, the ingress is a script in the kubernetes platform.
In the embodiment of the present application, fig. 9 provides an interaction block diagram of a kubernetes platform and a distribution system, and in fig. 9, ingress acquires configuration information from the kubernetes platform, based on which the interaction process includes steps S901 to S904:
step S901, when an instance is created, a four-layer load equalizer cluster management interface is called to create the instance, and the VIP is obtained.
Here, when an instance is created, the ingress acquires VIP from the four-layer load balancer cluster.
Step S902, after the pod changes, a seven-layer load balancer cluster management interface is called to create route and upstream.
Here, it means that a pod is created when an instance is created or a pod is changed.
In step S903, the four-layer load balancer cluster adopts DR mode.
In step S904, the seven-layer load balancer cluster interacts with the application server through HTTP.
Fourth, instances are isolated from each other when creating routes to apimix.
Here, after the DPVS is modified to the DR mode, at this time, the destination IP is VIP, and when creating a route to the apimix, the VIP is used as a matching condition of the route "destination IP"; if the user accesses other applications, the destination IP is not the same, and the policy is not matched, so that the isolation among different applications is realized.
By the load balancing method provided by the embodiment of the application, four-layer and seven-layer load balancing configuration can be realized through the Rest API call, the configuration file is not required to be reloaded, the configuration is invalid in real time, and waiting is not required. Meanwhile, jitter caused by the nginx or the openness is also solved. Applications are isolated from each other by VIP and are no longer dependent on domain name and domain name resolution service (DNS). And the distribution system is linked with the Kubernetes, the VIP is automatically applied through the ingress, and the configuration is carried out without manual intervention.
Based on the foregoing embodiments, the embodiments of the present application provide a load balancing apparatus, where each module included in the apparatus and each unit included in each module may be implemented by a processor in a computer device; of course, the method can also be realized by corresponding logic circuits; in practice, the processor may be a central processing unit (Central Processing Unit, CPU), microprocessor (Microprocessor Unit, MPU), digital signal processor (Digital Signal Processing, DSP) or field programmable gate array (Field Programmable Gate Array, FPGA), etc.
An embodiment of the present application further provides a load balancing device, and fig. 10 is a schematic diagram of a composition structure of the load balancing device provided by the embodiment of the present application, as shown in fig. 10, where the load balancing device 1000 includes:
a first determining module 1001, configured to determine a target four-layer load balancer from the four-layer load balancer cluster based on a destination MAC address in an access message sent by the client;
a first receiving module 1002, configured to receive the access packet by using the target four-layer load balancer, where the access packet carries a source IP address and a destination IP address;
a second determining module 1003, configured to control the target four-layer load balancer to determine, from a seven-layer load balancer cluster, a target seven-layer load balancer and a MAC address of the target seven-layer load balancer based on the destination IP address;
a first adjusting module 1004, configured to adjust, by the target four-layer load balancer, the destination MAC address to a MAC address of the target seven-layer load balancer;
a first sending module 1005, configured to control the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the destination IP address.
In some embodiments, the second determining module 1003 includes:
the first obtaining submodule is used for obtaining a first mapping relation table of the IP address and the MAC address by using the target four-layer load equalizer;
the first determining submodule is used for controlling the target four-layer load balancer to determine the MAC address of the seven-layer load balancer corresponding to the target IP address based on the first mapping relation table;
the second determining submodule is used for controlling the target four-layer load balancer to determine the MAC address of the seven-layer load balancer corresponding to the target IP address as the MAC address of the target seven-layer load balancer;
and the third determining submodule is used for controlling the target four-layer load balancer to determine the seven-layer load balancer corresponding to the MAC address of the target seven-layer load balancer as the target seven-layer load balancer.
In some embodiments, the load balancing apparatus 1000 further comprises:
a third determining module, configured to control the target seven-layer load balancer to determine a target application server from the plurality of target servers based on the destination IP address;
and the second sending module is used for sending the access message to the target application server by using the target seven-layer load equalizer.
In some embodiments, the third determination module includes:
the first receiving sub-module is used for receiving a second mapping relation table between the target IP address and a deployment unit IP address list sent by the application deployment platform by utilizing the target seven-layer load balancer;
a fourth determining submodule, configured to control the target seven-layer load balancer to determine a target deployment unit IP address list corresponding to the target IP address based on the second mapping relationship table;
and a fifth determining submodule, configured to control the target seven-layer load balancer to determine the target application server based on the target deployment unit IP address list.
In some embodiments, the load balancing apparatus 1000 further comprises:
and the third sending module is used for sending the destination IP address to the application deployment platform by utilizing the target four-layer load equalizer so that the application deployment platform builds a second mapping relation table between the destination IP address and a deployment unit IP address list based on the destination IP address.
In some embodiments, the load balancing apparatus 1000 further comprises:
the first creating module is used for controlling the four-layer load balancer cluster to create a new destination IP address corresponding to the new application when the distributed system deploys the new application on the plurality of application servers, and sending the new destination IP address to an application deployment platform so that the application deployment platform builds a new second mapping relation table between the new destination IP address and a deployment unit IP address list based on the new destination IP address;
The first receiving module is used for controlling the seven-layer load equalizer cluster to receive the new second mapping relation table through an application program interface API interface;
the second creating module is used for triggering the deployment unit IP address list to change when the plurality of application servers in the distributed system have fault application servers, so that the application deployment platform updates a second mapping relation table corresponding to the fault application based on the changed deployment unit IP address list to obtain an updated second mapping relation table;
and the second receiving module is used for controlling the seven-layer load equalizer cluster to receive the updated second mapping relation table through the API interface, wherein the fault application is an application deployed in the fault application server.
In some embodiments, the load balancing apparatus 1000 further comprises:
the response module is used for responding to the received access message by utilizing the target application server to acquire access resources;
and the return module is used for controlling the target application server to return the access resource to the client through the target seven-layer load balancer.
It should be noted that, the description of the load balancing device in the embodiment of the present application is similar to the description of the embodiment of the method described above, and has similar beneficial effects as the embodiment of the method. For technical details not disclosed in the present apparatus embodiment, please refer to the description of the method embodiment of the present application for understanding.
It should be noted that, in the embodiment of the present application, if the load balancing method is implemented in the form of a software functional module, and sold or used as a separate product, the load balancing method may also be stored in a computer readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be embodied essentially or in a part contributing to the related art in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a magnetic disk, an optical disk, or other various media capable of storing program codes. Thus, embodiments of the application are not limited to any specific combination of hardware and software.
Accordingly, an embodiment of the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the load balancing method provided in the above embodiment.
An embodiment of the present application provides a load balancing device, and fig. 11 is a schematic diagram of a composition structure of the load balancing device provided by the embodiment of the present application, as shown in fig. 11, where, the load balancing device 1100 includes: a processor 1101, at least one communication bus 1102, a user interface 1103, at least one external communication interface 1104 and a memory 1105. Wherein communication bus 1102 is configured to enable connected communication between the components. The user interface 1103 may include a display screen and the external communication interface 1104 may include a standard wired interface and a wireless interface, among others. Wherein the processor 1101 is configured to execute a program of the load balancing method stored in the memory, so as to implement the load balancing method provided in the above embodiment.
The description of the load balancing apparatus and the storage medium embodiments above is similar to that of the method embodiments described above, with similar advantageous effects as the method embodiments. For technical details not disclosed in the embodiments of the load balancing apparatus and the storage medium of the present application, please refer to the description of the method embodiments of the present application for understanding.
It should be noted here that: the description of the storage medium and load balancing device embodiments above is similar to that of the method embodiments described above, with similar benefits as the method embodiments. For technical details not disclosed in the embodiments of the storage medium and the load balancing apparatus of the present application, please refer to the description of the method embodiments of the present application for understanding.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. It should be understood that, in various embodiments of the present application, the sequence numbers of the foregoing processes do not mean the order of execution, and the order of execution of the processes should be determined by the functions and internal logic thereof, and should not constitute any limitation on the implementation process of the embodiments of the present application. The foregoing embodiment numbers of the present application are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above described device embodiments are only illustrative, e.g. the division of the units is only one logical function division, and there may be other divisions in practice, such as: multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or units, whether electrically, mechanically, or otherwise.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units; can be located in one place or distributed to a plurality of network units; some or all of the units may be selected according to actual needs to achieve the purposes of the embodiment of the present application.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated in one unit; the integrated units may be implemented in hardware or in hardware plus software functional units.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, where the program, when executed, performs steps including the above method embodiments; and the aforementioned storage medium includes: various media capable of storing program codes, such as a removable storage device, a ROM, a magnetic disk, or an optical disk.
Alternatively, the above-described integrated units of the present application may be stored in a computer-readable storage medium if implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied essentially or in a part contributing to the related art in the form of a software product stored in a storage medium, including several instructions for causing an AC to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a removable storage device, a ROM, a magnetic disk, or an optical disk.
The foregoing is merely an embodiment of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A load balancing method applied to a distributed system, wherein the distributed system comprises a four-layer load balancer cluster and a seven-layer load balancer cluster, the method comprising:
determining a target four-layer load balancer from the four-layer load balancer cluster based on a destination Media Access Control (MAC) address in an access message sent by a client;
receiving the access message by using the target four-layer load equalizer, wherein the access message carries a source IP address and a destination IP address;
controlling the target four-layer load balancer to determine a target seven-layer load balancer and MAC addresses of the target seven-layer load balancer from the seven-layer load balancer cluster based on the target IP address;
the target MAC address is adjusted to the MAC address of the target seven-layer load balancer through the target four-layer load balancer;
And controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer, so that the target seven-layer load balancer obtains the target IP address.
2. The method of claim 1, wherein said controlling the target four-layer load balancer to determine a target seven-layer load balancer and MAC addresses of the target seven-layer load balancer from the seven-layer load balancer cluster based on the destination IP address comprises:
acquiring a first mapping relation table of an IP address and an MAC address by using the target four-layer load balancer;
controlling the target four-layer load balancer to determine the MAC address of the seven-layer load balancer corresponding to the target IP address based on the first mapping relation table;
controlling the target four-layer load balancer to determine the MAC address of the seven-layer load balancer corresponding to the target IP address as the MAC address of the target seven-layer load balancer;
and controlling the target four-layer load balancer to determine the seven-layer load balancer corresponding to the MAC address of the target seven-layer load balancer as the target seven-layer load balancer.
3. The method of claim 1, wherein the distributed system further comprises a plurality of application servers, the method further comprising:
controlling the target seven-layer load balancer to determine a target application server from the plurality of target servers based on the target IP address;
and sending the access message to the target application server by using the target seven-layer load balancer.
4. A method according to claim 3, wherein said controlling the target seven-layer load balancer to determine a target application server from the plurality of target servers based on the destination IP address comprises:
receiving a second mapping relation table between the target IP address and a deployment unit IP address list sent by an application deployment platform by using the target seven-layer load balancer;
controlling the target seven-layer load balancer to determine a target deployment unit IP address list corresponding to the target IP address based on the second mapping relation table;
and controlling the target seven-layer load balancer to determine the target application server based on the target deployment unit IP address list.
5. The method as recited in claim 4, wherein the method further comprises:
And sending the destination IP address to the application deployment platform by using the target four-layer load balancer so that the application deployment platform builds a second mapping relation table between the destination IP address and a deployment unit IP address list based on the destination IP address.
6. A method as claimed in claim 3, further comprising:
when the distributed system deploys a new application on the plurality of application servers, controlling the four-layer load balancer cluster to create a new destination IP address corresponding to the new application, and sending the new destination IP address to an application deployment platform, so that the application deployment platform builds a new second mapping relation table between the new destination IP address and a deployment unit IP address list based on the new destination IP address;
controlling the seven-layer load equalizer cluster to receive the new second mapping relation table through an application program interface API interface;
when a fault application server exists in the plurality of application servers in the distributed system, the deployment unit IP address list is caused to change, so that the application deployment platform updates a second mapping relation table corresponding to the fault application based on the changed deployment unit IP address list to obtain an updated second mapping relation table;
And controlling the seven-layer load balancer cluster to receive the updated second mapping relation table through the API interface, wherein the fault application is an application deployed in the fault application server.
7. The method according to any one of claims 3 to 6, further comprising:
the target application server is utilized to respond to the received access message to acquire access resources;
and controlling the target application server to return the access resource to the client through the target seven-layer load balancer.
8. A load balancing apparatus, the load balancing apparatus comprising:
the first determining module is used for determining a target four-layer load balancer from the four-layer load balancer cluster based on a destination Media Access Control (MAC) address in an access message sent by the client;
the first receiving module is used for receiving the access message by utilizing the target four-layer load equalizer, wherein the access message carries a source IP address and a destination IP address;
the second determining module is used for controlling the target four-layer load balancer to determine a target seven-layer load balancer and MAC addresses of the target seven-layer load balancer from a seven-layer load balancer cluster based on the target IP address;
The first adjusting module is used for adjusting the target MAC address to the MAC address of the target seven-layer load balancer through the target four-layer load balancer;
and the first sending module is used for controlling the target four-layer load balancer to send the access message to the target seven-layer load balancer based on the MAC address of the target seven-layer load balancer so as to enable the target seven-layer load balancer to obtain the target IP address.
9. A load balancing apparatus, the load balancing apparatus comprising:
a processor; and
a memory for storing a computer program executable on the processor;
wherein the computer program, when executed by a processor, implements the load balancing method of any one of claims 1 to 7.
10. A computer readable storage medium having stored therein computer executable instructions configured to perform the load balancing method of any one of the preceding claims 1 to 7.
CN202211093599.9A 2022-09-08 2022-09-08 Load balancing method, device, equipment and computer readable storage medium Pending CN116781625A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211093599.9A CN116781625A (en) 2022-09-08 2022-09-08 Load balancing method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211093599.9A CN116781625A (en) 2022-09-08 2022-09-08 Load balancing method, device, equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN116781625A true CN116781625A (en) 2023-09-19

Family

ID=87993671

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211093599.9A Pending CN116781625A (en) 2022-09-08 2022-09-08 Load balancing method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN116781625A (en)

Similar Documents

Publication Publication Date Title
US11271892B2 (en) Network communication method and system, device, and storage medium
US10911398B2 (en) Packet generation method based on server cluster and load balancer
CN109451084A (en) A kind of service access method and device
JP6306640B2 (en) Providing logical networking capabilities for managed computer networks
CN109802985A (en) Data transmission method, device, equipment and read/write memory medium
CN107070691A (en) Docker containers across host communication method and system
US11095716B2 (en) Data replication for a virtual networking system
CN112995247B (en) Method, device and system for transmitting or processing data
JP2008537400A (en) System, network apparatus, method and computer program product for balancing active load using clustered nodes as authoritative domain name servers
CN108551488A (en) Distributed container cluster load balancing method based on domestic CPU and OS
CN113676564B (en) Data transmission method, device and storage medium
CN114501593B (en) Network slice access method, device, system and storage medium
CN109450768B (en) Method for interconnecting containers and system for interconnecting containers
CN114650290B (en) Network communication method, processing device, terminal and storage medium
CN106790502B (en) Load balancing system of IPv4 terminal and IPv6 service intercommunication service based on NAT64 prefix
US9929951B1 (en) Techniques for using mappings to manage network traffic
CN116112435A (en) Message transmission method, device, equipment and storage medium
CN116781625A (en) Load balancing method, device, equipment and computer readable storage medium
CN116418724A (en) Service access method, device and load balancing system
CA2720222C (en) Spatial clustering
CN116582516B (en) Data transmission method, device, system, medium and program product
US11991142B1 (en) Providing cloud-aware security for an application level network device
CN115277628B (en) FULL NAT local IP implementation method
CN116132542A (en) Container network management method, container network plug-in and related equipment
Suh et al. Enabling SDN experimentation with wired and wireless resources: The smartFIRE facility

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