Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The load balancing distribution method provided by the application can be applied to an application environment shown in figure 1. Referring to fig. 1, the application scenario includes a terminal 110, a Service object (Service) 120, a load balancer (lb, loadBalance) 130, a container group (pod) 140, and a host 150, which are communicatively connected to each other. The container group 140 operates in a host machine 150. At least one container group 140 may be run in the same host 150. The same service object 120 corresponds to at least one container group 140. The service object 120 provides a unified fixed IP address as an entry address for the container group 140, and distributes the received access request to the corresponding container group 140 through the load balancer 130 according to the load balancing principle.
It is understood that a plurality of hosts 104 form a cluster, and that the hosts 104 act as nodes in the cluster. The clusters in the embodiments of the present application may be distributed clusters or non-distributed clusters, and the types of the clusters are not limited herein. Thus, the host 104 may be an independent physical server or virtual server, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms.
A first process may be executed in the host 150 to collect resource usage information for the host 150 from the host 150 and report the resource usage information to the load balancer 130. For each container group 140 corresponding to the same service object 120, the load balancer 130 may determine the load balancing weight of the container group 140 running in the host 150 according to the resource usage information of the host 150 on which the container groups 140 run, where the size of the resource usage rate represented by the resource usage information is inversely related to the size of the load balancing weight. The terminal 110 may initiate an access request to the service object 120, and the load balancer 130 may allocate the access request for the service object 120 to the container group 140 corresponding to the service object 120 according to the load balancing weight of the container group 140 corresponding to the accessed service object 120. Thus, the load balancing scheduling of the access request can be performed according to the resource use condition of the host.
It can be understood that the load balancing distribution method in the embodiment of the application is equivalent to using cloud technology to perform cloud computing processing.
Cloud technology (Cloud technology) refers to a hosting technology for integrating hardware, software, network and other series resources in a wide area network or a local area network to realize calculation, storage, processing and sharing of data.
Cloud technology (Cloud technology) is based on the general terms of network technology, information technology, integration technology, management platform technology, application technology and the like applied by Cloud computing business models, and can form a resource pool, so that the Cloud computing business model is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical networking systems require a large amount of computing, storage resources, such as video websites, picture-like websites, and more portals. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data with different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized only through cloud computing.
Cloud computing (clouding) is a computing model that distributes computing tasks across a large pool of computers, enabling various application systems to acquire computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the cloud are infinitely expandable in the sense of users, and can be acquired at any time, used as needed, expanded at any time and paid for use as needed.
As a basic capability provider of cloud computing, a cloud computing resource pool (abbreviated as a cloud platform, generally referred to as IaaS (Infrastructure AS A SERVICE) platform) is established, in which multiple types of virtual resources are deployed for external clients to select for use.
According to the logic function division, a PaaS (Platform AS A SERVICE, platform service) layer can be deployed on an IaaS (Infrastructure AS A SERVICE, infrastructure service) layer, and a SaaS (Software AS A SERVICE, service) layer can be deployed above the PaaS layer, or the SaaS can be directly deployed on the IaaS. PaaS is a platform on which software runs, such as a database, web container, etc. SaaS is a wide variety of business software such as web portals, sms mass senders, etc. Generally, saaS and PaaS are upper layers relative to IaaS.
It can be understood that the container group in the embodiment of the present application is a combination of a plurality of containers in the container cloud. In the embodiments of the application, the load balancing distribution is performed through cloud computing, and the computing tasks are distributed on the container cloud formed by a large number of hosts, namely, the resource pool is provided by the container cloud, so that various application systems can acquire computing power, storage space and information service according to the needs.
In one embodiment, as shown in fig. 2, a load balancing distribution method is provided, and the method is applied to the load balancer 130 in fig. 1 for illustration, and includes the following steps:
Step 202, for a plurality of container groups corresponding to the same service object, acquiring the reported resource usage information of the host machine on which the container group operates.
Wherein the container group is a combination of a group of containers. Containers are a set of processes that are resource constrained and isolated from each other. It will be appreciated that the container contains a complete runtime environment.
The Service object, i.e. Service, is an object abstracted at the upper layer of the container group, and is used to provide a fixed IP address for the container group as an access interface for providing services to the outside.
It will be appreciated that the IP address to which the container group corresponds will change as soon as it is restarted. Therefore, the access request of the client is received by a service object with a fixed IP address, so that no influence is caused on the access of the client no matter how the IP address of the container group changes, namely, the access request received by the service object can be forwarded to the container group corresponding to the service object according to the mapping relation between the service object and the container group. Therefore, the container group corresponds to the target server corresponding to the service object. The target server is the object which finally and truly processes the access request.
The host is a computer for performing computation that needs to install virtual machine software. It will be appreciated that the container group is running in a host, and that the host provides computing power for the container group running thereon. The host may be a virtual machine or a physical machine. A plurality of hosts form a cluster. A cluster is a computer system that is connected by a set of integrated computer software and/or hardware to perform computing work in a highly close collaboration.
It is understood that a service object may correspond to at least one container group, one container group running on each host. One host may run at least one container group. Multiple container groups corresponding to the same service object may run on the same or different hosts. That is, the container groups running in the same host may be container groups corresponding to different service objects.
To facilitate an understanding of the relationship between the service objects, the container groups, and the hosts, an example will now be described in connection with the topology diagram of FIG. 3. Referring to fig. 3, service object a (i.e., serviceA) corresponds to container group 1 and container group 2 (i.e., container group 1 and container group 2 are target servers of service object a), service object B (i.e., serviceB) corresponds to container group 3 (i.e., container group 3 is a target server of service object B), and container group 2 and container group 3 run on the same host 2. I.e. the container groups running on the host 2 are the container groups corresponding to two different service objects, service object a and service object B, respectively. The container group 1 and the container group 2 corresponding to the same service object a run on two different hosts, namely the host 1 and the host 2.
And the resource use information is used for describing the resource use condition in the host. The resource use information is collected and reported from the host by a first process running in the host.
The first process is a process capable of collecting resource usage information of the host from the host.
In one embodiment, the first process may be a native process in the host, i.e., the native process in the host may be modified to have the function of collecting the resource usage information of the host. For example, the first process may be a proxy daemon in the host, i.e., a agent process. It will be appreciated that the first process may also be a non-native process that is newly added in the host.
In one embodiment, the resource usage information may be a resource usage rate, or may be specific usage information of a resource for characterizing the resource usage rate. In one embodiment, the resources may include at least one of CPU, network bandwidth, disk, and memory. Accordingly, the resource usage information may include at least one of CPU usage information, network bandwidth usage information, disk usage information, and memory usage information.
Specifically, each host machine can run a first process, and the first process can collect the resource usage information of the host machine from the host machine in which each host machine runs and report the collected resource usage information. When the load balancer needs to determine the liability balance weight of each container group corresponding to the same service object, the load balancer can acquire the resource use information of the host machine operated by each container group of the same service object from the reported resource use information of each host machine.
It can be understood that the resource usage information may be directly reported by the host, or may be reported by the host to a third party, and forwarded by the third party to the load balancer. That is, the host may directly report the collected resource usage information of the host to the load balancer through the first process, or may report the resource usage information of the host to the third party device, and the third party device forwards the resource usage information to the load balancer.
Step 204, determining the load balancing weight of the container group running in the host according to the resource usage information of each host.
Wherein the resource usage information is related to the load balancing weights.
The resource usage information can characterize the size of the resource usage of the host. In one embodiment, the resource usage information may be the resource usage itself. In another embodiment, the resource usage information may also be information characterizing the size of the resource usage, i.e. information reflecting the resource usage.
In one embodiment, the size of the resource usage characterized by the resource usage information is inversely related to the load balancing weight size.
When the resource usage information characterizes the greater the resource usage of the host, it indicates that the host is able to use less remaining resources, and the less load balancing weight of the container group running in the host. On the contrary, when the resource usage information characterizes the smaller resource usage rate of the host, it indicates that the host can use more residual resources, and the load balancing weight of the container group running in the host is larger.
It will be appreciated that the determination in step 204 is that the load balancing weights of the group of containers running in the host and corresponding to the service object.
And 206, distributing the access request aiming at the service object to the container group corresponding to the service object according to the load balancing weight.
Specifically, the terminal may send an access request to a service object, and the load balancer may allocate the access request for the service object to the container group corresponding to the service object according to the load balancing weight of the container group corresponding to the accessed service object, that is, implement load balancing scheduling.
The access request of the client or the terminal is first sent to the service object. And the load balancer forwards the access request received to the service object to the container group corresponding to the service object according to the load balancing weight of the container group corresponding to the service object. It will be appreciated that when a service object is for only one container group, then the access request received by the service object is forwarded to the unique corresponding container group. When the service object corresponds to a plurality of container groups, the access request received by the service object can be forwarded to the container group corresponding to the service object according to the load balancing weight of the container group corresponding to the service object.
An example will now be given by way of example in fig. 3. If a large number of requests access to the service object B, the container group 3 corresponding to the service object B is accessed, so that the load of the host 2 is increased, and the processing capacity of the container group 2 of the service object a on the host 2 is reduced. In the conventional method, the load balancer cannot sense this point, or sends the access request received by the service object a to the container group 2 according to the statically configured scheduling algorithm. This results in a decrease in the service efficiency of the service object a as a whole. According to the scheme of the application, the load balancer can obtain the resource usage information of the hosts 1 and 2 corresponding to the service object A, and determine that the load of the host 2 is heavy, so that the processing capacity of the container group 2 running on the host 2 can be perceived to slide down, and further, less load balancing weight is dynamically allocated to the container group 2, and more load balancing weight is dynamically allocated to the container group 1. Furthermore, the access requests for the service object a can be dynamically allocated to the container group 1 and the container group 2 according to the load balancing weights of the corresponding container groups (the container group 1 and the container group 2) of the service object a, so that more access requests can be transferred to the container group 1, and the service efficiency of the service object a as a whole is improved.
The load balancing distribution method comprises the steps of respectively obtaining reported resource usage information of a host machine operated by a container group corresponding to the same service object, collecting and reporting the resource usage information from the host machine by a first process operated in the host machine, determining load balancing weights of the container groups operated in the host machine according to the resource usage information of each host machine, wherein the resource usage information is related to the load balancing weights, and distributing access requests for the service object to the container groups corresponding to the service object according to the load balancing weights. The real load condition of the host can be accurately represented by the resource use information of the host, and then the load balancing weight of the container group can be more accurately and dynamically determined according to the resource use information of the host, so that the load balancing distribution can be more accurately performed based on the dynamically determined load balancing weight. In addition, practical tests show that when the host machine has unbalanced load, the method in the embodiments of the application greatly improves the responsiveness of the service object, and the resource cost used by the method in the embodiments of the application is very low.
In one embodiment, respectively acquiring the resource usage information of the host machine where the reported container groups are operated for a plurality of container groups corresponding to the same service object comprises acquiring the resource usage information of the host machine where each container group forwarded by the controller is operated for a plurality of container groups corresponding to the same service object.
The resource use information forwarded by the controller is collected from the host machine and reported to the controller by a first process running in the host machine.
Wherein the controller is a model that controls the resource to achieve the "desired" transition. And the controller is equivalent to a state machine and is used for controlling the specific state and behavior of the container group.
Specifically, the host machine can collect the resource usage information of the host machine through a first process running on the host machine, and report the resource usage information to the controller through the first process. The controller may forward the reported resource usage information to the load balancer.
For ease of understanding, an example will now be described in connection with the architecture diagram of fig. 4. Referring to fig. 4, a container group 1 and a container group 2 are respectively operated on a host 1 and a host 2. The host 1 and the host 2 respectively run a agent daemon (i.e. a first process) to collect respective resource usage (i.e. belonging to resource usage information), and report the collected resource usage to the controller, which can notify the load balancer lb of the reported resource usage. The load balancer runs a weight setting process weight-setter (i.e., a second process) and a load balancing program (e.g., linux IPVS, i.e., a load balancing software program of the Linux system). The load balancer can determine the load balancing weight of the container groups running in each host machine according to the reported resource utilization rate of the host machine through a weight setting process, and the original load balancing weight of each container group recorded in the load balancing program is modified into the determined load balancing weight through the weight setting process. Subsequently, after the service object receives the access request, the load balancer may allocate the access request for the service object to the service object according to the modified load balancing weight of each container group corresponding to the service object.
In the above embodiment, the host machine reports the resource usage information of the host machine to the controller through the first process, and then the resource usage information is forwarded to the load balancer by the controller, so that the resource usage information of the host machine can be reported under the original framework only by adding the first process, which is very convenient and fast, and unnecessary cost caused by excessive modification is avoided.
In one embodiment, step 204 of determining the load balancing weights of the container groups running in the hosts according to the resource usage information of each host includes determining the load balancing weights of the container groups running in the hosts according to the resource usage information of the hosts through a second process running in a load balancer, and modifying the original load balancing weights of the container groups recorded in a load balancing program running in the load balancer to the determined load balancing weights through the second process.
The second process is a process running in the load balancer and used for setting load balancing weights. I.e. may be referred to as a weight setting process. The load balancing program is a software program running in the load balancer and having the load balancing weights of the container groups recorded therein. It will be appreciated that the load balancing program may implement the load balancing distribution process according to the recorded load balancing weights.
Specifically, the load balancer can determine the load balancing weight of the container group running in the host according to the reported resource usage information of the host through the second process running in the load balancer. The load balancer may modify the original load balancing weights of the container group running in the load balancing program of the load balancer into the load balancing weights determined in step 204 through the second process, so as to dynamically modify the load balancing weights of the set container group. Thus, the dynamically modified load balancing weights are recorded in the load balancing program. The load balancer can dynamically allocate the access request aiming at the service object to the container group corresponding to the service object according to the dynamically modified load balancing weight recorded in the load balancing program.
In the above embodiment, by setting the second process in the load balancer, the load balancing weight of the container group in the host can be dynamically determined and modified according to the resource usage information of the host, which is very convenient, and avoids changing the original framework, thereby avoiding cost waste.
In one embodiment, step 204 of determining the load balancing weights of the container groups running in the hosts according to the resource usage information of each host includes determining, for each of the hosts, the load balancing weights of the container groups running in the hosts according to the resource usage information of the host and the total resource usage information corresponding to the service object.
The total resource usage information is the sum of the resource usage information of each host machine operated by each container group corresponding to the service object.
Specifically, when the load balancer needs to determine the load balancing weight of each container group of the same service object, each host machine on which each container group corresponding to the service object operates can be determined, and the total resource usage information corresponding to the service object is obtained according to the sum of the determined resource usage information of each host machine. For each host machine in which each container group corresponding to the service object operates, the load balancer can determine the load balancing weight of the container group operating in the host machine according to the resource usage information of the host machine and the total resource usage information corresponding to the service object.
For ease of understanding, an example will now be described in connection with fig. 3. Assuming that the access request received by the service object a needs to be subjected to load balancing allocation, the load balancing weights of the container group 1 and the container group 2 corresponding to the service object a need to be determined. The load balancer can acquire the resource usage information of the host 1 operated by the container group 1 and the resource usage information of the host 2 operated by the container group 2. The load balancer may determine total resource usage information corresponding to the service object a (i.e., the sum of the resource usage information corresponding to the hosts 1 and 2). The load balancer can determine the load balancing weight corresponding to the container group 1 on the host 1 according to the resource usage information of the host 1 and the total resource usage information corresponding to the service object a. Similarly, the load balancer may determine the load balancing weight corresponding to the container group 2 on the host 2 according to the resource usage information of the host 2 and the total resource usage information corresponding to the service object a.
In one embodiment, for each host, the load balancer may determine, through a second process, a load balancing weight of a container group running in the host according to the resource usage information of the host and total resource usage information corresponding to the service object. Further, the original load balancing weight of the container group recorded in the load balancing program running in the load balancing device is modified to be the determined load balancing weight through the second process.
In the above embodiment, according to the resource usage information of the host and the total resource usage information corresponding to the service object, the load balancing weight of the container group running in the host can be accurately and conveniently determined. Thereby improving the accuracy of subsequent load balancing distribution.
In one embodiment, determining the load balancing weight of the container group running in the host according to the resource usage information of the host and the total resource usage information corresponding to the service object includes determining a first occupation ratio corresponding to the host according to the CPU usage information of the host when the resource usage information includes the CPU usage information and the network bandwidth usage information, determining a second occupation ratio corresponding to the host according to the network bandwidth usage information of the host, and determining the load balancing weight of the container group running in the host according to the first occupation ratio and the second occupation ratio.
The first ratio is a ratio of CPU usage information of the host to total CPU usage information corresponding to the service object. That is, the first duty ratio is a CPU resource duty ratio. The total CPU usage information is the sum of CPU usage information of each host on which each container group corresponding to the service object operates.
The second ratio is a ratio of network bandwidth usage information of the host to total network bandwidth usage information corresponding to the service object. The second ratio is the network bandwidth ratio. The total network bandwidth usage information is the sum of the network bandwidth usage information of each host machine on which each container group corresponding to the service object operates.
It is understood that CPU usage information characterizes the amount of resources that the CPU is using. Accordingly, the CPU usage information may be an amount of CPU resources that are used (i.e., occupied) or an amount of CPU resources that are idle (i.e., spare, unused). Network bandwidth usage information characterizing the network bandwidth usage. Accordingly, the network bandwidth usage information may be the amount of network bandwidth that is used or the amount of network bandwidth that is idle.
In one embodiment, the data structure of the resource usage information of the host (i.e., the fabric node_cfg) may be as follows:
the structure indicates that, for a container group (pod) corresponding to a service object (service), the redundant cpu hertz and network bandwidth of the host (i.e., node) on which the container group operates are acquired, and resource usage information of the host is obtained.
In one embodiment, determining the load balancing weight for the group of containers running in the host based on the first and second occupancy rates includes minimizing the first and second occupancy rates to obtain the load balancing weight for the group of containers running in the host when the CPU usage information is an amount of idle CPU resources and the network bandwidth usage information is an amount of idle network bandwidth.
It will be appreciated that the load balancer may directly take the minimum as the load balancing weight for the set of containers running in the host. The minimum value may be further subjected to a numerical conversion process (e.g., linear conversion) to obtain a load balancing weight of the container group running in the host.
In the above embodiment, since the usage conditions of either the CPU or the network bandwidth affect the load condition of the host, the load balancing weight is determined by selecting one with a smaller idle amount from the CPU idle condition and the network bandwidth idle condition, so that the accuracy can be improved.
In one embodiment, when only one container group is running in the host, then the minimum value taken may be used as the load balancing weight for that container group. When there are multiple container groups in the host, then the load balancing weights of the container groups running in the host may be further determined according to the minimum value.
In one embodiment, taking the minimum value of the first occupancy rate and the second occupancy rate to obtain the load balancing weight of the container group running in the host machine comprises taking the minimum value of the first occupancy rate and the second occupancy rate when a plurality of container groups run in the host machine, dividing the taken minimum value according to the number of the container groups running in the host machine, and taking the divided value as the load balancing weight of the container group running in the host machine.
It will be understood that "plurality" in various embodiments of the application means at least two.
In one embodiment, the load balancer may determine the number of container groups running in the host, divide the minimum value by equal amounts according to the number of container groups running in the host, and use the divided value as the load balancing weight of each container group running in the host.
For example, for the structure node_cfg of the resource usage information of each host, calculating the ratio of the number of idle CPU hertz (i.e., cpu_hz, the amount of idle CPU resources) to the total amount of idle CPU resources (i.e., the sum of the amounts of idle CPU resources node cpu_hz of the respective hosts) of all the hosts corresponding to the service object (service), to obtain the first occupation ratio cpu_ratio. And calculating the ratio of the idle network bandwidth amount (i.e. net_pps) to the idle total network bandwidth amount (i.e. the sum of the idle network bandwidth amounts node net_pps of the respective hosts) of all the hosts corresponding to the service object (service), to obtain a second ratio net_ratio. Finally, taking min (cpu_ratio), namely the first occupation ratio and the second occupation ratio as minimum values, and taking the minimum values as load balancing weights of the container groups (pod) on the host. If N container groups (pod) are on the same host (node), then min (cpu_ratio)/N may be used as the load balancing weight of each container group on the host. That is, the minimum value is equally divided, and the divided value is used as the load balancing weight of each container group on the host machine.
In the embodiment, when a plurality of container groups are operated in the host, the minimum value is divided according to the number of the container groups operated in the host, and the divided value is used as the load balancing weight of the container groups operated in the host, so that each container group in the same host can be considered, and the accuracy of the load balancing weight of each container group is improved.
In one embodiment, determining the load balancing weight for the group of containers running in the host based on the first and second occupancy rates includes maximizing the first and second occupancy rates when the CPU usage information is an amount of occupied CPU resources and the network bandwidth usage information is an amount of occupied network bandwidth, and determining the load balancing weight for the group of containers running in the host based on the maximized values. The magnitude of the load balancing weight of the container group is inversely related to the magnitude of the maximum value. That is, the larger the maximum value taken, the larger the amount of occupied resources, the smaller the load balancing weight. The smaller the maximum value taken, the smaller the amount of occupied resources, and the larger the load balancing weight.
In other embodiments, the load balancer may also combine (e.g., linearly calculate) the first and second duty cycles to determine a new value as the load balancing weight for the set of containers running in the host.
In the above embodiment, the CPU usage information and the network bandwidth usage information can reflect the load condition of the host relatively accurately, so that the load balancing weight of the container group running in the host can be determined accurately according to the CPU usage duty ratio (i.e., the first duty ratio) and the network bandwidth usage duty ratio (i.e., the second duty ratio) of the host. Thereby improving the accuracy of subsequent load balancing distribution.
As shown in fig. 5, in one embodiment, a load balancing distribution method is provided, and the method is applied to the host 150 in fig. 1 for illustration. The method comprises the following steps:
Step 502, the host collects the resource usage information of the host according to the running first process.
And 504, reporting the resource use information to the load balancer, wherein the resource use information is used for indicating the load balancer to determine the load balancing weight of the container group running on the host machine according to the resource use information.
In step 506, the access request of the service object corresponding to the container group running on the host machine and distributed to the load balancer according to the load balancing weight is received through the container group running on the host machine.
In one embodiment, the first process is a native process running in the host's local end and used to gather the host's resource usage information. In other embodiments, the first process may also be a newly added non-native process.
In one embodiment, the resource usage information is used to instruct the load balancer to determine, according to the resource usage information, a load balancing weight of a container group running on the host through the second process, and modify an original load balancing weight of the container group running in a load balancing program of the load balancer to the determined load balancing weight. Wherein the second process is the process that is responsible for running in the equalizer and is used to determine and modify the load balancing weights.
In the above embodiment, the first process is run in the host to collect and report the resource usage information of the host, so that the real load condition of the host can be accurately represented, and further, according to the resource usage information of the host, the load balancing weight of the container group can be dynamically determined more accurately, so that the received access request can be more accurately distributed in a load balancing manner.
As shown in fig. 6, in one embodiment, a resource balanced allocation system 600 is provided, the system 600 comprising a host 602, a set of containers 604 running in the host 602, and a load balancer 606, wherein:
The host 602 is configured to collect resource usage information of the host according to a first process, and report the resource usage information to the load balancer 606.
The load balancer 606 is configured to determine, for a plurality of container groups 604 corresponding to the same service object, a load balancing weight of the container group 604 running in the host 602 according to resource usage information of the host 602 in which each container group 604 runs, where the resource usage information is related to the load balancing weight.
The load balancer 606 is further configured to distribute, according to the load balancing weight, an access request for the service object to the container group 602 corresponding to the service object.
As shown in fig. 7, in one embodiment, the system further includes a controller 605.
The host 604 is further configured to collect resource usage information of the host according to the first process, and report the resource usage information to the controller 605.
The controller 605 is also configured to forward the resource usage information to the load balancer.
In one embodiment, the load balancer 606 has a second process and a load balancing program running therein, wherein the load balancing program has the original load balancing weights of the container group recorded therein;
The load balancer 606 is further configured to determine, according to resource usage information of a host machine in which each container group is running, a load balancing weight of the container group running in the host machine for a plurality of container groups corresponding to the same service object through the second process, and modify, through the second process, the original load balancing weight recorded in the load balancing program to the determined load balancing weight.
In one embodiment, the load balancer 606 is further configured to determine, for each host, a load balancing weight of a container group running in the host according to the resource usage information of the host and total resource usage information corresponding to the service object, where the total resource usage information is a sum of resource usage information of hosts running in the container groups corresponding to the service object.
In one embodiment, the load balancer 606 is further configured to determine, when the resource usage information includes CPU usage information and network bandwidth usage information, a first occupation ratio corresponding to the host according to the CPU usage information of the host, where the first occupation ratio is a ratio of the CPU usage information of the host to total CPU usage information corresponding to the service object, the total CPU usage information is a sum of CPU usage information of hosts operated by container groups corresponding to the service object, determine, according to the network bandwidth usage information of the host, a second occupation ratio corresponding to the host, where the second occupation ratio is a ratio of network bandwidth usage information of the host to total network bandwidth usage information corresponding to the service object, where the total network bandwidth usage information is a sum of network bandwidth usage information of hosts operated by container groups corresponding to the service object, and determine, according to the first occupation ratio and the second occupation ratio, a load balance among the container groups operated by the host.
In one embodiment, the load balancer 606 is further configured to, when the CPU usage information is an amount of idle CPU resources and the network bandwidth usage information is an amount of idle network bandwidth, take a minimum value for the first occupancy rate and the second occupancy rate, and obtain a load balancing weight of a container group running in the host.
In one embodiment, the load balancer 606 is further configured to divide the minimum value of the first duty ratio and the second duty ratio according to the number of the container groups running in the host machine when a plurality of container groups run in the host machine, and use the divided value as a load balancing weight of each container group running in the host machine.
Fig. 8 is a timing diagram of a load balancing distribution method in one embodiment. The method specifically comprises the following steps:
(1) The host reports the idle CPU resource amount and the idle network bandwidth amount of the host to the controller through the proxy daemon.
(2) The controller informs the load balancer of the reported amount of idle CPU resources and the amount of idle network bandwidth.
(3) For a plurality of container groups corresponding to the same service object, the load balancer can acquire the idle CPU resource amount and the idle network bandwidth amount of the host machine where each container group operates according to the reporting condition.
(4) For each host, the load balancer can obtain a first occupation ratio corresponding to the host according to the ratio of the idle CPU resource amount of the host to the idle CPU total resource amount corresponding to the service object through a weight setting process.
(5) The load balancer can obtain a second occupation ratio corresponding to the host machine according to the ratio of the idle network bandwidth use information of the host machine to the total idle network bandwidth corresponding to the service object through a weight setting process.
(6) When only one container group is operated in the host, the load balancer can take the minimum value for the first occupation ratio and the second occupation ratio to obtain the load balancing weight of the container group.
(7) When a plurality of container groups are operated in the host, the load balancer can divide the minimum value in the first occupation ratio and the second occupation ratio according to the number of the container groups operated in the host, and load balancing weights of the container groups are obtained.
(8) The load balancer may distribute the access request for the service object to the container group corresponding to the service object according to the load balancing weight of each container group.
As shown in fig. 9, in one embodiment, a load balancing distribution apparatus is provided, disposed in a load balancer. The device comprises an acquisition module 902, a weight determination module 904 and a request distribution module 906, wherein:
The obtaining module 902 is configured to obtain, for a plurality of container groups corresponding to the same service object, resource usage information of a host machine on which the reported container groups run, where the resource usage information is collected and reported from the host machine by a first process running in the host machine.
The weight determining module 904 is configured to determine a load balancing weight of a container group running in the host according to the resource usage information of each host, where the resource usage information is related to the load balancing weight.
And a request allocation module 906, configured to allocate, according to the load balancing weight, an access request for the service object to a container group corresponding to the service object.
In one embodiment, the obtaining module 902 is further configured to obtain, for a plurality of container groups corresponding to the same service object, resource usage information of a host machine on which each of the container groups forwarded by the controller operates.
In one embodiment, the weight determining module 904 is further configured to determine, according to the resource usage information of the host, a load balancing weight of a container group running in the host through a second process running in a load balancer, and modify, by the second process, an original load balancing weight of the container group recorded in a load balancing program running in the load balancer to the determined load balancing weight.
In one embodiment, the weight determining module 904 is further configured to determine, for each host, a load balancing weight of a container group running in the host according to the resource usage information of the host and total resource usage information corresponding to the service object, where the total resource usage information is a sum of resource usage information of hosts running in the container groups corresponding to the service object.
In one embodiment, the weight determining module 904 is further configured to determine, when the resource usage information includes CPU usage information and network bandwidth usage information, a first occupation ratio corresponding to the host according to the CPU usage information of the host, where the first occupation ratio is a ratio of the CPU usage information of the host to total CPU usage information corresponding to the service object, the total CPU usage information is a sum of CPU usage information of hosts operated by respective container groups corresponding to the service object, determine, according to the network bandwidth usage information of the host, a second occupation ratio corresponding to the host, where the second occupation ratio is a ratio of the network bandwidth usage information of the host to total network bandwidth usage information corresponding to the service object, where the total network bandwidth usage information is a sum of network bandwidth usage information of hosts operated by respective container groups corresponding to the service object, and determine, according to the first occupation ratio and the second occupation ratio, a load balance among the container groups operated by the host.
In one embodiment, the weight determining module 904 is further configured to, when the CPU usage information is an amount of idle CPU resources and the network bandwidth usage information is an amount of idle network bandwidth, take a minimum value for the first occupancy rate and the second occupancy rate, and obtain a load balancing weight of a container group running in the host.
In one embodiment, the weight determining module 904 is further configured to divide the minimum value of the first occupancy rate and the second occupancy rate according to the number of the container groups running in the host machine when a plurality of container groups run in the host machine, and use the divided value as a load balancing weight of each of the container groups running in the host machine.
As shown in fig. 10, in one embodiment, a load balancing and distributing apparatus is provided, for example, disposed in a host, where the load balancing and distributing apparatus includes an acquisition module 1002, a reporting module 1004, and a request receiving module 1006, where:
and the collection module 1002 is configured to collect, according to the running first process, resource usage information of the host.
And the resource usage information is used for indicating the load balancer to determine the load balancing weight of the container group running on the host according to the resource usage information.
The request receiving module 1006 is configured to receive, through a container group running on a host, an access request, which is allocated by the load balancer according to the load balancing weight and is directed to a service object corresponding to the container group running on the host.
For specific limitations of the load balancing and distributing device, reference may be made to the above limitation of the load balancing and distributing method, and no further description is given here. The modules in the load balancing and distributing device can be realized in whole or in part by software, hardware and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a load balancer or a host, the internal structure of which may be as shown in fig. 11. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing search data. The network interface of the computer device is used for communicating with an external computer device through a network connection. The computer program, when executed by a processor, implements a load balancing distribution method. It will be appreciated that the server implements the background processing steps in the load balancing distribution method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 11 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.