Load balancing method, system and device
By determining the target Pod in Kubernetes and forwarding the request to it, and combining the load balancing server cluster built with the BGP protocol, the load balancing performance loss and multi-computer room load balancing problems in Kubernetes are solved, and efficient load balancing and business mutual backup are achieved.
Patent Information
- Application Number
- CN202110323823.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-26
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-03-26
AI Technical Summary
During the fourth layer load balancing in Kubernetes, the requested data of the business party needs to be determined in Kube-proxy to actually forward the object, resulting in performance losses. The existing load balancing strategy is difficult to achieve business mutual backup and high-performance load balancing between multiple computer rooms. .
By responding to service requests from the business party, the target virtual network address is determined, based on the correspondence between the pre-stored virtual network address and the Pod and load balancing information, the candidate Pod collection is determined from the Kubernetes cluster, and the target is selected based on the preset load balancing policy and load state. Pod and forward the request to the target Pod to achieve load balancing. This method combines the load balancing server cluster built by the BGP protocol to obtain the load balancing information of Kubernetes, and dynamically adjust the number of load balancing servers to improve scalability and redundancy.
It realizes load balancing and service backup for different computer rooms, improves the performance and scalability of the load balancing system, reduces performance losses, and enhances the system's redundancy capabilities.
Smart Images

Figure CN113783922B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, specifically to the field of cloud technology, and more particularly to a method, system, and device for load balancing. Background Art
[0002] A container is a lightweight virtual machine at the operating system level. Due to its advantages such as light weight, convenience, and high performance, container technology is increasingly being used in the Internet field. As an application-oriented container cluster deployment and management system, Kubernetes has comprehensive cluster management capabilities, including multi-level security protection and access mechanisms, multi-tenant application support capabilities, transparent service registration and service discovery mechanisms, built-in load balancers, fault detection and self-healing capabilities, service rolling upgrades and online expansion, scalable resource automatic scheduling mechanisms, and multi-granular resource quota management capabilities. When implementing four-layer load balancing through the built-in Kube-proxy in Kubernetes, the business party's request data needs to be in Kube-proxy (i.e., user space) to determine the actual object (Pod) to be forwarded. This process will cause performance loss.
[0003] The load balancing strategy used in related technologies is usually to divert traffic based on the domain name of the business party. In practice, it is often necessary to perform business mutual backup and high-performance load balancing among multiple computer rooms. Summary of the invention
[0004] The embodiments of the present disclosure provide a method and device for load balancing.
[0005] In a first aspect, an embodiment of the present disclosure provides a load balancing method, the method comprising: responding to a service request from a business party, determining a target virtual network address pointed to by the service request, the target virtual network address pointing to a Service in a Kubernetes cluster that responds to the service request, and the Service being a collection of Pods with the same function; based on a pre-stored correspondence between a virtual network address and a Pod, determining a candidate Pod set corresponding to the target virtual network address from a currently available Pod list, the host machines of each candidate Pod in the candidate Pod set belonging to different physical computer rooms; based on a preset load balancing strategy and the current load status of each candidate Pod, determining a target Pod from the candidate Pod set; sending a service request to the target Pod; receiving and forwarding a response message generated by the target Pod in response to the service request; wherein the correspondence between the virtual network address and the Pod, the currently available Pod list, and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
[0006] In some embodiments, the method also includes: receiving a proxy process pushed by a Kubernetes cluster, the proxy process being used to instruct the following operations: receiving a virtual network address of a preset network domain; performing an availability check on each Pod corresponding to the virtual network address of the preset network domain to obtain a result of the availability check; and updating a currently available Pod list based on the result of the availability check.
[0007] In the second aspect, an embodiment of the present disclosure provides a load balancing system, including a load balancing server cluster and a Kubernetes cluster, wherein the load balancing server cluster is a server cluster built based on BGP, and is configured to: receive load balancing information of the Kubernetes cluster, and execute the load balancing method in any of the above embodiments based on the load balancing information; the Kubernetes cluster includes a controller cluster, a synchronization cluster and a Pod cluster, and the controller cluster is configured to: configure a Service based on business needs, where a Service is a collection of Pods with preset functions; interact with each Service through a synchronization cluster to schedule the Pods in each Service and obtain the running status of each Pod; generate load balancing information based on the configuration information of each Service and the running status of each Pod; and send the load balancing information to the load balancing server cluster.
[0008] In some embodiments, the host machine of each Pod in the Pod cluster belongs to a different physical computer room, the load balancing server cluster includes several load balancing server sub-clusters, and each physical computer room is deployed with at least one load balancing server sub-cluster.
[0009] In some embodiments, the controller cluster is further configured to: mark the load balancing identifier for the Service based on a pre-built correspondence between the load balancing identifier and the business requirements and the business requirements corresponding to the Service; determine the network domain of the Service and the virtual network address of the Service in the network domain based on a pre-built correspondence between the load balancing identifier and the network domain and the load balancing identifier of the Service.
[0010] In some embodiments, the controller cluster is configured to: based on business needs, determine a Pod set that responds to the business needs from the Pod cluster, divide the set into several Pod subsets based on the location of the host machine of each Pod in the set, determine each Pod subset as a Service, and determine the network domain of each Service and its virtual network address in the network domain based on the pre-built correspondence between business needs and network domains.
[0011] In some embodiments, the load balancing server cluster is further configured to: respond to a service request from a business party, resolve the domain name of the business party; based on a pre-built correspondence between the domain name and the load balancing server sub-cluster, send the service request to the target load balancing server sub-cluster corresponding to the domain name of the business party, and the target load balancing server sub-cluster executes the load balancing method in any of the above embodiments.
[0012] In some embodiments, each load balancing server in the load balancing server cluster uses a DPDK network card to send and receive messages, and the messages include service requests and response messages generated by the target Pod.
[0013] In some embodiments, the load balancing server cluster is also configured to: build a session control table based on the source address of the service request and the real network address of the target Pod; store the session control table to the target load balancing server, which is the load balancing server that sends the service request to the target Pod; the target load balancing server is also configured to forward the response message generated by the target Pod to the business party.
[0014] In a third aspect, an embodiment of the present disclosure provides a load balancing device, which includes: a service request parsing unit, configured to respond to a service request from a business party and determine a target virtual network address pointed to by the service request, the target virtual network address points to a Service cluster in a Kubernetes cluster that responds to the service request, and each Service in the Service cluster is a set of Pods with the same function; a candidate Pod determination unit, configured to determine a candidate Pod set corresponding to the target virtual network address from a currently available Pod list based on a pre-stored correspondence between the virtual network address and the Pod, and the host machines of each candidate Pod in the candidate Pod set belong to different physical computer rooms; a target Pod determination unit, configured to determine a target Pod from the candidate Pod set based on a preset load balancing strategy and the current load status of each candidate Pod; a service request forwarding unit, configured to send the service request to the target Pod; a response message forwarding unit, configured to receive and forward a response message generated by the target Pod in response to the service request; wherein the correspondence between the virtual network address and the Pod, the currently available Pod list, and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
[0015] In some embodiments, the device also includes: a proxy process unit, configured to receive a proxy process pushed by a Kubernetes cluster, the proxy process being used to perform the following operations: receiving a virtual network address of a preset network domain; performing an availability check on each Pod corresponding to the virtual network address of the preset network domain to obtain an availability check result; based on the availability check result, adding or deleting the Pod corresponding to the virtual network address of the preset network domain.
[0016] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement a load balancing method as in any embodiment.
[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, a load balancing method as in any of the above embodiments is implemented.
[0018] The load balancing method and device provided by the embodiments of the present disclosure determine a set of candidate Pods that respond to the service request from the backend Kubernetes cluster based on the service request of the business party, and then determine the target Pod based on the preset load balancing strategy and the running status of each candidate Pod, and forward the service request to the target Pod, which responds to the service request, and finally forwards the response message generated by the target Pod. Based on the received load balancing information of the Kubernetes cluster, the Pods deployed on the physical machines in different computer rooms can be load balanced, and load balancing and business mutual backup between different computer rooms can be achieved.
[0019] The load balancing system provided by the embodiment of the present disclosure uses a load balancing server cluster constructed using the BGP protocol to obtain the load balancing information of the backend business container from Kubernetes, and execute the load balancing strategy based on the load balancing information. The load balancing capability of the load balancing system can be improved by simply increasing the number of servers in the load balancing server cluster, thereby improving the scalability of the load balancing system. In addition, the load balancing server cluster can use the BGP protocol to route the data in each load balancing server to other load balancing servers, thereby achieving N+1 redundancy. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0021] Figure 1 is an exemplary system architecture diagram in which some embodiments of the present disclosure may be applied;
[0022] Figure 2 is a flow chart of an embodiment of a load balancing method according to the present disclosure;
[0023] Figure 3 is an architectural diagram of an embodiment of a load balancing system according to the present disclosure;
[0024] Figure 4 is a flow chart of an embodiment of a load balancing system according to the present disclosure;
[0025] Figure 5 is a structural diagram of an embodiment of a load balancing device according to the present disclosure;
[0026] Figure 6 It is a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0027] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] Figure 1 An exemplary system architecture 100 is shown to which a load balancing method or a load balancing apparatus according to an embodiment of the present disclosure can be applied.
[0030] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and servers 105, 106, 107, 108. Among them, server 105 is a load balancing server, servers 106, 107, 108 are business servers, and a container cluster is deployed on the business server, and the container cluster is scheduled and managed by Kubernetes. The network 104 is used to provide a medium for communication links between terminal devices 101, 102, 103 and server 105, and between server 105 and servers 106, 107, 108. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0031] The user can use the terminal devices 101, 102, and 103 to interact with the server 105 through the network 104 to receive or send messages, etc. For example, a service request can be sent to the server 105, and a response message sent by the server 105 can also be received. The generation process of the response message is as follows: the server 105 distributes the service request to the business server according to the preset load balancing strategy, and the container deployed on the business server responds to the service request and generates a response message. After that, the business server sends the response message to the server 105.
[0032] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be electronic devices with communication functions, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules for providing distributed services, or they can be implemented as a single software or software module. No specific limitation is made here.
[0033] The server 105 may be a server that provides load balancing services, for example, forwarding service requests sent by the terminal devices 101 , 102 , 103 and response messages sent by the service server.
[0034] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules for providing distributed services, or it can be implemented as a single software or software module. No specific limitation is made here.
[0035] It should be noted that the load balancing method provided in the embodiment of the present disclosure may be executed by the server 105. Accordingly, the load balancing device may be disposed in the server 105.
[0036] Continue to refer Figure 2 , shows a process 200 of an embodiment of a load balancing method according to the present disclosure. The load balancing method includes the following steps:
[0037] Step 201: In response to a service request from a business party, determine a target virtual network address to which the service request points.
[0038] In this embodiment, the target virtual network address points to the Service that responds to the service request in the Kubernetes cluster, and the Service is a collection of Pods with the same function.
[0039] Generally, Pod is the basic functional unit in Kubernetes. Each pod includes a group of containers that are closely related in terms of functions and services, and volumes shared by the group of containers. Containers are deployed on physical machines or virtual machines to execute preset programs. A collection of Pods with the same functions is called a Service. Kubernetes schedules containers and Pods at the management level in the form of Services. When it is necessary to call a function in a Service (for example, when receiving a service request from a business party), Kubernetes will make a call request to the Service instead of making a call request to a single Pod. Kubernetes assigns a ClusterIP (network address within the cluster) to each Service through Kube-proxy. The ClusterIP is the virtual network address of the Service. Each Service corresponds to a fixed virtual network address.
[0040] The execution subject of this embodiment can be a load balancing server or a load balancing service cluster. When the execution subject receives a service request from the business party, it can parse the destination address of the service request, which is the virtual network address of the Service in Kubernetes.
[0041] Step 202: Based on the pre-stored correspondence between virtual network addresses and Pods, a candidate Pod set corresponding to the target virtual network address is determined from a currently available Pod list.
[0042] In this embodiment, the host machines of the candidate Pods in the candidate Pod set belong to different physical computer rooms.
[0043] It is understandable that the container can be deployed on a physical machine or a virtual machine. The host machine in this embodiment represents the physical machine where each container in the Pod is located and / or the physical machine where the virtual machine is located. The physical computer room can be a data center where the cluster composed of host machines is located.
[0044] The currently available Pods represent the Pods that Kubernetes can call at the current moment, such as Pods that are idle or whose load is less than the preset load threshold. The currently available Pods include all the available Pods in Kubernetes at the current moment. Candidate Pods represent the Pods that can respond to the service request. The correspondence between the virtual network address and the Pod and the currently available Pod list are all from Kubernetes.
[0045] As an example, a proxy process may be run on the execution entity, which receives the correspondence between the virtual network address and the Pod and the currently available Pod list from the Kubernetes controller via GRPC (Google Remote Procedure Call), and then selects the Pod corresponding to the target virtual network address from the currently available Pod list based on the target virtual network address obtained in step 201, thereby obtaining a candidate Pod set.
[0046] Step 203: Based on a preset load balancing strategy and the current load status of each candidate Pod, a target Pod is determined from the candidate Pod set.
[0047] In this embodiment, the target Pod represents the Pod that responds to the service request of the business party. The execution subject can select the target Pod from the candidate Pod set according to the preset load balancing strategy. For example, the candidate Pod with the lowest load can be determined as the target Pod.
[0048] The load balancing strategy may be, for example, least load balancing, least connection load balancing, weighted round robin, etc., and this application does not impose any limitation on this.
[0049] Step 204: Send the service request to the target Pod.
[0050] In this embodiment, the execution subject can access each Pod in the Kubernetes cluster from the outside to distribute the service request of the business party directly to the target Pod. The access method may include Hostwork, Hostport, Nodeport, Loadbalancer, Ingress, etc., which is not limited in this application.
[0051] In a specific example, the execution subject can use the FULLAT mode to exchange information with the target Pod. The execution subject replaces the destination address of the service request with the network address of the target Pod in Kubernetes, and the source address with the local network address of the execution subject. The updated service request is then forwarded by the network card, thereby sending the updated service request to the target Pod. The network address of the target Pod in Kubernetes can be obtained in advance through the proxy process.
[0052] Step 205: Receive and forward a response message generated by the target Pod in response to the service request.
[0053] In this embodiment, the response message represents the result obtained after the target Pod performs the corresponding action for the service request. The source address of the response message is the network address of the target Pod in Kubernetes, and the destination address is the local network address of the execution subject.
[0054] As an example, after the execution entity receives the response message generated by the target Pod, the execution entity replaces the source address of the response message with the target virtual address obtained in step 201, and replaces the destination address of the response message with the network address of the business party (i.e., the source address of the service request in step 201), obtains an updated response message, and sends the updated response message by the network card, thereby feeding back the response result generated by the backend container for the service request of the business party to the business party.
[0055] In a specific example, the execution subject can be a load balancing server of an e-commerce platform. The e-commerce platform can have data centers set up in different locations. Containers are deployed on the business servers of the data centers, and the container clusters are scheduled through Kubernetes. Users of the e-commerce platform interact with the e-commerce platform through the client of the e-commerce platform. For example, a user can click "place an order" on the product page presented by the client of the e-commerce platform. The client of the e-commerce platform will send the "place an order" service request to the execution subject through the network. The destination address of the service request is the Service corresponding to the service type of "place an order" in the Kubernetes cluster. The Pods in the Service are all preset with programs for "place an order". The execution subject parses the target virtual network address of the service request, and determines the candidate Pod set corresponding to the target virtual network address from the currently available Pod list. Then, the candidate Pod with the lowest current running load is determined as the target Pod. After that, the execution subject sends the service request to the target Pod. The target Pod responds to the service request and generates a response message, for example, which may be confirmation information of the goods to be ordered, and sends the generated confirmation information of the goods to be ordered to the execution entity, which sends the confirmation information of the goods to be ordered to the user's terminal device, so that the client of the e-commerce platform loaded on the user's terminal device presents the confirmation information of the goods to be ordered.
[0056] In some optional implementations of this embodiment, the method also includes: receiving a proxy process pushed by a Kubernetes cluster, the proxy process being used to instruct the following operations: receiving a virtual network address of a preset network domain; performing an availability check on each Pod corresponding to the virtual network address of the preset network domain to obtain a result of the availability check; and updating a currently available Pod list based on the result of the availability check.
[0057] The virtual network address corresponds to the Service one-to-one, so the network domain in this implementation can represent the scope of the load balancing of the execution subject. The result of the availability test represents the running status of the Pod. If the running status of the Pod is abnormal, it means that the Pod is currently unavailable. Furthermore, if the Pod exists in the currently available Pod list, the Pod should be removed from the currently available Pod list.
[0058] Since the same Pod can be called by multiple Services, its running status is constantly changing. The running status of the Pod can be determined through availability detection. In this way, it is possible to avoid identifying an unavailable Pod as the target Pod, thereby improving the reliability of load balancing.
[0059] Furthermore, the execution entity in the present implementation may also determine the candidate Pod set by taking the following steps: determining the network domain where the target virtual address is located; determining the Service to which each virtual network address in the network domain points to, and obtaining a Service cluster; if each Pod in the Service cluster is in the currently available Pod list, then determining the Pod as a candidate Pod.
[0060] The load balancing method and device provided by the embodiments of the present disclosure determine a set of candidate Pods that respond to the service request from the backend Kubernetes cluster based on the service request of the business party, and then determine the target Pod based on the preset load balancing strategy and the running status of each candidate Pod, and forward the service request to the target Pod, which responds to the service request, and finally forwards the response message generated by the target Pod. Based on the received load balancing information of the Kubernetes cluster, the Pods deployed on the physical machines in different computer rooms can be load balanced, and load balancing and business mutual backup between different computer rooms can be achieved.
[0061] Continue to see Figure 3 , Figure 3 An architecture diagram of an embodiment of the load balancing system disclosed in the present invention is as follows: Figure 3As shown, the load balancing system 300 includes: a load balancing server cluster 301 and a Kubernetes cluster 302, wherein the load balancing server cluster 301 is a server cluster built based on BGP, and is configured to: receive load balancing information of the Kubernetes cluster 302, and execute the load balancing method in any of the above embodiments based on the load balancing information; the Kubernetes cluster 302 includes a controller cluster 3021, a synchronization cluster 3022 and a Pod cluster 3023, and the controller cluster 3021 is configured to: configure a Service based on business needs, where a Service is a collection of Pods with preset functions; interact with each Service through the synchronization cluster 3022 to schedule the Pods in each Service and obtain the running status of each Pod; generate load balancing information based on the configuration information of each Service and the running status of each Pod; and send the load balancing information to the load balancing server cluster 301.
[0062] In this embodiment, the backend of the load balancing system is a container cluster built on Kubernetes. The container cluster is deployed on the business server in the computer room and can provide various types of services for the business party. The operator of the load balancing system can schedule each container through Kubernetes, such as deleting or adding Pods, configuring Services, and deploying external access ports in Pods. The load balancing server cluster is used to distribute the service requests of the business party to the backend containers, thereby realizing four-layer load balancing. The load balancing server cluster can interact with the backend container in an external access manner, for example, it can receive load balancing information from the controller cluster, send the service request of the business party to the Pod, and forward the response message generated by the backend Pod.
[0063] In this embodiment, the load balancing server cluster can be a physical machine cluster, or a cluster composed of virtual machines deployed on physical machines, or a combination of the two. The load balancing servers use the BGP protocol for data exchange, so that each load balancing server can route data to other load balancing servers by BGP, ensuring that after a single load balancing server fails or recovers, the load balancing server can be dynamically added or deleted, thereby realizing the horizontal expansion and contraction of the load balancing server cluster.
[0064] In some optional implementations of this embodiment, the host machines of each Pod in the Pod cluster belong to different physical computer rooms, and the load balancing server cluster includes several load balancing server sub-clusters, and each physical computer room is deployed with at least one load balancing server sub-cluster. Figure 3 The physical machine room 1 and the physical machine room 2 are shown in FIG.
[0065] In this way, load balancing and business backup can be achieved between different physical computer rooms, and business-level disaster recovery can be realized.
[0066] Furthermore, the load balancing server cluster is also configured to: respond to the service request of the business party, resolve the domain name of the business party; based on the pre-built correspondence between the domain name and the load balancing server sub-cluster, send the service request to the target load balancing server sub-cluster corresponding to the domain name of the business party, and the target load balancing server sub-cluster executes the load balancing method in the above embodiment.
[0067] As an example, the correspondence between the domain name and the load balancing server sub-cluster can be established based on the distance between the geographical area represented by the domain name and the physical computer room, and each load balancing server sub-cluster corresponds to service requests in a geographical area; the correspondence between the domain name and the load balancing server sub-cluster can also be established based on the attributes of the business party represented by the domain name (such as educational institutions, government departments, and other institutional attributes), and the load balancing server sub-cluster corresponds to service requests with one or several attributes.
[0068] Exemplarily, the load balancing server cluster includes a first load balancing server sub-cluster and a second load balancing server sub-cluster, wherein the first load balancing server sub-cluster is set at location A, the second load balancing server sub-cluster is set at location B, and the business party is located at location C, wherein location C is closer to location B. After the load balancing server cluster receives the service request from the business party, it can distribute the service request to the second load balancing server sub-cluster, and the second load balancing server sub-cluster executes the load balancing strategy.
[0069] In this way, the service requests of the business party can be distributed to different load balancing server subclusters based on the domain name of the business party, which can further improve the efficiency of load balancing.
[0070] Further integration Figure 4 For example, Figure 4 400 is a flow chart of an embodiment of a load balancing system of the present disclosure. Figure 4 As shown, the process includes the following steps:
[0071] In step 4011, the controller cluster sends a scheduling instruction to the synchronization cluster, which may be an instruction to add or delete a Pod, or an instruction to assign a Service virtual network address, etc.
[0072] In step 4012, the synchronization cluster sends the scheduling instruction sent by the controller cluster to the specified Service, and the Service executes the operation indicated by the scheduling instruction, such as assigning the virtual network address of the Service, adding, reducing or deleting Pods in the Service, and deploying external access ports in the Pods.
[0073] In step 4013, the Pod cluster sends the running status of each Pod to the synchronization cluster. The running status can represent the load status of the Pod.
[0074] Step 4014, the synchronization cluster sends the running status of each Pod to the controller cluster.
[0075] Through step 4011 to step 4014, scheduling and information interaction within the backend Kubernetes cluster are implemented.
[0076] In step 4015, the control cluster generates load balancing information based on the configuration information of each Service and the acquired running status of each Pod. As an example, the configuration information of the Service may include the virtual network address of the Service, the Nodeport of the Service, the network address of the Pod in the Service within the Kubernetes cluster, the external access port of the Pod in the Service, etc.
[0077] It can be seen that the backend Kubernetes cluster can generate load balancing information through steps 4011 to 4015.
[0078] Step 401: The controller cluster sends the load balancing information to the load balancing server cluster. For example, the controller cluster may push a proxy process to the load balancing server cluster, and then use GPRC to call the proxy process to send the load balancing information to the load balancing server cluster.
[0079] Step 402: The business party sends the service request to the load balancing server cluster.
[0080] Step 403: The load balancing server cluster executes the load balancing method in the above embodiment to determine a target Pod that responds to the service request.
[0081] Step 404: forward the service request to the target Pod.
[0082] Step 405: The target Pod responds to the service request and generates a response message according to the response result.
[0083] Step 406: The target Pod sends a response message to the load balancing server cluster.
[0084] Step 407: The load balancing server cluster forwards the response message to the business party.
[0085] In practice, the load balancing server cluster can configure a local network address for each load balancing server and write the local network address into the network card configuration. After receiving the service request from the business party, the load balancing server cluster can route the service request to one of the load balancing servers based on the principle of proximity, and the load balancing server will execute the above load balancing method.
[0086] In some optional implementations of this embodiment, the load balancing server cluster is also configured to: build a session control table based on the source address of the service request and the real network address of the target Pod; store the session control table to the target load balancing server, which is the load balancing server that sends the service request to the target Pod; the target load balancing server is also configured to forward the response message generated by the target Pod to the business party.
[0087] In this implementation, the session control table represents the session information between the business party and the target load balancing server, and the real network address of the target Pod represents the network address of the target Pod that can be accessed from the outside by the load balancing server cluster, for example, it can be the network address of the target Pod in the Kubernetes cluster. The load balancing server that forwards the response message is determined based on the session control table, and the interaction between the business party and the backend can be processed by the same load balancing server, which helps to improve the efficiency of the interaction.
[0088] In some optional implementations of this embodiment, each load balancing server in the load balancing server cluster uses a DPDK network card to send and receive messages, and the messages include service requests and response messages generated by the target Pod.
[0089] DPDK network cards have the advantages of easy development, easy porting, and higher message forwarding efficiency. Therefore, using DPDK network cards to send and receive messages can further improve the efficiency of forwarding messages in the load balancing server cluster.
[0090] The load balancing system provided by the embodiment of the present disclosure uses a load balancing server cluster constructed using the BGP protocol to obtain the load balancing information of the backend business container from Kubernetes, and execute the load balancing strategy based on the load balancing information. The load balancing capability of the load balancing system can be improved by simply increasing the number of servers in the load balancing server cluster, thereby improving the scalability of the load balancing system. In addition, the load balancing server cluster can use the BGP protocol to route the data in each load balancing server to other load balancing servers, thereby achieving N+1 redundancy.
[0091] In some optional implementations of this embodiment, the controller cluster is further configured to: mark the load balancing identifier for the Service based on a pre-built correspondence between the load balancing identifier and the business requirements and the business requirements corresponding to the Service; determine the network domain of the Service and the virtual network address of the Service in the network domain based on a pre-built correspondence between the load balancing identifier and the network domain and the load balancing identifier of the Service.
[0092] In this implementation, the load balancing identifier represents the service category provided by the Pod cluster. Multiple services with the same service category can correspond to the same load balancing identifier, so that each service in the Kubernetes cluster can be classified based on the service category for easy management and scheduling. In addition, multiple services with the same service category are in the same network domain. When the load balancing server cluster receives a service request from the business party, it can identify the Pods in all Services in the network domain where the virtual network address pointed to by the service request is located as the Pods that can respond to the service request, thereby expanding the number of Pods for the corresponding service request and helping to improve the efficiency of load balancing.
[0093] In some optional implementations of this embodiment, the controller cluster is configured to: based on business needs, determine from the Pod cluster a Pod set that responds to the business needs, divide the set into several Pod subsets based on the location of the host machine of each Pod in the set, determine each Pod subset as a Service, and determine the network domain of each Service and its virtual network address in the network domain based on the pre-built correspondence between business needs and network domains.
[0094] In this implementation, the Service can also be configured from the dimension of the Pod's host machine location, so that the Pods in each Service all belong to the same physical computer room. When the load balancing server cluster receives a service request from the business party, the Pods in all Services in the network domain where the virtual network address pointed to by the service request is located can be determined as Pods that can respond to the service request. The host machines of the Pods that respond to the service request belong to different physical computer rooms, which can achieve cross-computer room load balancing and business mutual backup, and facilitate Pod scheduling and management.
[0095] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a load balancing device. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0096] like Figure 5 As shown, the load balancing device 500 of this embodiment includes: a service request parsing unit 501, which is configured to respond to the service request of the business party and determine the target virtual network address pointed to by the service request, the target virtual network address points to the Service cluster in the Kubernetes cluster that responds to the service request, and each Service in the Service cluster is a set of Pods with the same function; a candidate Pod determination unit 502, which is configured to determine the candidate Pod set corresponding to the target virtual network address from the currently available Pod list based on the pre-stored correspondence between the virtual network address and the Pod, and the host machines of each candidate Pod in the candidate Pod set belong to different physical computer rooms; a target Pod determination unit 503, which is configured to determine the target Pod from the candidate Pod set based on the preset load balancing strategy and the current load status of each candidate Pod; a service request forwarding unit 504, which is configured to send the service request to the target Pod; a response message forwarding unit 505, which is configured to receive and forward the response message generated by the target Pod in response to the service request; wherein the correspondence between the virtual network address and the Pod, the currently available Pod list and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
[0097] In this embodiment, the device 500 also includes: a proxy process unit, configured to receive a proxy process pushed by a Kubernetes cluster, and the proxy process is used to perform the following operations: receiving a virtual network address of a preset network domain; performing an availability check on each Pod corresponding to the virtual network address of the preset network domain to obtain a result of the availability check; based on the result of the availability check, adding or deleting the Pod corresponding to the virtual network address of the preset network domain.
[0098] Reference below Figure 6 , which shows an electronic device (eg, Figure 1 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0099] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0100] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0101] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are executed. It should be noted that the computer-readable medium described in the embodiment of the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, an apparatus, or a device. In an embodiment of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, an apparatus, or a device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the foregoing.
[0102] The computer-readable medium may be included in the electronic device; or it may exist separately without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: responds to the service request of the business party, determines the target virtual network address pointed to by the service request, the target virtual network address points to the Service in the Kubernetes cluster that responds to the service request, and the Service is a collection of Pods with the same function; based on the correspondence between the pre-stored virtual network address and the Pod, determines the candidate Pod set corresponding to the target virtual network address from the currently available Pod list, and the host machines of each candidate Pod in the candidate Pod set belong to different physical computer rooms; based on the preset load balancing strategy and the current load status of each candidate Pod, determines the target Pod from the candidate Pod set; sends the service request to the target Pod; receives and forwards the response message generated by the target Pod in response to the service request; wherein the correspondence between the virtual network address and the Pod, the currently available Pod list, and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
[0103] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0104] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The described units may also be provided in a processor, for example, may be described as: a processor including a service request parsing unit, a candidate Pod determination unit, a target Pod determination unit, a service request forwarding unit, and a response message forwarding message. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances. For example, the service request parsing unit may also be described as "a unit that determines the target virtual network address pointed to by the service request in response to the service request of the business party."
[0106] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) to form a technical solution.
Claims
1. A load balancing method, in, include: In response to the service request of the business party, determine the target virtual network address pointed to by the service request, wherein the target virtual network address points to the Service in the Kubernetes cluster that responds to the service request, and the Service is a collection of Pods with the same function; Based on the pre-stored correspondence between the virtual network address and the Pod, a candidate Pod set corresponding to the target virtual network address is determined from the currently available Pod list, wherein the host machines of each candidate Pod in the candidate Pod set belong to different physical computer rooms, and the currently available Pod list includes the Pods in the Kubernetes cluster that are currently running normally; Based on a preset load balancing strategy and the current load status of each candidate Pod, determine a target Pod from the candidate Pod set; Send the service request to the target Pod; Receive and forward the response message generated by the target Pod in response to the service request; Among them, the corresponding relationship between the virtual network address and the Pod, the currently available Pod list, and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
2. The method according to claim 1, further comprising: include: Receive the proxy process pushed by the Kubernetes cluster, the proxy process is used to instruct the following operations: Receive a virtual network address of a preset network domain; perform availability detection on each Pod corresponding to the virtual network address of the preset network domain to obtain a result of the availability detection; and update the currently available Pod list based on the result of the availability detection.
3. A load balancing system, including a load balancing server cluster and a Kubernetes cluster, in, The load balancing server cluster is a server cluster built based on BGP (Border Gateway Protocol), and is configured to: receive load balancing information of the Kubernetes cluster, and execute the load balancing method according to claim 1 or 2 based on the load balancing information; The Kubernetes cluster includes a controller cluster, a synchronization cluster and a Pod cluster. The controller cluster is configured to: configure Services based on business needs, where the Services are a collection of Pods with preset functions; interact with each Service through the synchronization cluster to schedule the Pods in each Service and obtain the running status of the Pods in each Service; generate load balancing information based on the configuration information of each Service and the running status of the Pods in each Service; and send the load balancing information to the load balancing server cluster.
4. The system according to claim 3, in, The host machines of each Pod in the Pod cluster belong to different physical computer rooms. The load balancing server cluster includes several load balancing server sub-clusters, and each of the physical computer rooms is deployed with at least one load balancing server sub-cluster.
5. The system according to claim 4, in, The controller cluster is further configured to: mark the load balancing identifier for the Service based on the pre-built correspondence between the load balancing identifier and the business requirement and the business requirement corresponding to the Service; Based on the pre-constructed correspondence between the load balancing identifier and the network domain and the load balancing identifier of the Service, the network domain of the Service and the virtual network address of the Service in the network domain are determined.
6. The system according to claim 4, in, The controller cluster is configured as follows: Based on business needs, a Pod set that responds to the business needs is determined from the Pod cluster, and based on the location of the host machine of each Pod in the set, the set is divided into several Pod subsets, each of the Pod subsets is determined as a Service, and based on the pre-built correspondence between business needs and network domains, the network domain of each Service and its virtual network address in the network domain are determined.
7. The system according to claim 6, in, The load balancing server cluster is also configured as follows: Responding to a service request from a business party, resolving the domain name of the business party; Based on the pre-constructed correspondence between the domain name and the load balancing server sub-cluster, the service request is sent to the target load balancing server sub-cluster corresponding to the domain name of the business party, and the target load balancing server sub-cluster executes the load balancing method described in claim 1 or 2.
8. The system according to claim 3, in, Each load balancing server in the load balancing server cluster uses a DPDK (Data Plane Development Kit) network card to send and receive messages, and the messages include the service request and a response message generated by the target Pod.
9. The system according to any one of claims 3 to 8, in, The load balancing server cluster is also configured as follows: Constructing a session control table based on the source address of the service request and the real network address of the target Pod; Storing the session control table to a target load balancing server, where the target load balancing server is a load balancing server that sends the service request to the target Pod; The target service balancing server is also configured to forward the response message generated by the target Pod to the business party.
10. A load balancing device, in, include: A service request parsing unit is configured to respond to a service request from a business party and determine a target virtual network address to which the service request points, wherein the target virtual network address points to a Service cluster in a Kubernetes cluster that responds to the service request, and each Service in the Service cluster is a collection of Pods with the same function; A candidate Pod determination unit is configured to determine, based on a pre-stored correspondence between a virtual network address and a Pod, a candidate Pod set corresponding to the target virtual network address from a currently available Pod list, wherein a host machine of each candidate Pod in the candidate Pod set belongs to a different physical computer room, and the currently available Pod list includes Pods in the Kubernetes cluster that are currently in normal operation; A target Pod determination unit is configured to determine a target Pod from the candidate Pod set based on a preset load balancing strategy and a current load status of each candidate Pod; A service request forwarding unit, configured to send the service request to the target Pod; A response message forwarding unit, configured to receive and forward a response message generated by the target Pod in response to the service request; Among them, the corresponding relationship between the virtual network address and the Pod, the currently available Pod list, and the current load status of each candidate Pod are load balancing information, and the load balancing information is obtained from the Kubernetes cluster.
11. The device according to claim 10, further comprising: include: The proxy process unit is configured to receive the proxy process pushed by the Kubernetes cluster, and the proxy process is used to perform the following operations: Receive a virtual network address of a preset network domain; perform an availability check on each Pod corresponding to the virtual network address of the preset network domain to obtain a result of the availability check; and update the currently available Pod list based on the result of the availability check.
12. An electronic device, include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the load balancing method as described in any one of claims 1 or 2.
13. A computer readable medium having a computer program stored thereon, in, When the program is executed by a processor, the load balancing method as described in any one of claims 1 or 2 is implemented.
