WO2021120633A1 - 一种负载均衡方法及相关设备 - Google Patents

一种负载均衡方法及相关设备 Download PDF

Info

Publication number
WO2021120633A1
WO2021120633A1 PCT/CN2020/106021 CN2020106021W WO2021120633A1 WO 2021120633 A1 WO2021120633 A1 WO 2021120633A1 CN 2020106021 W CN2020106021 W CN 2020106021W WO 2021120633 A1 WO2021120633 A1 WO 2021120633A1
Authority
WO
WIPO (PCT)
Prior art keywords
pod
node
weight
pods
target
Prior art date
Application number
PCT/CN2020/106021
Other languages
English (en)
French (fr)
Inventor
钟国城
徐新海
程宝传
王云龙
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20901734.2A priority Critical patent/EP4068725A4/en
Publication of WO2021120633A1 publication Critical patent/WO2021120633A1/zh
Priority to US17/843,754 priority patent/US20220318071A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/101Server selection for load balancing based on network conditions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/12Discovery or management of network topologies
    • H04L41/122Discovery or management of network topologies of virtualised topologies, e.g. software-defined networks [SDN] or network function virtualisation [NFV]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/12Discovery or management of network topologies
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1023Server selection for load balancing based on a hash applied to IP addresses or costs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/505Clust
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Definitions

  • This application relates to the field of computer technology, and in particular to a load balancing method and related equipment.
  • Load balancing refers to distributing task requests to multiple nodes in a load balancing cluster according to a scheduling algorithm, thereby improving the task processing capability of the load balancing cluster.
  • load balancing in the container orchestration and management platform for example, Kubernetes
  • the container orchestration and management platform is implemented by deploying distributed software on the nodes of the load balancing cluster, and the distributed software distributes tasks according to the existing scheduling algorithm
  • the method of request is likely to cause additional network overhead. Therefore, how to save network overhead when distributing task requests is a technical problem being studied by those in the art.
  • This application discloses a load balancing method and related equipment, which can save network overhead when distributing task requests.
  • the first aspect of this application discloses a load balancing method, including:
  • the multiple Pods in the load balancing cluster to which the first node belongs where the multiple Pods are distributed on at least two nodes, for example, some are distributed on the first node , Some are distributed on the node connected to the same top-of-rack switch as the first node, some are distributed on the node connected to the same leaf switch as the first node, and some are distributed on the same node as the first node.
  • the number of Pods distributed on each of the at least two nodes is not limited here;
  • a target Pod is selected from the plurality of Pods according to the weight of each Pod, where the target Pod is used to process tasks currently to be processed in the first node.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the distance between the node where each Pod is located and the first node.
  • the number of layers of the switch, and then according to the weight value of each pod, the target Pod with a small number of layers across the switch can be selected to process the tasks currently to be processed in the first node, avoiding the choice of Pod processing with a large number of layers across the switch
  • the task currently to be processed in the first node reduces network overhead.
  • the determining the topology information of each of the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs includes:
  • the first node does not need to collect the LLDP information of other computing nodes, and directly receives the topology information of each Pod among the multiple Pods sent by the control node, which is faster and saves the time for selecting the target Pod.
  • the determining the topology information of each of the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs includes:
  • the topology information of each Pod in the plurality of Pods is generated.
  • the first node needs to communicate with at least two nodes, collect LLDP information of at least two nodes, and generate topology information of each of multiple Pods based on real-time collection of LLDP information. This kind of topology information generation Way, more accurate.
  • the Pod with the smallest weight may be selected from the plurality of Pods as the target Pod. Since the Pod with the smallest weight and the first node have the smallest number of cross-switch layers, the target Pod selected in this way under the same load conditions can save network overhead.
  • the target Pod may be selected from the multiple Pods according to the load of each Pod in the multiple Pods and the weight of each Pod.
  • the method further includes:
  • the task currently to be processed in the first node is directed to the target Pod to instruct the target Pod to process the task currently to be processed.
  • this application provides a load balancing device, including:
  • the first determining unit is configured to determine the topology information of each Pod in the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs, and the multiple Pods are distributed on at least two nodes;
  • the second determining unit is configured to determine the weight of each Pod according to the topology information of each Pod in the plurality of Pods;
  • the selection unit is configured to select a target Pod from the multiple Pods according to the weight of each Pod, where the target Pod is used to process a task currently to be processed in the first node.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the distance between the node where each Pod is located and the first node.
  • the number of layers of the switch, and then according to the weight value of each pod, the target Pod with a small number of layers across the switch can be selected to process the tasks currently to be processed in the first node, avoiding the choice of Pod processing with a large number of layers across the switch
  • the tasks currently pending in the first node cause additional network overhead.
  • the first determining unit is configured to receive topology information of each Pod in the plurality of Pods sent by the control node.
  • the first node does not need to collect the LLDP information of other computing nodes, and directly receives the topology information of each Pod among the multiple Pods sent by the control node, which is faster and saves the time for selecting the target Pod.
  • the first determining unit is configured to collect link layer discovery protocol LLDP information of the at least two nodes; according to the LLDP information of the at least two nodes, Generate topology information of each Pod in the plurality of Pods.
  • the first node needs to communicate with at least two nodes, collect LLDP information of at least two nodes, and generate topology information of each of multiple Pods according to real-time collection of LLDP information. This kind of topology information generation Way, more accurate.
  • the selection unit is configured to select the Pod with the smallest weight from the multiple Pods as the target Pod when the load of each Pod in the multiple Pods is the same;
  • the smallest Pod and the first node have the least number of cross-switch layers, so the target Pod selected in this way under the same load conditions can save network overhead.
  • the selection unit is configured to, in a case where the loads of the multiple Pods are different, from the multiple Pods according to the load of each Pod in the multiple Pods and the weight of each Pod
  • the target Pod is selected in the selection; the method of selecting the target Pod by comprehensively considering the weight value of each Pod and the load of each Pod can balance load balancing and saving network overhead, and improve the overall load balancing cluster performance.
  • the device further includes:
  • An orienting unit configured to orient the task currently to be processed in the first node to the target after the selecting unit selects a target Pod from the multiple Pods according to the weight of each Pod Pod to instruct the target Pod to process the task currently to be processed.
  • the present application provides a first node, the first node includes a processor, a memory, and a communication interface, the memory is used to store a computer program, and the processor calls the computer program to execute Do as follows:
  • a target Pod is selected from the plurality of Pods according to the weight of each Pod, where the target Pod is used to process tasks currently to be processed in the first node.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the difference between the node where each Pod is located and the first node.
  • the number of layers between the switches then you can select the target Pod with a small number of layers across the switches according to the weight value of each pod to process the tasks currently to be processed in the first node, avoiding the choice of a large number of layers across the switches Pod processes the tasks currently pending in the first node, causing additional network overhead.
  • the processor in terms of determining the topology information of each Pod in the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs, the processor is configured to:
  • the first node does not need to collect the LLDP information of other computing nodes, and directly receives the topology information of each Pod among the multiple Pods sent by the control node, which is faster and saves the time for selecting the target Pod.
  • the processor in terms of determining the topology information of each Pod in the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs, the processor is configured to:
  • the topology information of each Pod in the plurality of Pods is generated.
  • the first node needs to communicate with at least two nodes, collect LLDP information of at least two nodes, and generate topology information of each of multiple Pods based on real-time collection of LLDP information. This kind of generated topology The way of information is more accurate.
  • the processor in terms of selecting a target Pod from the plurality of Pods according to the weight of each Pod, the processor is configured to:
  • the Pod with the smallest weight is selected from the multiple Pods as the target Pod; since the Pod with the smallest weight and the first node have the smallest number of cross-switch layers Therefore, the target Pod selected in this way can save network overhead when the load is the same.
  • the target Pod is selected from the multiple Pods according to the load of each Pod in the multiple Pods and the weight of each Pod; by comprehensively considering each Pod
  • the method of selecting the target Pod based on the size of the weight value and the load of each Pod can balance load balancing and saving network overhead, and improve the overall performance of the load balancing cluster.
  • the processor is further configured to:
  • the task currently to be processed in the first node is directed to the target Pod to instruct the target Pod to process the target Pod. Describe the tasks currently pending.
  • the load balancing cluster includes a control node and at least two computing nodes, and the first node is the One of at least two computing nodes, the control node is used to manage the at least two computing nodes, and the multiple Pods are distributed on the at least two computing nodes.
  • the weight of the Pod in the first node is the first weight
  • the weight of the Pod in the second node is the second weight.
  • the second node and the first node are connected to the same top-of-rack switch, and the Internet Protocol IP address of the second node is the same as that of the first node.
  • the IP addresses belong to the same network segment;
  • the weight of the Pod in the third node is the third weight, the third node and the first node are connected to different top-of-rack switches, and the different top-of-rack switches are connected to the same leaf switch;
  • the weight of the Pod in the fourth node is the fourth weight, the fourth node and the first node are connected to different leaf switches, and the different leaf switches are connected to the same spine switch;
  • the first weight ⁇ the second weight ⁇ the third weight ⁇ the fourth weight.
  • the present application provides a computer-readable storage medium that stores a computer program that, when executed by a processor, causes the processor to implement the first aspect or the first aspect. Any one of the options described in the method.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the distance between the node where each Pod is located and the first node.
  • the number of layers of the switch, and then according to the weight value of each pod, the target Pod with a small number of layers across the switch can be selected to process the tasks currently to be processed in the first node, avoiding the choice of Pod processing with a large number of layers across the switch
  • the tasks currently pending in the first node cause additional network overhead.
  • FIG. 1 is a schematic diagram of the architecture of a load balancing cluster provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a process of distributing a task request provided by an embodiment of the present application
  • FIG. 3 is a schematic flowchart of a load balancing method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of topology information of each Pod in multiple Pods in multiple nodes according to an embodiment of the present application
  • FIG. 5 is a schematic diagram of a control node sending the topology information of each Pod in multiple Pods among multiple nodes to a first node according to an embodiment of the present application;
  • FIG. 6 is a schematic diagram of node 1 generating topology information of each Pod in node 1 and node 2 according to the LLDP information of node 1 and node 2 according to an embodiment of the present application;
  • FIG. 7 is a schematic structural diagram of a load balancing device provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of another load balancing device provided by an embodiment of the present application.
  • FIG. 1 is a schematic diagram of the architecture of a load balancing cluster provided by an embodiment of the present application.
  • the load balancing cluster may include a control node 101 and at least two computing nodes 102 (102a-102e are shown in the figure) , Where each of the control node 101 and the at least two computing nodes 102 may be a server or a virtual machine on a cloud platform.
  • the control node 101 is used to manage the at least two computing nodes 102.
  • the at least two computing nodes 102 are load balancing nodes, which are used to select Pods in the computing nodes to process tasks to be processed.
  • the task to be processed may be a request to open a video software, a request to access a certain website, and so on.
  • each computing node may include one or more minimum management unit Pods.
  • the above load balancing cluster can be a container orchestration and management platform (such as Kubernetes, k8s) cluster or other operating environment cluster.
  • Kubernetes is a cross-host cluster open source container scheduling platform, which can make containerized applications simple and efficient Local deployment provides a mechanism for application deployment, planning, updating, and maintenance.
  • the traditional way of application deployment is to install applications through plug-ins or scripts.
  • the disadvantage of this is that the operation, configuration, management, and life cycle of the application will be bound to the current operating system. This is not conducive to application upgrades/rollbacks and other operations.
  • each container When using Kubernetes to deploy containers, each container is isolated from each other, and each container has its own file system. The processes between the containers will not affect each other and can distinguish computing resources. Compared with virtual machines, containers can be deployed quickly. Since containers are decoupled from the underlying facilities and machine file systems, they can be migrated between different clouds and different versions of operating systems.
  • Pod is the smallest management unit in a Kubernetes cluster. It is the smallest component created or deployed by users. It is also a resource object used when running containerized applications on the Kubernetes cluster. Each Pod is assigned a unique IP address. Each Pod contains If one or more containers are added, the containers in the same Pod will be allocated to the same node. The containers inside the Pod share the network space of the Pod, including the IP address and port. The containers inside the Pod can use the Pod's host to communicate with each other. When the container inside the Pod communicates with the outside world, it must use the network resources allocated for the Pod.
  • the containers inside the Pod can access the shared storage volume (volume), which can also be used to persist storage resources in the Pod to prevent file loss after the container is restarted.
  • the containers in the Pod are always scheduled at the same time and have a common operating environment.
  • Load balancing scheduling algorithms include static scheduling algorithms and dynamic scheduling algorithms. The following is a brief introduction to static scheduling algorithms and dynamic scheduling algorithms.
  • Static scheduling algorithm Distribute service requests according to a certain established algorithm, regardless of the number of real-time connections.
  • the roundrobin (RR) algorithm is used to distribute external requests to the nodes in the cluster in turn, and it treats each node equally, regardless of the actual number of connections and load on the node.
  • a weighted round robin (WRR) algorithm is used to assign a weight to each node in the cluster. The larger the weight, the more requests are allocated.
  • the destination hashing (DH) algorithm is used to find the corresponding node from the statically allocated hash table according to the requested destination IP address as a hash key. If the node is available and unavailable Overload, send the request to this node, otherwise return empty. Requests from the same IP address are all redirected to the same node to ensure that the target address remains unchanged.
  • DH destination hashing
  • the source hashing (SH) algorithm is used to find the corresponding node from the statically allocated hash table according to the requested source IP address as a hash key. If the node is available and not yet Overload, send the request to this node, otherwise return empty.
  • SH source hashing
  • Dynamic scheduling algorithm By checking the active status of the current number of connections on the node, the next scheduling method is re-decided.
  • the least connection (LC) algorithm is adopted, that is, the next connection request is directed to the node with the few connections on which node has a few connections.
  • Algorithm implementation: the number of connections the number of active connections * 256 + the number of inactive connections.
  • a weighted least-connection (WLC) algorithm is used, that is, a weight is assigned to each node on the basis of the least-connection.
  • WLC weighted least-connection
  • the never-queue (NQ) algorithm is used.
  • the never-queue algorithm is an improvement of the SED algorithm. When a new request comes, it not only depends on the value obtained by the SED algorithm, but also depends on whether the node is There are active connections.
  • the locality-based least-connection (LBLC) algorithm is adopted, that is, the number of active connections on the node must be considered on the basis of the DH algorithm.
  • FIG. 2 is a schematic diagram of the process of distributing task requests.
  • the smallest management unit Pod1 in node 1 is the client that initiates the request
  • node 1 and node 2 are connected to the same top-of-rack switch
  • node 1 distributes the task request to Pod 4 in node 2
  • Pod 4 actually provides services .
  • the task request is not distributed to Pod2 in node 1, causing additional network overhead.
  • Figure 3 is a load balancing method provided by an embodiment of the present application.
  • the method can be implemented based on the load balancing cluster shown in Figure 1.
  • the method includes but is not limited to the following steps:
  • Step S301 The first node determines the topology information of each of the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs.
  • the first node is a node in a load balancing cluster, for example, a computing node; the multiple Pods are distributed on at least two nodes in the load balancing cluster, for example, some are distributed on the first node, and some are distributed on On the nodes connected to the same top-of-rack switch as the first node, some are distributed on the nodes connected to the same leaf switch as the first node, and some are distributed on the nodes connected to the same spine switch as the first node ;
  • the number of Pods distributed on each of the at least two nodes is not limited here.
  • the multiple Pods can all process tasks currently to be processed in the first node, and the topology information of each Pod indicates the node where each Pod is located and the connection relationship between the node where the Pod is located and other nodes.
  • node 1 is the first node
  • Pod1 in node 1 is the client who initiated the request
  • both Pod3 and Pod4 in node 2 can provide services for the request
  • Pod5 and Pod6 in node 3 can both provide services for the request
  • Pod7 and Pod8 in node 4 can also provide services for the request.
  • node 1 determines that node 2 and node 1 belong to the same network segment according to the Internet Protocol address of node 2 as 10.1.10.2, and is connected to the same top-of-rack switch; node 1 determines the node according to the IP address of node 3 as 10.1.11.2 3 is connected to top-of-rack switch 2, node 1 is connected to top-of-rack switch 1, top-of-rack switch 1 and top-of-rack switch 2 are connected to the same leaf switch 1; node 1 is determined according to the IP address of node 4 as 10.1.12.2 Node 4 is connected to top-of-rack switch 3, top-of-rack switch 3 is connected to leaf switch 2, and node 1 is connected to top-of-rack switch 1, top-of-rack switch 1 is connected to leaf switch 1, and leaf switch 1 and leaf switch 2 are connected to the same spine switch 1. . Finally, the topology information of each Pod in the multiple Pods in the multiple nodes determined by the node 1 may be as shown in FIG. 4.
  • the methods for determining the topology information of each Pod in the load balancing cluster include but are not limited to the following two:
  • Manner 1 Receive topology information of each Pod in the multiple Pods sent by the control node.
  • FIG. 5 shows a process in which the control node sends the topology information of each Pod in the multiple Pods of the multiple nodes to the first node.
  • node A is the control node
  • node B is the first node.
  • the default distributed key-value database (etcd) of the load balancing cluster during deployment saves the deployment status of each computing node and the deployment status of the Pod in each computing node; optionally, users can define each of the load balancing clusters. How to deploy the node and the Pod in the node.
  • control node sends the topology information of each Pod in the multiple Pods of the multiple nodes to the first node, and correspondingly, the first node receives the topology information of each Pod in the multiple Pods.
  • Manner 2 Collect Link Layer Discovery Protocol (LLDP) information of the at least two nodes; and then generate each of the multiple Pods according to the LLDP information of the at least two nodes Pod topology information.
  • LLDP Link Layer Discovery Protocol
  • the collection here can be active reading or passive reception.
  • the first node when it is actively reading, the first node sends a request message to multiple nodes separately or in multicast to request LLDP information, and each of the multiple nodes sends its own request message after receiving the request message.
  • the LLDP information is sent to the first node.
  • each of the multiple nodes when receiving passively, each of the multiple nodes periodically sends its own LLDP information to the first node, and accordingly, the first node receives the LLDP information sent by the multiple nodes.
  • LLDP information may include: information used to identify the node and information used to identify the peer end of the node.
  • the information used to identify the node includes the node identification (ie chassis ID) and port identification (port ID) of the node.
  • the information used to identify the opposite end of the node includes the chassis ID and port ID of the opposite end.
  • the connection relationship between the node and other nodes can be determined according to the chassis ID and port ID used for the node and the chassis ID and port ID of the peer end of the node.
  • node 1 is the first node
  • Step S302 The first node determines the weight of each Pod according to the topology information of each Pod in the multiple Pods.
  • the weight of each Pod can be configured according to the following rules:
  • the weight of the Pod in the first node is the first weight
  • the weight of the Pod in the second node is the second weight.
  • the second node and the first node are connected to the same top-of-rack switch, and the Internet Protocol IP address of the second node is the same as that of the first node.
  • the IP addresses belong to the same network segment;
  • the weight of the Pod in the third node is the third weight, the third node and the first node are connected to different top-of-rack switches, and the different top-of-rack switches are connected to the same leaf switch;
  • the weight of the Pod in the fourth node is the fourth weight
  • the fourth node and the first node are connected to different leaf switches
  • the different leaf switches are connected to the same spine switch.
  • the first weight ⁇ the second weight ⁇ the third weight ⁇ the fourth weight.
  • the greater the weight the greater the calculated cost, and the smaller the probability that the Pod related to the cost will be selected.
  • the larger the weight the smaller the calculated cost, and the greater the probability that the Pod related to the cost will be selected.
  • Top-of-rack switches are generally switches directly connected to nodes; leaf switches are connected to different top-of-rack switches, which are the convergence point of multiple top-of-rack switches, which can handle all communications from the top-of-rack switches and provide them to the spine switches; the spine switches have different connections The leaf switch can forward communication at high speed.
  • node 1 is the first node, because both Pod2 and Pod1 are located in node 1, then it can be determined that the weight of Pod2 is the first weight, and the value of the first weight can be 4; because node 2 It is connected to the same top-of-rack switch 1 with node 1, and the IP addresses of node 2 and node 1 are in the same network segment, then it can be determined that the weight of Pod3 and Pod4 in node 2 is the second weight, for example, the second weight
  • the value of can be 5; because node 3 is connected to top-of-rack switch 2, node 1 is connected to top-of-rack switch 1, and top-of-rack switch 1 and top-of-rack switch 2 are connected to the same leaf switch 1, then Pod5 and Pod6 in node 3 can be determined
  • the weight is the third weight.
  • the third weight value can be 6; because node 4 is connected to top-of-rack switch 3, node 1 is connected to top-of-rack switch 1, top-of-rack switch 3 is connected to leaf switch 2, and top-of-rack switch 1 is connected to leaf switch 1. If leaf switch 1 and leaf switch 2 are connected to the same spine switch 1, then it can be determined that the weight of Pod7 and Pod8 in node 4 is the fourth weight, for example, the fourth weight may be 7.
  • Step S303 The first node selects a target Pod from the multiple Pods according to the weight of each Pod.
  • the first node selects a Pod with a smaller weight value from a plurality of Pods as the target Pod, the target Pod is one of the multiple Pods, and the target Pod is used to process the first Pod.
  • a task currently pending in a node when there are multiple Pods with the smallest weight value, the multiple Pods with the smallest weight value can be further selected, so as to select one of them as the target Pod.
  • the weight value of Pod2 in node 1 (ie the first node) is 4, the weight value of Pod3 and Pod4 in node 2 is 5, and Pod5 and Pod6 in node 3
  • the weight value of is 6, and the weight value of Pod7 and Pod8 in node 4 is 7; because 4 ⁇ 5 ⁇ 6 ⁇ 7, then the first node chooses Pod2 to handle the task currently to be processed, for example, there is a Pod2 pair to open the video software Respond to the request to provide the corresponding service.
  • the selecting the target Pod from the multiple Pods according to the weight of each Pod may be: when the load of each Pod in the multiple Pods is the same, The Pod with the smallest weight is selected from the multiple Pods as the target Pod.
  • the load of the Pod represents the utilization rate of one or more resources such as the central processing unit CPU, memory, and bandwidth of the node where the Pod is located.
  • the CPU usage rate of node 1 where Pod2 is located is 50%
  • the CPU usage rate of node 2 where Pod3 and Pod4 are located is 50%
  • the CPU usage rate of node 3 where Pod5 and Pod6 are located The utilization rate of Pod7 and Pod8 is 50%
  • the CPU utilization rate of node 4 where Pod7 and Pod8 are located is 50%
  • the weight value of Pod2 is 4
  • the weight value of Pod3 and Pod4 is 5
  • the weight value of Pod5 and Pod6 is 6, Pod7 and Pod8
  • the weight value of is 7, because 4 ⁇ 5 ⁇ 6 ⁇ 7, then the first node selects Pod2 with the smallest weight value from multiple Pods as the target Pod.
  • the selecting the target Pod from the multiple Pods according to the weight of each Pod may be: when the loads of the multiple Pods are different, according to the multiple Pods The load of each Pod in and the weight of each Pod select the target Pod from the multiple Pods.
  • training can be performed in advance based on multiple data records (where each data record includes a load value, a weight value, and a Pod), so as to obtain a corresponding relationship between the load and the weight and the target Pod.
  • Recommend a model and then input the load and weight of each Pod obtained in the embodiment of this application in real time into the recommendation model to recommend a target Pod by the recommendation model, and the recommended target Pod is the one selected for this application Target Pod.
  • a corresponding strategy can be pre-configured, based on the strategy to comprehensively consider the impact of load and weight, and finally select a Pod as the target Pod.
  • the corresponding algorithm can also be configured in advance, and the load and weight of each Pod can be substituted into the algorithm to output a value that characterizes the preference for each Pod, and then based on the value that characterizes the preference for each Pod.
  • the CPU usage rate of Pod2’s node 1 is 10%, that is, the impact factor of Pod2 is 1, and the CPU usage rate of node 2 where Pod3 and Pod4 are located is 20%, that is, the impact factor of Pod3 and Pod4 is 2, and Pod5
  • the CPU usage rate of node 3 where Pod6 and Pod6 are located is 30%, that is, the impact factor of Pod3 and Pod4 is 3, and the CPU usage rate of node 4 where Pod7 and Pod8 are located is 40%, that is, the impact factor of Pod7 and Pod8 is 4
  • the weight value of Pod2 is 4, the weight value of Pod3 and Pod4 is 5, the weight value of Pod5 and Pod6 is 6, and the weight value of Pod7 and Pod8 is 7, then the first node chooses the smallest sum of weight value and influence factor Pod is the target Pod, because the sum of the influence factor and weight value of Pod2 is 5, the sum of the influence factor and weight value of Pod3 is 7
  • the first node selects Pod2 as the target Pod. If the sum of the influence factor and the weight value of the Pod is the same, the first node selects the Pod with the smaller weight value as the target Pod.
  • the above only uses the CPU usage rate of the node where the Pod is located as the load of the Pod.
  • the usage rate of multiple resources of the node where the Pod is located as the load of the Pod those skilled in the art can design a variety of different algorithms to determine the node's load.
  • the comprehensive utilization rate of multiple resources, and the comprehensive utilization rate is used as the load of the Pod.
  • the tasks that need to be processed in the first node may be The request of is directed to multiple Pods in the load balancing cluster through a round-robin algorithm.
  • the request of the task that the first node needs to process can be to open the video software, and multiple Pods in the load balancing cluster can provide the service of opening the video software request, then the first node will open the video according to the round-robin algorithm
  • the software request is directed to a certain Pod in the load balancing cluster, and the certain Pod responds to its own request to provide corresponding services.
  • the first node may direct the task currently to be processed in the first node to the target Pod to instruct the target Pod to execute the task currently to be processed.
  • the task to be processed may be a request to open a video software, a request to access a certain website, and so on.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the node where each Pod is located and the first The number of layers across switches between nodes, and then according to the weight value of each pod, the target Pod with a small number of layers across switches can be selected to process the tasks currently to be processed in the first node, avoiding the choice of the number of layers across switches More Pods process the tasks currently to be processed in the first node, reducing network overhead.
  • FIG. 7 is a schematic structural diagram of a load balancing device provided by an embodiment of the present application.
  • the load balancing device may be the aforementioned first node or a device in the first node; the load balancing device 700 may include a first node.
  • the first determining unit 701 is configured to determine the topology information of each Pod in the multiple minimum management unit Pods in the load balancing cluster to which the first node belongs, and the multiple Pods are distributed on at least two nodes;
  • the second determining unit 702 is configured to determine the weight of each Pod according to the topology information of each Pod in the plurality of Pods;
  • the selecting unit 703 is configured to select a target Pod from the multiple Pods according to the weight of each Pod, where the target Pod is used to process tasks currently to be processed in the first node.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the distance between the node where each Pod is located and the first node.
  • the number of layers of the switch then you can select the target Pod with a small number of layers across the switch to process the tasks currently to be processed in the first node according to the weight value of each pod, avoiding the choice of Pod processing with a large number of layers across the switch
  • the task currently to be processed in the first node reduces network overhead.
  • the load balancing cluster includes a control node and at least two computing nodes, the first node is one of the at least two computing nodes, and the control node is used to manage the at least two computing nodes. Two computing nodes, and the multiple Pods are distributed on the at least two computing nodes.
  • the first determining unit 701 is configured to receive topology information of each Pod in the plurality of Pods sent by the control node.
  • the first node does not need to collect the LLDP information of other computing nodes, and directly receives the topology information of each Pod among the multiple Pods sent by the control node, which is faster and saves the time for selecting the target Pod.
  • the first determining unit 701 is configured to: collect link layer discovery protocol LLDP information of the at least two nodes; and generate all the information according to the LLDP information of the at least two nodes. Describe the topology information of each Pod in the multiple Pods.
  • the first node needs to communicate with at least two nodes, collect LLDP information of at least two nodes, and generate topology information of each of multiple Pods according to real-time collection of LLDP information. This kind of topology information generation Way, more accurate.
  • the weight of the Pod in the first node is the first weight
  • the weight of the Pod in the second node is the second weight.
  • the second node and the first node are connected to the same top-of-rack switch, and the Internet Protocol IP address of the second node is the same as that of the first node.
  • the IP addresses belong to the same network segment;
  • the weight of the Pod in the third node is the third weight, the third node and the first node are connected to different top-of-rack switches, and the different top-of-rack switches are connected to the same leaf switch;
  • the weight of the Pod in the fourth node is the fourth weight
  • the fourth node and the first node are connected to different leaf switches
  • the different leaf switches are connected to the same spine switch.
  • the first weight ⁇ the second weight ⁇ the third weight ⁇ the fourth weight.
  • the greater the weight the greater the calculated cost, and the smaller the probability that the Pod related to the cost will be selected.
  • the larger the weight the smaller the calculated cost, and the greater the probability that the Pod related to the cost will be selected.
  • the selection unit 703 is configured to select the Pod with the smallest weight from the multiple Pods when the load of each Pod in the multiple Pods is the same.
  • the selection unit 703 is configured to, when the loads of the multiple Pods are different, according to the load of each Pod in the multiple Pods and the weight of each Pod The target Pod is selected from the plurality of Pods. By comprehensively considering the weight of each Pod and the load of each Pod to select the target Pod, it can balance load balancing and saving network overhead, and improve the overall performance of the load balancing cluster.
  • the device further includes an orienting unit configured to: after the selecting unit 703 selects a target Pod from the multiple Pods according to the weight of each Pod, The first node is directed to the target Pod for the task currently to be processed, so as to instruct the target Pod to process the task currently to be processed.
  • FIG. 8 is another load balancing device 800 provided by an embodiment of the present application.
  • the load balancing device may be the first node in the foregoing embodiments, or a virtual machine in the first node;
  • the load balancing device 800 includes a processor 801, a memory 802, and a communication interface 803.
  • the processor 801 includes a control plane 805 and a data plane 806.
  • the processor 801, the memory 802 and the communication interface 803 are connected to each other through a bus 804.
  • the memory 802 includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or portable A compact disc read-only memory (CD-ROM), the memory 802 is used to store computer programs and data.
  • the communication interface 803 is used to receive and send data.
  • the processor 801 may be one or more central processing units (CPU).
  • CPU central processing units
  • the CPU may be a single-core CPU or a multi-core CPU.
  • the processor 801 in the load balancing device 800 invokes a computer program stored in the memory 802 to perform the following operations:
  • the data plane 806 selects a target Pod from the multiple Pods according to the weight of each Pod, where the target Pod is used to process the task currently to be processed in the first node.
  • the weight of each Pod is determined according to the topology information of each Pod to quantify the positional relationship of each Pod. Therefore, the size of the weight value can reflect the difference between the node where each Pod is located and the first node. After the number of layers across the switch, you can then select the target Pod with a small number of layers across the switch according to the weight value of each pod to process the tasks currently to be processed in the first node, avoiding the choice of a large number of layers across the switch Pod processes the tasks currently pending in the first node, reducing network overhead.
  • the load balancing cluster includes a control node and at least two computing nodes, the first node is one of the at least two computing nodes, and the control node is used to manage the at least two computing nodes. Two computing nodes, and the multiple Pods are distributed on the at least two computing nodes.
  • the processor 801 is configured to:
  • the topology information of each Pod in the plurality of Pods sent by the control node is received through the communication interface 803.
  • the load balancing device does not need to collect the LLDP information of other computing nodes, and directly receives the topology information of each Pod among the multiple Pods sent by the control node, which is faster and saves the time for selecting the target Pod.
  • the processor 801 is configured to:
  • the topology information of each Pod in the plurality of Pods is generated.
  • the load balancing device needs to communicate with at least two nodes, collect LLDP information of at least two nodes, and generate topology information of each of multiple Pods based on real-time collection of LLDP information. This way of generating topology information, more precise.
  • the weight of the Pod in the first node is the first weight; the weight of the Pod in the second node is the second weight, and the second node and the first node are connected to the same rack
  • the Internet Protocol IP address of the second node and the IP address of the first node belong to the same network segment;
  • the weight of the Pod in the third node is the third weight, and the third node is the same as the first node.
  • One node is connected to different top-of-rack switches, and the different top-of-rack switches are connected to the same leaf switch;
  • the weight of the Pod in the fourth node is the fourth weight, and the fourth node is connected to the first node with different Leaf switches, the different leaf switches are connected to the same spine switch.
  • the first weight ⁇ the second weight ⁇ the third weight ⁇ the fourth weight.
  • the greater the weight the greater the calculated cost, and the smaller the probability that the Pod related to the cost will be selected.
  • the larger the weight the smaller the calculated cost, and the greater the probability that the Pod related to the cost will be selected.
  • the processor 801 is configured to:
  • the Pod with the smallest weight is selected from the multiple Pods as the target Pod; since the Pod with the smallest weight and the first node have the smallest number of cross-switch layers Therefore, the target Pod selected in this way can save network overhead when the load is the same.
  • the target Pod is selected from the multiple Pods according to the load of each Pod in the multiple Pods and the weight of each Pod; by comprehensively considering each Pod
  • the method of selecting the target Pod based on the size of the weight value and the load of each Pod can balance load balancing and saving network overhead, and improve the overall performance of the load balancing cluster.
  • the processor 801 is further configured to:
  • the task currently to be processed in the first node is directed to the target Pod to instruct the target Pod to process the target Pod. Describe the tasks currently pending.
  • the embodiment of the present application also provides a computer-readable storage medium in which a computer program is stored, and when it runs on a processor, the method shown in FIG. 3 is implemented.
  • the embodiment of the present application also provides a computer program product, which implements the method shown in FIG. 3 when the computer program product runs on a processor.
  • a person of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by a computer program, or by a computer program that drives related hardware.
  • the computer program can be stored in a computer readable storage medium. When the computer program is executed, it can realize the process including the foregoing method embodiments.
  • the aforementioned storage media include: ROM or random storage RAM, magnetic disks or optical disks and other media that can store computer program codes.

Abstract

本申请实施例提供一种负载均衡方法及相关设备,该方法包括:确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务,采用本申请实施例,能够在分发任务请求时节约网络开销。

Description

一种负载均衡方法及相关设备
本申请要求于2019年12月19日提交中国专利局、申请号为201911323403.9、申请名称为“一种负载均衡方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种负载均衡方法及相关设备。
背景技术
负载均衡是指根据调度算法将任务请求分发到负载均衡集群中的多个节点(node),从而提高了负载均衡集群的任务处理的能力。在容器网络场景下,容器编排和管理平台(例如,Kubernetes)中的负载均衡是在负载均衡集群的节点上部署分布式的软件来实现的,通过分布式的软件根据现有的调度算法分发任务请求的方式容易造成额外的网络开销。因此如何在分发任务请求时节约网络开销是本领域人员正在研究的技术问题。
发明内容
本申请公开了一种负载均衡方法及相关设备,能够在分发任务请求时节约网络开销。
本申请第一方面公开了一种负载均衡方法,包括:
确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上,例如,有的分布在该第一节点上,有的分布在与该第一节点连接同一个架顶交换机的节点上,有的分布在与该第一节点连接同一个叶子交换机的节点上,有的分布在与该第一节点连接同一个脊交换机的节点上;每个该至少两个节点中每个节点上分布的Pod数量此处不做限定;
根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
在上述方法中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,减少了网络开销。
在第一方面的又一种可选方案中,所述确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,包括:
接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
在上述方法中,第一节点无需采集其他计算节点的LLDP信息,直接通过接收控制节点发送的多个Pod中每个Pod的拓扑信息的方式,更加快速,节约了选择目标Pod的时间。
在第一方面的又一种可选方案中,所述确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,包括:
采集所述至少两个节点的链路层发现协议LLDP信息;
根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
在上述方法中,第一节点需要与至少两个节点进行通信,采集至少两个节点的LLDP信息,根据实时采集LLDP信息生成多个Pod中的每个Pod的拓扑信息,这种生成拓扑信息的方式,更加准确。
当所述多个Pod中的每个Pod的负载都相同时,可以从所述多个Pod中选择权重最小的Pod为所述目标Pod。由于权重最小的Pod与第一节点的跨交换机层数最少,因此在负载都相同的情况下通过这种方式选择的目标Pod能够节约网络开销。
当所述多个Pod的负载不同时,可以根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod。通过综合考虑每个Pod的权重值的大小和每个Pod的负载来选择目标Pod的方式,能够在负载均衡和节约网络开销两方面进行平衡,提高负载均衡集群的整体性能。
在第一方面的又一种可选方案中,所述根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,还包括:
将所述第一节点中所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
第二方面,本申请提供了一种负载均衡装置,包括:
第一确定单元,用于确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
第二确定单元,用于根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
选择单元,用于根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
在上述装置中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,造成了额外的网络开销。
在第二方面的又一种可选方案中,所述第一确定单元用于:接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
在上述装置中,第一节点无需采集其他计算节点的LLDP信息,直接通过接收控制节点发送的多个Pod中每个Pod的拓扑信息的方式,更加快速,节约了选择目标Pod的时间。
在第二方面的又一种可选方案中,所述第一确定单元用于采集所述至少两个节点的链路层发现协议LLDP信息;根据所述至少两个节点的所述LLDP信息,生成所述多个Pod 中的每个Pod的拓扑信息。
在上述装置中,第一节点需要与至少两个节点进行通信,采集至少两个节点的LLDP信息,根据实时采集LLDP信息生成多个Pod中的每个Pod的拓扑信息,这种生成拓扑信息的方式,更加准确。
可选地,所述选择单元,用于在所述多个Pod中的每个Pod的负载都相同的情况下,从所述多个Pod中选择权重最小的Pod为所述目标Pod;由于权重最小的Pod与第一节点的跨交换机层数最少,因此在负载都相同的情况下通过这种方式选择的目标Pod能够节约网络开销。
可选地,所述选择单元,用于在所述多个Pod的负载不同的情况下,根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod;通过综合考虑每个Pod的权重值的大小和每个Pod的负载来选择目标Pod的方式,能够在负载均衡和节约网络开销两方面进行平衡,提高负载均衡集群的整体性能。
在第二方面的又一种可选方案中,所述装置还包括:
定向单元,用于在所述选择单元根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,将所述第一节点中针对所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
第三方面,本申请提供了一种第一节点,所述第一节点包括处理器、存储器和通信接口,所述存储器用于存储计算机程序,所述处理器调用所述计算机程序,用于执行如下操作:
确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
在上述第一节点中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,造成了额外的网络开销。
在第三方面的又一种可选方案中,在确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息方面,所述处理器用于:
通过所述通信接口接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
在上述第一节点中,第一节点无需采集其他计算节点的LLDP信息,直接通过接收控制节点发送的多个Pod中每个Pod的拓扑信息的方式,更加快速,节约了选择目标Pod的时间。
在第三方面的又一种可选方案中,在确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息方面,所述处理器用于:
采集所述至少两个节点的链路层发现协议LLDP信息;
根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
在上述第一节点中,第一节点需要与至少两个节点进行通信,采集至少两个节点的LLDP信息,根据实时采集LLDP信息生成多个Pod中的每个Pod的拓扑信息,这种生成拓扑信息的方式,更加准确。
在第三方面的又一种可选方案中,在根据所述每个Pod的权重从所述多个Pod中选择目标Pod方面,所述处理器用于:
当所述多个Pod中的每个Pod的负载都相同时,从所述多个Pod中选择权重最小的Pod为所述目标Pod;由于权重最小的Pod与第一节点的跨交换机层数最少,因此在负载都相同的情况下通过这种方式选择的目标Pod能够节约网络开销。
或者
当所述多个Pod的负载不同时,根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod;通过综合考虑每个Pod的权重值的大小和每个Pod的负载来选择目标Pod的方式,能够在负载均衡和节约网络开销两方面进行平衡,提高负载均衡集群的整体性能。
在第三方面的又一种可选方案中,所述处理器还用于:
在根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,将所述第一节点中所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
结合上述任意一个方面或者任意一个方面的任意一种可选方案,在又一种可选的方案中,所述负载均衡集群包括控制节点和至少两个计算节点,所述第一节点为所述至少两个计算节点中的一个,所述控制节点用于管理所述至少两个计算节点,所述多个Pod分布在所述至少两个计算节点上。
结合上述任意一个方面或者任意一个方面的任意一种可选方案,在又一种可选的方案中,
在所述第一节点中的Pod的权重为第一权重;
在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;
在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;
在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机;
第一权重<第二权重<第三权重<第四权重。
第四方面,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器实现第一方面或者第一方面的任意一种可选方案所描述的方法。
通过实施本申请,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod 的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,造成了额外的网络开销。
附图说明
图1是本申请实施例提供的一种负载均衡集群的架构示意图;
图2是本申请实施例提供的一种分发任务请求的过程示意图;
图3是本申请实施例提供的一种负载均衡方法的流程示意图;
图4是本申请实施例提供的一种多个节点中的多个Pod中每个Pod拓扑信息的示意图;
图5是本申请实施例提供的一种控制节点向第一节点发送多个节点中的多个Pod中每个Pod的拓扑信息的示意图;
图6是本申请实施例提供的一种节点1根据节点1和节点2的LLDP信息,生成节点1和节点2中的每个Pod的拓扑信息的示意图;
图7是本申请实施例提供的一种负载均衡装置的结构示意图;
图8是本申请实施例提供的另一种负载均衡装置的结构示意图。
具体实施方式
下面结合本申请实施例中的附图对本申请实施例进行描述。
请参见图1,图1是本申请实施例提供的一种负载均衡集群的架构示意图,该负载均衡集群可以包括一个控制节点101和至少两个计算节点102(图中示出了102a-102e),其中,控制节点101和至少两个计算节点102中的每个节点可以为一个服务器或者云平台上的一个虚拟机。控制节点101用于管理该至少两个计算节点102。该至少两个计算节点102为负载均衡节点,用于选择计算节点中的Pod来处理待处理任务。例如,待处理任务可以为打开视频软件的请求,访问某个网址的请求等。其中,每个计算节点中可以包括一个或多个最小管理单元Pod。
上述负载均衡集群可以为容器编排和管理平台(例如Kubernetes,k8s)集群或者其他运行环境的集群,其中,Kubernetes是一个跨主机集群的开源容器调度平台,它可以让容器化的应用被简单并且高效地部署,提供了应用部署,规划,更新,维护的一种机制。传统的应用部署方式是通过插件或脚本来安装应用。这样做的缺点是应用的运行、配置、管理、生存周期将与当前操作系统绑定,这样做并不利于应用的升级更新/回滚等操作,当然也可以通过创建虚拟机的方式来实现某些功能,但是虚拟机非常重,并不利于可移植性。当使用Kubernetes部署容器时,每个容器之间互相隔离,每个容器有自己的文件系统,容器之间进程不会相互影响,能区分计算资源。相对于虚拟机,容器能快速部署,由于容器是与底层设施、机器文件系统解耦的,所以它能在不同云、不同版本操作系统间进行迁移。
Pod是Kubernetes集群中的最小管理单元,是由用户创建或部署的最小组件,也是Kubernetes集群上运行容器化应用时使用的资源对象,每个Pod都会被分配一个唯一的IP 地址,每个Pod包含了一个或多个容器,同一个Pod中的容器会被分配到同一个节点上。Pod内部的容器共享Pod的网络空间,包括IP地址和端口。Pod内部的容器可以使用该Pod的宿主机互相通信。Pod内部的容器与外界通信时,必须使用为该Pod分配的网络资源。
Pod内部的容器都可以访问共享的存储卷(volume),该volume也可以用来持久化Pod中的存储资源,以防容器重启后文件丢失。Pod中的容器总是被同时调度,有共同的运行环境。
当客户端请求服务时,服务端在负载均衡集群中通过负载均衡调度算法选择一个目标Pod,由该目标Pod为该客户端提供服务。负载均衡调度算法包括静态调度算法和动态调度算法,下面对静态调度算法和动态调度算法进行简单介绍。
静态调度算法:按照某种既定的算法分配服务请求,不考虑实时的连接数。
例如,采用轮循(roundrobin,RR)算法将外部请求按顺序轮流分配到集群中的节点上,它均等地对待每一个节点,而不管节点上实际的连接数和负载。
再如,采用加权轮询(weighted roundrobin,WRR)算法给集群中的每个节点分配一个权值,权值越大,分到的请求数越多。
再如,采用目标散列(destination hashing,DH)算法根据请求的目标IP地址,作为散列键值(hash key)从静态分配的散列表找出对应的节点,若该节点是可用的且未超载,将请求发送到该节点,否则返回空。来自于同一个IP地址的请求都被重定向到同一个节点上,保证目标地址不变。
再如,采用源散列(source hashing,SH)算法根据请求的源IP地址,作为散列键值(hash key)从静态分配的散列表找出对应的节点,若该节点是可用的且未超载,将请求发送到该节点,否则返回空。
动态调度算法:通过检查节点上当前连接数的活跃状态来重新决定下一步调度方式。
例如,采用最少连接(leastconnection,LC)算法,即哪一个节点上的连接数少就将下一个连接请求定向到该连接数少的节点上去。算法实现:连接数=活跃连接数*256+非活跃连接数。
再如,采用加权最少连接(weight least-connection,WLC)算法,即在最少连接的基础上给每个节点分配一个权重。算法实现:连接数=(活跃连接数*256+非活跃连接数)÷权重,是一种比较理想的算法。
再如,采用最短期望延迟(shortest expected delay,SED)算法,即不再考虑非活跃连接数,算法实现:连接数=(活跃连接数+1)*256÷权重。
再如,采用永不排队(never queue,NQ)算法,永不排队算法是对SED算法的改进,当新请求过来的时候不仅要取决于SED算法所得到的值,还要取决于节点上是否有活跃连接。
再如,采用基于本地状态的最少连接(locality-based least-connection,LBLC)算法,即在DH算法的基础上还要考虑节点上的活跃连接数。
在容器网络场景下,容器编排和管理平台中的负载均衡是在负载均衡集群的节点上部署分布式的软件来实现的,通过分布式的软件根据调度算法分发任务请求的方式容易造成额外的网络开销,如图2所示,图2为分发任务请求的过程示意图。其中,节点1中的最 小管理单元Pod1为发起请求的客户端(client),节点1和节点2连接同一架顶交换机,节点1将任务请求分发给节点2中的Pod4,由该Pod4实际提供服务。而没有将任务请求分发给节点1中的Pod2,造成了额外的网络开销。为了解决上述技术问题,本申请实施例提供了如下解决方案。
请参见图3,图3是本申请实施例提供的一种负载均衡方法,该方法可以基于图1所示的负载均衡集群来实现,该方法包括但不限于如下步骤:
步骤S301、第一节点确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息。
第一节点为负载均衡集群中的节点,例如,计算节点;该多个Pod分布在该负载均衡集群中的至少两个节点上,例如,有的分布在该第一节点上,有的分布在与该第一节点连接同一个架顶交换机的节点上,有的分布在与该第一节点连接同一个叶子交换机的节点上,有的分布在与该第一节点连接同一个脊交换机的节点上;该至少两个节点中每个节点上分布的Pod数量此处不做限定。该多个Pod均能够处理第一节点中当前待处理任务,每个Pod的拓扑信息表示每个Pod所在的节点以及该Pod所在的节点与其他节点的连接关系。
假若节点1中有Pod1和Pod2,节点2中有Pod3和Pod4,节点3中有Pod5和Pod6,节点4中有Pod7和Pod8,节点1为第一节点,节点1中的Pod1为发起请求的客户端(client),节点2中的Pod3和Pod4都能为该请求提供服务,节点3中的Pod5和Pod6都能为该请求提供服务,节点4中的Pod7和Pod8也都能为该请求提供服务;那么节点1根据节点2的互联网协议地址IP地址为10.1.10.2确定节点2与节点1属于同一网段,连接同一个架顶交换机;节点1根据节点3的IP地址为10.1.11.2,确定节点3连接在架顶交换机2上,节点1连接在架顶交换机1上,架顶交换机1和架顶交换机2连接在同一个叶子交换机1上;节点1根据节点4的IP地址为10.1.12.2确定节点4连接在架顶交换机3上,架顶交换机3连接叶子交换机2,而节点1连接架顶交换机1,架顶交换机1连接叶子交换机1,叶子交换机1和叶子交换机2连接同一个脊交换机1。最终,节点1确定的多个节点中的多个Pod中每个Pod的拓扑信息可以如图4所示。
确定该负载均衡集群中的多个Pod中的每个Pod的拓扑信息方式包括但不限于如下两种:
方式一,接收控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
例如,如图5所示,图5表示控制节点向第一节点发送多个节点中的多个Pod中每个Pod的拓扑信息的过程。其中,节点A为控制节点,节点B为第一节点。负载均衡集群在部署时默认的分布式键值数据库(etcd),保存了各个计算节点的部署情况,以及各个计算节点中的Pod的部署情况;可选的,用户可以自己定义负载均衡集群中各个节点以及节点中的Pod如何部署。可选的,当添加新Pod、删除已有Pod或者Pod的相应信息有更新时,相关信息都会实时更新到控制节点。控制节点向第一节点发送多个节点中的多个Pod中每个Pod的拓扑信息,相应的,该第一节点接收该多个Pod中每个Pod的拓扑信息。
方式二,采集所述至少两个节点的链路层发现协议(Link Layer Discovery Protocol,LLDP)信息;然后根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个 Pod的拓扑信息。
此处的采集可以为主动读取,或者被动接收。第一种情况,当为主动读取时,第一节点向多个节点分别或组播发送请求消息,以请求LLDP信息,该多个节点中的每个节点接收到该请求消息后将自己的LLDP信息发送给该第一节点。第二种情况,当为被动接收时,多个节点中的每个节点定期将自己的LLDP信息发送给第一节点,相应地,第一节点接收该多个节点发送的LLDP信息。
LLDP信息可以包括:用于标识该节点的信息和用于标识该节点的对端的信息,例如,用于标识该节点的信息包括该节点的节点标识(即chassis ID)和端口标识(port ID),用于标识该节点的对端的信息包括该对端的chassis ID和port ID。根据用于该节点的chassis ID、port ID和该节点的对端的chassis ID、port ID即可确定该节点与其他节点的连接关系。
例如,有节点1和节点2(均以节点的MAC地址作为节点标识,以端口名称作为端口标识),节点1为第一节点,节点1的节点标识为chassis ID=00-16-EA-AE-3C-40,节点1的a端口的端口标识为port ID=Ethernet 0/0/7/0;节点2的节点标识为chassis ID=00-16-EA-AE-2B-66,节点2的b端口的端口标识为port ID=Ethernet 0/0/6/0。那么采集到的节点1的LLDP信息中节点1的信息包括chassis ID=00-16-EA-AE-3C-40,port ID=port ID=Ethernet 0/0/7/0,对端的信息包括chassis ID=00-16-EA-AE-2B-66,port ID=Ethernet0/0/6/0;那么采集到的节点2的LLDP信息中的节点2的信息包括chassis ID=00-16-EA-AE-2B-66,port ID=Ethernet 0/0/6/0,对端的信息包括chassis ID=00-16-EA-AE-3C-40,port ID=Ethernet 0/0/7/0,根据节点1的LLDP信息和节点2的LLDP信息确定节点1的a端口与节点2的b端口存在连接关系,即确定节点1和节点2连接同一个架顶交换机,因为节点1中有Pod2,节点2中有Pod3和Pod4,依次类推,最终,节点1根据节点1和节点2的LLDP信息,生成节点1和节点2中的每个Pod的拓扑信息可以如图6所示。
步骤S302、第一节点根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重。
可选的,可以按照如下规则来配置各个Pod权重:
在所述第一节点中的Pod的权重为第一权重;
在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;
在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;
在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机。
在一个实现方式中,第一权重<第二权重<第三权重<第四权重。本实施方式中,权重越大,计算出的开销越大,与该开销相关的Pod被选择的几率越小。
在另一个实现方式中,第一权重〉第二权重〉第三权重〉第四权重。本实施方式中,权重越大,计算出的开销越小,与该开销相关的Pod被选择的几率越大。
架顶交换机一般为直接连接节点的交换机;叶子交换机连接不同的架顶交换机,为多 台架顶交换机的汇聚点,能够处理来自架顶交换机的所有通信,并提供到脊交换机;脊交换机连接不同的叶子交换机,能够高速转发通信。
例如,如图4所示,假若节点1为第一节点,因为Pod2与Pod1都位于节点1中,那么可以确定Pod2的权重为第一权重,该第一权重的值可以为4;因为节点2和节点1连接同一个架顶交换机1,且节点2与节点1的IP地址在同一个网段中,那么可以确定在节点2中的Pod3和Pod4的权重为第二权重,例如该第二权重的值可以为5;因为节点3连接架顶交换机2,节点1连接架顶交换机1,架顶交换机1和架顶交换机2连接同一个叶子交换机1,那么可以确定节点3中的Pod5和Pod6的权重为第三权重,例如该第三权重值可以为6;因为节点4连接架顶交换机3,节点1连接架顶交换机1,架顶交换机3连接叶子交换机2,架顶交换机1连接叶子交换机1,叶子交换机1和叶子交换机2连接同一个脊交换机1,那么可以确定节点4中的Pod7和Pod8的权重为第四权重,例如该第四权重可以为7。
步骤S303、第一节点根据所述每个Pod的权重从所述多个Pod中选择目标Pod。
具体地,第一节点根据每个Pod的权重值的大小,从多个Pod中选择权重值小的Pod为目标Pod,目标Pod为多个Pod中的一个Pod,目标Pod用于处理所述第一节点中当前待处理的任务。可选的,当存在多个权重值最小的Pod时,可以对多个权重值最小的Pod做进一步选择,从而选择其中一个作为目标Pod。
例如,又如图4所示,假若在节点1(即第一节点)中的Pod2的权重值为4,在节点2中的Pod3和Pod4的权重值为5,在节点3中的Pod5和Pod6的权重值为6,在节点4中的Pod7和Pod8的权重值为7;因为4<5<6<7,那么第一节点选择Pod2处理当前待处理的任务,例如,有Pod2对打开视频软件的请求进行响应以提供相应服务。
在一种可选的方案中,所述根据所述每个Pod的权重从所述多个Pod中选择目标Pod,可以为:当所述多个Pod中的每个Pod的负载都相同时,从所述多个Pod中选择权重最小的Pod为所述目标Pod。其中,Pod的负载表示Pod所在的节点的中央处理器CPU、内存、带宽等一个或多个资源的使用率。
以负载为CPU的使用率为例,假若Pod2的所在节点1的CPU的使用率为50%、Pod3和Pod4的所在节点2的CPU的使用率为50%、Pod5和Pod6的所在节点3的CPU的使用率为50%、Pod7和Pod8的所在节点4的CPU使用率为50%,Pod2的权重值为4、Pod3和Pod4的权重值为5、Pod5和Pod6的权重值为6、Pod7和Pod8的权重值为7,因为4<5<6<7,那么第一节点从多个Pod中选择权重值最小的Pod2为目标Pod。
在一种可选的方案中,所述根据所述每个Pod的权重从所述多个Pod中选择目标Pod,可以为:当所述多个Pod的负载不同时,根据所述多个Pod中每个Pod的负载以及每个Pod的权重从所述多个Pod中选择所述目标Pod。
可选的,可以预先根据多条数据记录(其中,每一条数据记录包括一个负载值、一个权重值和一个Pod)进行训练,从而得出能够表征负载和权重两者与目标Pod的对应关系的推荐模型,然后将本申请实施例中实时得到的每个Pod的负载和权重输入到该推荐模型中,以由该推荐模型推荐得到一个目标Pod,推荐得到的目标Pod即为本申请所选择的目标Pod。
可选的,还可以预先配置相应策略,基于该策略综合考量负载和权重的影响,最终选 择出一个Pod作为目标Pod。
可选的,也可以预先配置相应算法,将每个Pod的负载和权重代入到该算法中从而输出表征对每个Pod的选择倾向的数值,然后根据表征对每个Pod的选择倾向的数值来选择一个Pod为目标Pod。假若当节点的CPU的使用率为10%时,节点中的Pod的影响因子为1,当节点的CPU的使用率为20%时,节点中的Pod的影响因子为2,当节点的CPU的使用率为30%时,节点中的Pod的影响因子为3,当节点的CPU的使用率为40%时,节点中的Pod的影响因子为4。假若Pod2的所在节点1的CPU的使用率为10%,即Pod2的影响因子为1,Pod3和Pod4的所在节点2的CPU的使用率为20%,即Pod3和Pod4的影响因子为2,Pod5和Pod6的所在节点3的CPU的使用率为30%,即Pod3和Pod4的影响因子为3,Pod7和Pod8的所在节点4的CPU的使用率为40%,即Pod7和Pod8的影响因子为4,因为Pod2的权重值为4、Pod3和Pod4的权重值为5、Pod5和Pod6的权重值为6、Pod7和Pod8的权重值为7,那么第一节点选择权重值和影响因子的和最小的Pod为目标Pod,因为Pod2的影响因子与权重值的和为5,Pod3的影响因子与权重值的和为7(Pod4同理),Pod5的影响因子与权重值的和为9(Pod6同理),Pod7的影响因子与权重值的和为11(Pod8同理),可选的,哪个Pod的影响因子与权重值的和越小,则选择该Pod作为目标Pod的倾向越强,由于5<7<9<11,那么第一节点选择Pod2为目标Pod。若Pod的影响因子和权重值的和相同时,第一节点选择权重值较小的Pod为目标Pod。
以上仅以Pod所在节点的CPU的使用率作为Pod的负载,当使用Pod所在节点的多种资源的使用率作为Pod的负载时,本领域技术人员可以设计多种不同的算法来确定该节点的多种资源的综合使用率,并将该综合使用率作为该Pod的负载。
在一种可选的方案中,所述确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息之前,可以将所述第一节点中需要处理的任务的请求通过轮循算法定向到所述负载均衡集群中的多个Pod。
例如,假若第一节点需要处理的任务的请求可以为打开视频软件,负载均衡集群中的多个Pod都能够提供打开视频软件的请求的服务,那么第一节点根据通过轮循的算法将打开视频软件的请求定向到负载均衡集群中某一个Pod,该某一个Pod响应定向到自己的请求以提供相应服务。
可选的,第一节点根据每个Pod的权重从多个Pod中选择目标Pod之后,可以将第一节点中当前待处理的任务定向到目标Pod,以指示目标Pod执行当前待处理的任务。例如,待处理任务可以为打开视频软件的请求,访问某个网址的请求等。
在图3所描述的方法中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,减少了网络开销。
上述详细阐述了本申请实施例的方法,下面提供了本申请实施例的装置。
请参见图7,图7是本申请实施例提供的一种负载均衡装置的结构示意图,该负载均 衡装置可以为上述第一节点,或者第一节点中的器件;该负载均衡装置700可以包括第一确定单元701,第二确定单元702和选择单元703。
第一确定单元701,用于确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
第二确定单元702,用于根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
选择单元703,用于根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
在上述装置中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,减少了网络开销。
在一种可选方案中,所述负载均衡集群包括控制节点和至少两个计算节点,所述第一节点为所述至少两个计算节点中的一个,所述控制节点用于管理所述至少两个计算节点,所述多个Pod分布在所述至少两个计算节点上。
在又一种可选方案中,所述第一确定单元701用于:接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
在上述装置中,第一节点无需采集其他计算节点的LLDP信息,直接通过接收控制节点发送的多个Pod中每个Pod的拓扑信息,更加快速,节约了选择目标Pod的时间。
在又一种可选方案中,所述第一确定单元701用于:采集所述至少两个节点的链路层发现协议LLDP信息;根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
在上述装置中,第一节点需要与至少两个节点进行通信,采集至少两个节点的LLDP信息,根据实时采集LLDP信息生成多个Pod中的每个Pod的拓扑信息,这种生成拓扑信息的方式,更加准确。
在又一种可选方案中,
在所述第一节点中的Pod的权重为第一权重;
在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;
在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;
在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机。
在一个实现方式中,第一权重<第二权重<第三权重<第四权重。本实施方式中,权重越大,计算出的开销越大,与该开销相关的Pod被选择的几率越小。
在另一个实现方式中,第一权重>第二权重>第三权重>第四权重。本实施方式中,权重越大,计算出的开销越小,与该开销相关的Pod被选择的几率越大。
在又一种可选方案中,所述选择单元703,用于在所述多个Pod中的每个Pod的负载都相同的情况下,从所述多个Pod中选择权重最小的Pod为所述目标Pod;由于权重最小的Pod与第一节点的跨交换机层数最少,因此在负载都相同的情况下通过这种方式选择的目标Pod能够节约网络开销。
在另一种可选方案中,所述选择单元703,用于在所述多个Pod的负载不同的情况下,根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod。通过综合考虑每个Pod的权重值的大小和每个Pod的负载来选择目标Pod的方式,能够在负载均衡和节约网络开销两方面进行平衡,提高负载均衡集群的整体性能。
在又一种可选方案中,所述装置还包括定向单元,该定向单元,用于在所述选择单元703根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,将所述第一节点中针对所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
需要说明的是,每个单元的实现及有益效果还可以对应参照图3所示的方法实施例的相应描述。
请参见图8,图8是本申请实施例提供的另一种负载均衡装置800,该负载均衡装置可以为上述各实施方式中第一节点,或者第一节点中的一个虚拟机;负载均衡装置800包括处理器801、存储器802和通信接口803,处理器801中包括控制面805和数据面806,所述处理器801、存储器802和通信接口803通过总线804相互连接。
存储器802包括但不限于是随机存储器(random access memory,RAM)、只读存储器(read-only memory,ROM)、可擦除可编程只读存储器(erasable programmable read-only memory,EPROM)、或便携式只读存储器(compact disc read-only memory,CD-ROM),该存储器802用于存储计算机程序及数据。通信接口803用于接收和发送数据。
处理器801可以是一个或多个中央处理器(central processing unit,CPU),在处理器801是一个CPU的情况下,该CPU可以是单核CPU,也可以是多核CPU。
该负载均衡装置800中的处理器801调用存储器802中存储的计算机程序,用于执行以下操作:
通过控制面805确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
通过控制面805根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
通过数据面806根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
在上述负载均衡装置中,通过根据每个Pod的拓扑信息确定每个Pod的权重,以将每个Pod的位置关系量化,因此权重值的大小能够反映每个Pod所在的节点与第一节点之间跨交换机的层数,之后就可以根据每个pod的权重值的大小选择跨交换机的层数少的目标Pod处理第一节点中当前待处理的任务,避免了选择跨交换机的层数多的Pod处理第一节点中当前待处理的任务,减少了网络开销。
在一种可选方案中,所述负载均衡集群包括控制节点和至少两个计算节点,所述第一 节点为所述至少两个计算节点中的一个,所述控制节点用于管理所述至少两个计算节点,所述多个Pod分布在所述至少两个计算节点上。
在又一种可选方案中,所述处理器801用于:
通过所述通信接口803接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
这样,该负载均衡装置无需采集其他计算节点的LLDP信息,直接通过接收控制节点发送的多个Pod中每个Pod的拓扑信息的方式,更加快速,节约了选择目标Pod的时间。
在又一种可选方案中,所述处理器801用于:
采集所述至少两个节点的链路层发现协议LLDP信息;
根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
这样,该负载均衡装置需要与至少两个节点进行通信,采集至少两个节点的LLDP信息,根据实时采集LLDP信息生成多个Pod中的每个Pod的拓扑信息,这种生成拓扑信息的方式,更加准确。
可选地,在所述第一节点中的Pod的权重为第一权重;在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机。
在一个实现方式中,第一权重<第二权重<第三权重<第四权重。本实施方式中,权重越大,计算出的开销越大,与该开销相关的Pod被选择的几率越小。
在另一个实现方式中,第一权重>第二权重>第三权重>第四权重。本实施方式中,权重越大,计算出的开销越小,与该开销相关的Pod被选择的几率越大。
在又一种可选方案中,在根据所述每个Pod的权重从所述多个Pod中选择目标Pod方面,所述处理器801用于:
当所述多个Pod中的每个Pod的负载都相同时,从所述多个Pod中选择权重最小的Pod为所述目标Pod;由于权重最小的Pod与第一节点的跨交换机层数最少,因此在负载都相同的情况下通过这种方式选择的目标Pod能够节约网络开销。
当所述多个Pod的负载不同时,根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod;通过综合考虑每个Pod的权重值的大小和每个Pod的负载来选择目标Pod的方式,能够在负载均衡和节约网络开销两方面进行平衡,提高负载均衡集群的整体性能。
在又一种可选方案中,所述处理器801还用于:
在根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,将所述第一节点中所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
需要说明的是,各个操作的实现及有益效果还可以对应参照图3所示的方法实施例的 相应描述。
本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当其在处理器上运行时,实现图3所示的方法。
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在处理器上运行时,实现图3所示的方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程可以由计算机程序来完成,或者由计算机程序驱动相关的硬件完成,该计算机程序可存储于计算机可读取存储介质中,该计算机程序在执行时,可实现包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储计算机程序代码的介质。

Claims (16)

  1. 一种负载均衡方法,其特征在于,包括:
    确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
    根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
    根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
  2. 根据权利要求1所述的方法,其特征在于,所述负载均衡集群包括控制节点和至少两个计算节点,所述第一节点为所述至少两个计算节点中的一个,所述控制节点用于管理所述至少两个计算节点,所述多个Pod分布在所述至少两个计算节点上。
  3. 根据权利要求2所述的方法,其特征在于,所述确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,包括:
    接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
  4. 根据权利要求1或2所述的方法,其特征在于,所述确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,包括:
    采集所述至少两个节点的链路层发现协议LLDP信息;
    根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
  5. 根据权利要求1-4任一项所述的方法,其特征在于:
    在所述第一节点中的Pod的权重为第一权重;
    在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;
    在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;
    在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述根据所述每个Pod的权重从所述多个Pod中选择目标Pod,包括:
    当所述多个Pod中的每个Pod的负载都相同时,从所述多个Pod中选择权重最小的Pod为所述目标Pod;
    或者
    当所述多个Pod的负载不同时,根据所述多个Pod中每个Pod的负载以及所述每个Pod 的权重从所述多个Pod中选择所述目标Pod。
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,还包括:
    将所述第一节点中所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
  8. 一种负载均衡装置,其特征在于,包括:
    第一确定单元,用于确定第一节点所属的负载均衡集群中的多个最小管理单元Pod中的每个Pod的拓扑信息,所述多个Pod分布在至少两个节点上;
    第二确定单元,用于根据所述多个Pod中的每个Pod的拓扑信息确定所述每个Pod的权重;
    选择单元,用于根据所述每个Pod的权重从所述多个Pod中选择目标Pod,其中,所述目标Pod用于处理所述第一节点中当前待处理的任务。
  9. 根据权利要求8所述的装置,其特征在于,所述负载均衡集群包括控制节点和至少两个计算节点,所述第一节点为所述至少两个计算节点中的一个,所述控制节点用于管理所述至少两个计算节点,所述多个Pod分布在所述至少两个计算节点上。
  10. 根据权利要求2所述的装置,其特征在于,所述第一确定单元用于:接收所述控制节点发送的所述多个Pod中的每个Pod的拓扑信息。
  11. 根据权利要求8或9所述的装置,其特征在于,所述第一确定单元用于:采集所述至少两个节点的链路层发现协议LLDP信息;根据所述至少两个节点的所述LLDP信息,生成所述多个Pod中的每个Pod的拓扑信息。
  12. 根据权利要求8-11任一项所述的装置,其特征在于:
    在所述第一节点中的Pod的权重为第一权重;
    在第二节点中的Pod的权重为第二权重,所述第二节点与所述第一节点连接同一个架顶交换机上,所述第二节点的互联网协议IP地址与所述第一节点的IP地址属于同一网段;
    在第三节点中的Pod的权重为第三权重,所述第三节点与所述第一节点连接不同的架顶交换机,所述不同的架顶交换机连接同一个叶子交换机;
    在第四节点中的Pod的权重为第四权重,所述第四节点与所述第一节点连接不同的叶子交换机,所述不同的叶子交换机连接同一个脊交换机。
  13. 根据权利要求8-12任一项所述的装置,其特征在于,
    所述选择单元,用于在所述多个Pod中的每个Pod的负载都相同的情况下,从所述多个Pod中选择权重最小的Pod为所述目标Pod;
    或者
    所述选择单元,用于在所述多个Pod的负载不同的情况下,根据所述多个Pod中每个Pod的负载以及所述每个Pod的权重从所述多个Pod中选择所述目标Pod。
  14. 根据权利要求8-13任一项所述的方法,其特征在于,所述装置还包括:
    定向单元,用于在所述选择单元根据所述每个Pod的权重从所述多个Pod中选择目标Pod之后,将所述第一节点中所述当前待处理的任务定向到所述目标Pod,以指示所述目标Pod处理所述当前待处理的任务。
  15. 一种第一节点,其特征在于,所述服务器包括处理器、存储器和通信接口,所述存储器用于存储计算机程序,所述处理器调用所述计算机程序,用于使所述负载均衡服务器实现权利要求1-7中任意一项所述的方法。
  16. 一种计算机可读存储介质,其特征在于,所述计算机存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
PCT/CN2020/106021 2019-12-19 2020-07-30 一种负载均衡方法及相关设备 WO2021120633A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20901734.2A EP4068725A4 (en) 2019-12-19 2020-07-30 LOAD BALANCING METHOD AND RELATED DEVICE
US17/843,754 US20220318071A1 (en) 2019-12-19 2022-06-17 Load balancing method and related device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911323403.9 2019-12-19
CN201911323403.9A CN113014611A (zh) 2019-12-19 2019-12-19 一种负载均衡方法及相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/843,754 Continuation US20220318071A1 (en) 2019-12-19 2022-06-17 Load balancing method and related device

Publications (1)

Publication Number Publication Date
WO2021120633A1 true WO2021120633A1 (zh) 2021-06-24

Family

ID=76381949

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/106021 WO2021120633A1 (zh) 2019-12-19 2020-07-30 一种负载均衡方法及相关设备

Country Status (4)

Country Link
US (1) US20220318071A1 (zh)
EP (1) EP4068725A4 (zh)
CN (1) CN113014611A (zh)
WO (1) WO2021120633A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113596152A (zh) * 2021-07-28 2021-11-02 杭州萤石软件有限公司 负载均衡实现方法、系统及装置

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11729263B2 (en) * 2020-09-22 2023-08-15 Ribbon Communications Operating Company, Inc. Methods, apparatus and systems for cloud native application multi-factor load balancing
US20230239237A1 (en) * 2022-01-27 2023-07-27 Dell Products L.P. Service discovery method for networks with multicast restrictions

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108519911A (zh) * 2018-03-23 2018-09-11 上饶市中科院云计算中心大数据研究院 一种基于容器的集群管理系统中资源的调度方法和装置
CN109167835A (zh) * 2018-09-13 2019-01-08 重庆邮电大学 一种基于kubernetes的物理资源调度方法及系统
US10291707B1 (en) * 2015-05-18 2019-05-14 Twitter, Inc. Systems and methods for balancing storage resources in a distributed database
CN109960585A (zh) * 2019-02-02 2019-07-02 浙江工业大学 一种基于kubernetes的资源调度方法

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685054B (zh) * 2013-12-18 2017-02-01 武汉烽火网络有限责任公司 基于业务感知的多路径负载均衡方法
US10242370B2 (en) * 2016-05-26 2019-03-26 Cloudcolt Software Inc. Enforcing compliance with administrative requirements relating to using computing resources
CN107819695B (zh) * 2017-10-19 2020-11-10 西安电子科技大学 一种基于sdn的分布式控制负载均衡系统与方法
CN110389843B (zh) * 2019-07-29 2022-04-15 广东浪潮大数据研究有限公司 一种业务调度方法、装置、设备及可读存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10291707B1 (en) * 2015-05-18 2019-05-14 Twitter, Inc. Systems and methods for balancing storage resources in a distributed database
CN108519911A (zh) * 2018-03-23 2018-09-11 上饶市中科院云计算中心大数据研究院 一种基于容器的集群管理系统中资源的调度方法和装置
CN109167835A (zh) * 2018-09-13 2019-01-08 重庆邮电大学 一种基于kubernetes的物理资源调度方法及系统
CN109960585A (zh) * 2019-02-02 2019-07-02 浙江工业大学 一种基于kubernetes的资源调度方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4068725A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113596152A (zh) * 2021-07-28 2021-11-02 杭州萤石软件有限公司 负载均衡实现方法、系统及装置
CN113596152B (zh) * 2021-07-28 2024-03-26 杭州萤石软件有限公司 负载均衡实现方法、系统及装置

Also Published As

Publication number Publication date
EP4068725A4 (en) 2023-02-22
US20220318071A1 (en) 2022-10-06
EP4068725A1 (en) 2022-10-05
CN113014611A (zh) 2021-06-22

Similar Documents

Publication Publication Date Title
US10791168B1 (en) Traffic aware network workload management system
US10171567B2 (en) Load balancing computer device, system, and method
US9632839B2 (en) Dynamic virtual machine consolidation
US8099615B2 (en) Method and system for power management in a virtual machine environment without disrupting network connectivity
Lee et al. Load-balancing tactics in cloud
WO2021120633A1 (zh) 一种负载均衡方法及相关设备
US8321862B2 (en) System for migrating a virtual machine and resource usage data to a chosen target host based on a migration policy
CN107547661B (zh) 一种容器负载均衡实现方法
Zhang et al. SDN-based load balancing strategy for server cluster
CN108833462A (zh) 一种面向微服务的自注册服务发现的系统及方法
WO2014190791A1 (zh) 一种网关设备身份设置的方法及管理网关设备
US9104488B2 (en) Support server for redirecting task results to a wake-up server
JP6272190B2 (ja) 計算機システム、計算機、負荷分散方法及びそのプログラム
CN112994937A (zh) 智融标识网络中虚拟cdn的部署与迁移系统
US9760370B2 (en) Load balancing using predictable state partitioning
WO2020082839A1 (zh) 报文处理方法、相关设备及计算机存储介质
US10382349B2 (en) Server for distributed controller system
WO2023207189A1 (zh) 负载均衡方法及系统、计算机存储介质、电子设备
KR20160025926A (ko) 가상 응용서버들로 부하를 분산하는 장치 및 방법
Ashalatha et al. Dynamic load balancing methods for resource optimization in cloud computing environment
EP3685567B1 (en) Load shedding of traffic based on current load state of target capacity
Vijayalakshmi et al. Investigations on job scheduling algorithms in cloud computing
KR20210016802A (ko) 소프트웨어 정의 네트워킹 환경에서 서버-클라이언트 기반의 네트워크 서비스를 위한 플로우 테이블을 최적화하는 방법 및 이를 위한 sdn 스위치
CN114020417A (zh) 一种虚拟负载均衡系统及其工作方法
Ivanisenko Methods and Algorithms of load balancing

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20901734

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020901734

Country of ref document: EP

Effective date: 20220629

NENP Non-entry into the national phase

Ref country code: DE