A resource scheduling method, device, apparatus, storage medium and program product
By optimizing Kubernetes resource scheduling through an improved artificial bee colony algorithm, and combining historical and predicted load data of nodes, the problem of uneven resource sharding is solved, achieving more efficient resource utilization and load balancing.
Patent Information
- Application Number
- CN202511350219.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-22
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-09-22
AI Technical Summary
Existing Kubernetes resource scheduling algorithms do not fully consider the actual proportion of CPU, memory, bandwidth, and disk capacity used on nodes, resulting in uneven resource sharding and affecting resource utilization and load balancing.
An improved artificial bee colony algorithm is adopted, which combines historical and predicted load data of nodes. Through weight calculation and adaptive random rule distribution, the resource scheduling strategy is optimized to select the most suitable target nodes for Pod deployment.
This achieves balanced resource deployment, improves cluster resource utilization and load balancing, and avoids node resource waste and unstable Pod operation.
Smart Images

Figure CN120849063B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of resource scheduling, and in particular to a resource scheduling method, device, equipment, storage medium and program product. BACKGROUND
[0002] Kubernetes is a container orchestration tool for deploying and managing containerization, which mainly utilizes Pod (the smallest deployment unit, containing one or more containers) for resource scheduling. Specifically, first, nodes that meet the resource size required by the Pod application are screened out, then the nodes are scored according to the remaining CPU and memory utilization, and the node with the highest score is selected to deploy the Pod application.
[0003] However, the Pod-based resource scheduling algorithm mainly relies on CPU and memory resources indicators for decision-making when processing the Pod, and does not fully consider the influence of the actual occupation proportion of the four types of resources, CPU, memory, bandwidth and disk capacity, on the performance of the node, and ignores the dynamic changes of the actual resources of the node, so that the Pod-based resource scheduling algorithm is not competent when applied to various applications, and there is a problem of uneven resource fragmentation. SUMMARY
[0004] In view of the problems in the prior art, the embodiments of the present application provide a resource scheduling method, device, equipment, storage medium and program product, which can realize balanced deployment of resources and improve the resource utilization and load balancing degree of the entire cluster.
[0005] In a first aspect, the embodiments of the present application provide a resource scheduling method, comprising:
[0006] intercepting the Pod created in the Kubernetes cluster to obtain a plurality of to-be-scheduled Pods;
[0007] screening a plurality of to-be-deployed nodes from the Kubernetes cluster according to the resource type and resource requirement of the plurality of to-be-scheduled Pods and the resource information of the nodes in the Kubernetes cluster;
[0008] determining the target node of each to-be-scheduled Pod from the plurality of to-be-deployed nodes according to the resource scheduling strategy based on the improved artificial bee colony algorithm, and deploying the plurality of to-be-scheduled Pods to the corresponding target nodes.
[0009] As an improvement of the above-mentioned scheme, the intercepting the Pod created in the Kubernetes cluster to obtain a plurality of to-be-scheduled Pods comprises:
[0010] In a preset interception period, intercept the Pods created in the Kubernetes cluster; wherein the interception period is determined according to the Pod request rate and the Pod delay tolerance;
[0011] In the case where the number of intercepted Pods reaches a preset number threshold, the intercepted Pods are taken as the to-be-scheduled Pods.
[0012] As an improvement of the above-mentioned scheme, the filtering of the to-be-deployed nodes from the Kubernetes cluster according to the resource type and resource requirement of each of the to-be-scheduled Pods and the resource information of each of the nodes in the Kubernetes cluster comprises:
[0013] According to the resource requirement of each of the to-be-scheduled Pods, the type of each of the to-be-scheduled Pods is divided, and the resource type of each of the to-be-scheduled Pods is determined;
[0014] According to the historical load data of each of the nodes in the Kubernetes cluster, the predicted load data of each of the nodes in a plurality of time units within a future set time is obtained, and according to the predicted load data of the nodes, a plurality of candidate nodes are filtered from the nodes of the Kubernetes cluster;
[0015] According to the resource type of each of the to-be-scheduled Pods and the resource information of each of the candidate nodes, a plurality of to-be-deployed nodes are filtered from the plurality of candidate nodes.
[0016] As an improvement of the above-mentioned scheme, the filtering of the to-be-deployed nodes from the Kubernetes cluster according to the resource type of each of the to-be-scheduled Pods and the resource information of each of the candidate nodes comprises:
[0017] determining whether the CPU resource utilization rate of each of the nodes exceeds a preset utilization rate threshold;
[0018] If not, the corresponding node is regarded as a candidate node;
[0019] If yes, the CPU load data collected in a set time period of the corresponding node is obtained as the historical load data;
[0020] According to the historical load data of the corresponding node, CPU load prediction is performed through a preset load prediction model to obtain the predicted load data of the corresponding node in a plurality of time units within a future set time;
[0021] determine whether the predicted load data of the corresponding node in a plurality of time units within a future set time meets a preset load condition; the load condition includes that there is at least a first set number of predicted load data exceeding a preset load threshold;
[0022] When the load condition is met, the corresponding node is regarded as a candidate node.
[0023] As an improvement of the above scheme, the filtering of the plurality of to-be-deployed nodes from the plurality of candidate nodes according to the resource types of the plurality of to-be-scheduled Pods and the resource information of the plurality of candidate nodes comprises:
[0024] According to the resource type of each to-be-scheduled Pod, the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth and disk space is determined;
[0025] According to the resource information of each candidate node, the total resource amount and the used resource amount of each candidate node on CPU, memory, network bandwidth and disk space, and the requested resource amount of the to-be-scheduled Pod on CPU, memory, network bandwidth and disk space are determined, and the resource usage and the remaining resource amount of each candidate node on CPU, memory, network bandwidth and disk space after scheduling the Pod are determined according to the total resource amount, the used resource amount and the requested resource amount;
[0026] According to the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth and disk space, the resource usage, the remaining resource amount and the disk read-write speed of each candidate node on CPU, memory, network bandwidth and disk space, the performance score of each candidate node is calculated;
[0027] According to the performance score of each candidate node, the plurality of to-be-deployed nodes are filtered from the plurality of candidate nodes.
[0028] As an improvement of the above scheme, the determination of the target node of each to-be-scheduled Pod from the plurality of to-be-deployed nodes according to the resource scheduling strategy based on the improved artificial bee colony algorithm comprises:
[0029] According to the plurality of to-be-scheduled Pods, the bee colony is initialized, and the search space is initialized according to the plurality of to-be-deployed nodes;
[0030] In the employed bee search stage, the improved ant colony algorithm is used for global optimization of the search space to determine a first search region;
[0031] In the onlooker bee selection stage, a preset adaptive random rule distribution is used for position updating of the first search region to determine a second search region;
[0032] In the investigation bee search stage, fitness values of each position in the second search region are calculated, and an optimal position of the bee colony is determined according to the fitness values of each position in the second search region; each position corresponds to a to-be-deployed node;
[0033] The optimal position of the bee colony is iteratively updated to determine the most suitable position of the bee colony;
[0034] According to the to-be-deployed node indicated by the most suitable position and the mapping relationship between the to-be-deployed node and the plurality of to-be-scheduled Pods indicated by the bee colony, a target node corresponding to the plurality of to-be-scheduled Pods is determined.
[0035] As an improvement of the above scheme, the improved ant colony algorithm is used to perform global optimization on the search space to determine a first search region, comprising:
[0036] Ant colony parameters are initialized, and the path pheromone concentration is initialized to a preset concentration value;
[0037] According to the path pheromone concentration and a preset heuristic function, a probability value of each to-be-scheduled Pod in each population being scheduled to any to-be-deployed node in the search space is calculated;
[0038] According to the probability value of each to-be-scheduled Pod being scheduled to any to-be-deployed node in the search space, a target scheduling node of each to-be-scheduled Pod is determined;
[0039] According to the load balancing degree of the currently determined target scheduling node, the path pheromone concentration is updated;
[0040] According to the updated path pheromone concentration, the target scheduling node of each to-be-scheduled Pod is re-determined until a preset iteration termination condition is met, and the final target scheduling node of each to-be-scheduled Pod is determined as a first search region.
[0041] As an improvement of the above scheme, the probability value of each to-be-scheduled Pod in each population being scheduled to any to-be-deployed node in the search space is calculated according to the path pheromone concentration and a preset heuristic function, comprising:
[0042] According to the utilization of CPU, memory, network bandwidth and disk space of the corresponding to-be-deployed node when each to-be-scheduled Pod is scheduled to any to-be-deployed node, and the average utilization of CPU, memory, network bandwidth and disk space of all to-be-deployed nodes in the search space, the expected degree of each to-be-scheduled Pod being scheduled to any to-be-deployed node is calculated through the heuristic function;
[0043] According to the expected degree of each of the to-be-scheduled Pods being scheduled to any one of the to-be-deployed nodes, the path information concentration, a probability value of each of the to-be-scheduled Pods being scheduled to any one of the to-be-deployed nodes is calculated.
[0044] As an improvement of the above scheme, the updating of the path information concentration according to the load balancing degree of the currently determined target scheduling node comprises:
[0045] According to the utilization of CPU, memory, network bandwidth and disk space of the corresponding target scheduling node when each of the to-be-scheduled Pods is scheduled to the corresponding target scheduling node, and the average utilization of CPU, memory, network bandwidth and disk space of all the target scheduling nodes, a load balancing degree of each of the to-be-scheduled Pods being scheduled to the corresponding target scheduling node is calculated as the load balancing degree of the ant scheduling each of the to-be-scheduled Pods;
[0046] Each of the ants is sorted according to the load balancing degree of each of the ants, and a ranking of each of the ants is determined;
[0047] According to the load balancing degree and the ranking of each of the ants, an increment of the path information concentration is calculated;
[0048] According to the path information concentration and the increment thereof, the path information concentration is updated.
[0049] As an improvement of the above scheme, the position updating of the first search region by using the adaptive random rule distribution to determine the second search region comprises:
[0050] The standard Gaussian distribution and the Cauchy distribution are taken as limit distributions of continuous probability distributions under the condition of setting degrees of freedom, so as to obtain the adaptive random rule distribution;
[0051] The first search region is position updated by using the adaptive random rule distribution, so as to determine the second search region.
[0052] In a second aspect, an embodiment of the present application provides a resource scheduling device, comprising:
[0053] A Pod interception module is configured to intercept Pods created in a Kubernetes cluster to obtain a plurality of to-be-scheduled Pods.
[0054] A node screening module is configured to screen a plurality of to-be-deployed nodes from the Kubernetes cluster according to resource types and resource demands of the plurality of to-be-scheduled Pods and resource information of nodes in the Kubernetes cluster.
[0055] The pod scheduling module is configured to determine a target node for each of the to-be-scheduled pods from the plurality of to-be-deployed nodes according to a resource scheduling strategy based on the improved artificial bee colony algorithm, and deploy the plurality of to-be-scheduled pods to the corresponding target nodes.
[0056] In a third aspect, an embodiment of the present application provides a resource scheduling device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the resource scheduling method according to any one of the first aspect when executing the computer program.
[0057] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and when the computer program runs, the computer readable storage medium controls a device where the computer readable storage medium is located to execute the resource scheduling method according to any one of the first aspect.
[0058] In a fifth aspect, an embodiment of the present application provides a computer program product, including computer programs / instructions, and the computer programs / instructions implement the resource scheduling method according to any one of the first aspect when executed by a processor.
[0059] Compared with the prior art, the resource scheduling method, device, equipment, storage medium and program product provided by the embodiment of the present application can obtain a plurality of to-be-scheduled pods by intercepting the pods created in the Kubernetes cluster, then screen a plurality of to-be-deployed nodes from the Kubernetes cluster according to the resource type and resource demand of the plurality of to-be-scheduled pods and the resource information of the nodes in the Kubernetes cluster, and finally determine a target node for each of the to-be-scheduled pods from the plurality of to-be-deployed nodes according to a resource scheduling strategy based on the improved artificial bee colony algorithm, and deploy the plurality of to-be-scheduled pods to the corresponding target nodes, so that the balanced deployment of resources can be realized, and the resource utilization rate and the load balancing degree of the entire cluster are improved. BRIEF DESCRIPTION OF DRAWINGS
[0060] In order to more clearly illustrate the technical solutions of the present application, the drawings used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0061] Figure 1 is a flowchart of a resource scheduling method provided by an embodiment of the present application;
[0062] Figure 2is a node search process schematic diagram of Pod scheduling provided by an embodiment of the present application;
[0063] Figure 3 is a system framework schematic diagram of Pod scheduling provided by an embodiment of the present application;
[0064] Figure 4 is a structure block diagram of a resource scheduling device provided by an embodiment of the present application;
[0065] Figure 5 is a structure block diagram of a resource scheduling device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0066] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0067] It can be understood that various numerical numbers involved in the embodiments of the present application are only distinguished for convenience of description, and do not limit the scope of the present application. The size of the serial number of each process does not mean the execution order, and the execution order of each process should be determined according to its function and inherent logic.
[0068] In the embodiments of the present application, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. The terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes the elements inherent in such process, method, article or device. Without more limitation, the elements defined by the statement "include" do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0069] Please refer to Figure 1 , Figure 1 is a flowchart of a resource scheduling method provided by an embodiment of the present application. The resource scheduling method specifically includes:
[0070] S11: intercepting the Pods created in the Kubernetes cluster to obtain a plurality of to-be-scheduled Pods;
[0071] Specifically, S11: intercepting the Pods created in the Kubernetes cluster to obtain a plurality of to-be-scheduled Pods, including:
[0072] In a preset interception period, the Pods created in the Kubernetes cluster are intercepted; wherein the interception period is determined according to a Pod request rate and a Pod delay tolerance;
[0073] In a case where the number of intercepted Pods reaches a preset number threshold, the intercepted Pods are taken as to-be-scheduled Pods.
[0074] In the embodiment of the application, a short-term Pod request interception mechanism is introduced; wherein the interception period (which can also be described as an interception time period) can be determined according to specific business characteristics, such as a Pod request rate, a Pod delay tolerance (i.e. a tolerance of a Pod to a creation time delay), and other factors. The calculation of the interception period is not specifically limited in the embodiment of the application, for example, the interception period = (upper limit of concurrency Pod delay tolerance) / (Pod request rate per unit time of a single Pod).
[0075] When the number of intercepted Pods in the interception period reaches a certain number threshold, resource scheduling is triggered, and the Pods intercepted in the current interception period are uniformly scheduled.
[0076] Compared with the default initial resource scheduling mechanism of Kubernetes, in which the system determines the best Node node according to preselection and preferred strategies in the order of Pod request creation, resulting in uneven load distribution of nodes (also described as Node nodes or Nodes) in the cluster, and a small number of Pods placed on some nodes, thereby failing to fully utilize the cluster resources, the embodiment of the application performs batch and unified resource scheduling on the intercepted Pods in a specific time period, so as to schedule the intercepted Pods to multiple Node nodes at the same time, thereby realizing maximum utilization of resources and load balancing.
[0077] S12: According to the resource type and resource demand of the plurality of to-be-scheduled Pods and the resource information of the nodes in the Kubernetes cluster, a plurality of to-be-deployed nodes are screened out from the Kubernetes cluster;
[0078] For example, based on the resource type and resource demand of the plurality of to-be-scheduled Pods intercepted in step S11, in combination with the resource information of the nodes in the Kubernetes cluster, a plurality of nodes in a normal load state are screened out from the Kubernetes cluster for subsequent Pod deployment.
[0079] S13: determining a target node for each of the to-be-scheduled Pods from the plurality of to-be-deployed nodes according to the resource scheduling strategy based on the improved artificial bee colony algorithm, and deploying the plurality of to-be-scheduled Pods to the corresponding target nodes.
[0080] The embodiment of the present application allocates a to-be-deployed node for each of the trapped Pods as a target node of the Pod, and then simultaneously deploys the plurality of trapped Pods to the corresponding target nodes, so that balanced deployment of resources can be achieved, and the resource utilization and the load balancing degree of the entire cluster are improved.
[0081] In an optional embodiment, S12: screening a plurality of to-be-deployed nodes from the Kubernetes cluster according to the resource type and resource requirement of each of the to-be-scheduled Pods and the resource information of the nodes in the Kubernetes cluster, comprising:
[0082] According to the resource requirement of each of the to-be-scheduled Pods, the to-be-scheduled Pods are classified by type, and the resource type of each of the to-be-scheduled Pods is determined.
[0083] In the embodiment of the present application, it is considered that different resource requirements of applications in a Pod have a significant impact on the performance of a node in a cluster environment. For example, some tenants have a high demand for CPU resources, which may cause the CPU load of a node to increase; while other tenants focus more on memory resources, thereby increasing the memory load. It is also considered that when the CPU and bandwidth resources exceed the quota, the system can avoid overuse through soft limits, but once the memory and disk capacity exceed the quota, the kernel may throw an "Out-of-memory" error, causing the Pod to be forcibly terminated and rescheduled. The embodiment of the present application introduces a Pod type classification mechanism to classify the to-be-scheduled Pods into different resource types, including CPU load Pod nodes, memory load Pod nodes, and network bandwidth load Pod nodes, to represent the preference of applications in the to-be-scheduled Pods for CPU, memory, bandwidth, and disk capacity. Specifically, the CPU load Pod node represents that the application in the corresponding Pod has a higher demand for CPU resources than other resources, the memory load Pod node represents that the application in the corresponding Pod has a higher demand for memory resources than other resources, and the network bandwidth load Pod node represents that the application in the corresponding Pod has a higher demand for network bandwidth resources than other resources. By classifying the to-be-scheduled Pods by type, data support can be provided for subsequent load balancing of Node node scheduling.
[0084] obtain predicted load data of each node in a plurality of time units within a future set time according to historical load data of each node in the Kubernetes cluster, and select a plurality of candidate nodes from the nodes of the Kubernetes cluster according to the predicted load data of the nodes;
[0085] Specifically, the obtaining predicted load data of each node in a plurality of time units within a future set time according to historical load data of each node in the Kubernetes cluster, and selecting a plurality of candidate nodes from the nodes of the Kubernetes cluster according to the predicted load data of the nodes, comprises:
[0086] judging whether the CPU resource utilization rate of each node exceeds a preset utilization rate threshold;
[0087] if not, regarding the corresponding node as a candidate node;
[0088] if yes, obtaining CPU load data collected in a set time period of the corresponding node as historical load data;
[0089] performing CPU load prediction on the historical load data of the corresponding node by using a preset load prediction model to obtain predicted load data of the corresponding node in a plurality of time units within a future set time;
[0090] judging whether the predicted load data of the corresponding node in a plurality of time units within a future set time meets a preset load condition; the load condition comprises that there is at least a first set number of predicted load data exceeding a preset load threshold;
[0091] when the load condition is met, regarding the corresponding node as a candidate node.
[0092] The load prediction model is constructed based on a cubic exponential smoothing algorithm.
[0093] In the embodiment of the application, the historical load data of the nodes in the cluster is used to estimate the predicted load data of the nodes in a future set time, which is used to evaluate the load state of the nodes, so as to determine whether the nodes are suitable for deploying pods. Specifically, the historical load data of a node is collected at a preset collection interval (10 seconds). Since the collected historical load data is a time series and has nonlinear characteristics, in order to more accurately reflect the actual load state of the node and avoid misoperation caused by instantaneous high load value, a cubic exponential smoothing method is used to construct a load prediction model to calculate the short-term predicted load data of the node in a future set time, thereby effectively improving the accuracy and stability of load prediction and ensuring the stable operation of the pod in the cluster.
[0094] The prediction results of the triple exponential smoothing method are like curves, which show both long-term trends and seasonal fluctuations. The triple exponential smoothing method combines historical data, previous predictions, and smoothing coefficients to derive the prediction results. The calculation process of the triple exponential smoothing method is as follows:
[0095] (1);
[0096] (2);
[0097] (3);
[0098] where, denotes the first exponential smoothing value of the t period; denotes the second exponential smoothing value of the t period; denotes the third exponential smoothing value of the t period; denotes the smoothing coefficient, which is between 0 and 1; denotes the actual observation value of the t period.
[0099] The calculation process of the prediction results of the future T period is as follows:
[0100] (4);
[0101] where, denotes the prediction of the future t+T period based on the data of the t period, t can represent the t time, and T can represent the data collection interval. 、 、 denotes the prediction parameter of the t period, which is used to describe the level, trend slope, and trend curvature of the time series in the t period.
[0102] (5).
[0103] In a Kubernetes cluster, tenants write resource requirements such as CPU, memory, network bandwidth, and disk space in the yaml file of the Pod. According to the resource requirements recorded in the resource configuration of the yaml file, the resource consumption of the Pod on the corresponding node after deployment can be calculated.
[0104] Taking CPU resource utilization as an example, the process of node load data prediction is as follows:
[0105] (1) When the CPU resource utilization of a node exceeds the preset utilization threshold, the prediction mechanism for the future CPU utilization of the node is started.
[0106] (2) retrieve the CPU load data of the node collected in the last q times from the database as the historical load data, and predict the CPU load data of the future p time units by using the above-mentioned three exponential smoothing algorithms as the predicted load data.
[0107] (3) analyze the p predicted CPU load data. If the first set number (such as Nk or more than Nk) of data points in the P predicted CPU load data exceeds the set load threshold, the node is determined to be in a high load state; otherwise, the node is considered to be in a normal load state.
[0108] The node determined to be in the normal load state is used as a candidate node for participating in Pod deployment.
[0109] According to the resource types of the plurality of to-be-scheduled Pods and the resource information of the plurality of candidate nodes, a plurality of to-be-deployed nodes are screened from the plurality of candidate nodes.
[0110] Specifically, the plurality of to-be-deployed nodes are screened from the plurality of candidate nodes according to the resource types of the plurality of to-be-scheduled Pods and the resource information of the plurality of candidate nodes, comprising:
[0111] According to the resource type of each to-be-scheduled Pod, the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth and disk space is determined;
[0112] According to the resource information of each candidate node, the total resource amount and the used resource amount of each candidate node on CPU, memory, network bandwidth and disk space, and the requested resource amount of the to-be-scheduled Pod on CPU, memory, network bandwidth and disk space are determined, and the resource usage and the remaining resource amount of each candidate node on CPU, memory, network bandwidth and disk space after scheduling the Pod are determined according to the total resource amount, the used resource amount and the requested resource amount;
[0113] According to the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth and disk space, the resource usage, the remaining resource amount and the disk read-write speed of each candidate node on CPU, memory, network bandwidth and disk space, the performance score of each candidate node is calculated;
[0114] According to the performance score of each candidate node, a plurality of to-be-deployed nodes are screened from the plurality of candidate nodes.
[0115] In the embodiment of the application, the total resource amounts of CPU, memory, disk space and network bandwidth of the node N i are respectively , , 、 , the disk read-write rate includes a disk read IO rate and a disk write IO rate , the used resource amount is respectively 、 、 、 , which is recorded in the resource information of the candidate node.
[0116] The requested resource amount of the current to-be-scheduled Pod in CPU, memory, disk space and network bandwidth is respectively 、 、 、 , the weight of the to-be-scheduled Pod in CPU, memory, network bandwidth and disk space is respectively 、 、 、 , wherein the weight is divided according to the resource type of the to-be-scheduled Pod. For example + + + =1, if the resource type of the to-be-scheduled Pod is a CPU type load Pod node, the value of is set to be the maximum, if it is a memory type load Pod node, the value of is set to be the maximum, and so on. The specific weight setting ratio is not limited in the embodiment of the present application, for example, the weight of the maximum is 4, and the weight of the others is 2.
[0117] When the to-be-scheduled Pod is scheduled to the current candidate node i, the resource usage amount of the current candidate node i in CPU, memory, disk space and network bandwidth is respectively 、 、 、 , and the specific calculation formula is as follows:
[0118] = + (6);
[0119] = + (7);
[0120] = + (8);
[0121] = + (9);
[0122] When the pod to be scheduled is scheduled to the current candidate node i, the remaining resource amounts of CPU, memory, disk space and network bandwidth of the current candidate node i are respectively 、 、 、 The specific calculation formulas are as follows:
[0123] = - (10);
[0124] = - (11);
[0125] = - (12);
[0126] = - (13);
[0127] The performance score S of the current candidate node i is i Specifically as follows:
[0128] (14);
[0129] In the evaluation of node performance, the embodiment of the application considers four resources: CPU, memory, disk space and network bandwidth; first, the percentages of the remaining resources of the candidate nodes in the total amounts of the resources are calculated, and the importance (weight) of each resource is also considered; the values obtained by dividing the percentages by the weights are related to the performance score of the node, and the greater the value, the higher the performance score. Subsequently, the candidate nodes with performance scores exceeding a set score threshold can be selected as the nodes to be deployed. Compared with the traditional single-dimensional evaluation (such as only considering CPU usage), which can lead to misjudgment (for example, a node with idle CPU but exhausted memory is mistakenly selected), the embodiment of the application simultaneously considers four types of core resources, and can more completely depict the actual load capacity of the node. By introducing the resource weight mechanism, the importance of different resources can be adjusted according to the business characteristics, unreasonable scheduling of “one-size-fits-all” can be avoided, and diversified deployment scenarios can be adapted.
[0130] Further, the balance of the four resources can be considered. If the usage of the four resources of a node in the scheduling cluster is similar, it means that the node is in good condition and works well. For example, for a candidate node with a performance score exceeding a set score threshold, the percentage of the resource usage of CPU, memory, disk space, and network bandwidth of the candidate node after the to-be-scheduled pod is scheduled to the candidate node to the total resource amount of each resource can be calculated. The percentage of CPU, memory, disk space, and network bandwidth is compared, and the candidate node with a deviation between the percentages of CPU, memory, disk space, and network bandwidth within a certain range is selected as the to-be-deployed node.
[0131] In an optional embodiment, S13: determining a target node of each to-be-scheduled pod from a plurality of to-be-deployed nodes according to a resource scheduling strategy based on an improved artificial bee colony algorithm, comprising:
[0132] According to a plurality of to-be-scheduled pods, a bee colony is initialized, and a search space is initialized according to a plurality of to-be-deployed nodes;
[0133] In the employed bee search stage, an improved ant colony algorithm is used to perform global optimization on the search space to determine a first search area;
[0134] In the onlooker bee selection stage, a preset adaptive random rule distribution is used to update the position of the first search area to determine a second search area;
[0135] In the scout bee search stage, the fitness value of each position in the second search area is calculated, and the optimal position of the bee colony is determined according to the fitness value of each position in the second search area; wherein each position corresponds to a to-be-deployed node;
[0136] The optimal position of the bee colony is iteratively updated to determine the most suitable position of the bee colony;
[0137] According to the to-be-deployed node indicated by the most suitable position and the mapping relationship between the to-be-deployed node and a plurality of to-be-scheduled pods indicated by the bee colony, the target node corresponding to a plurality of to-be-scheduled pods is determined.
[0138] For example, assuming that there are n to-be-scheduled pods currently trapped in the Kubermetes cluster and m to-be-deployed nodes are screened out, the node search process of the resource scheduling strategy based on the improved artificial bee colony algorithm (referred to as AABCK strategy) is described as follows: Figure 2
[0139] Step1: initialization of the parameters of the bee colony: initialization of the population size: n bee colonies, initialization of an m-dimensional search space, each position in the m-dimensional search space indicating a to-be-deployed node; the bee colony searches for an optimal solution in the m-dimensional search space, and the optimal solution is the optimal position (i.e., the optimal to-be-deployed node) of the to-be-deployed Pod; the number of iterations , the maximum number of searches limit, and the initial boundary conditions.
[0140] According to the resource requirements in the to-be-scheduled Pods, the to-be-scheduled Pods are classified into employed bees, onlookers, and scouts, and form corresponding bee colonies, for example, to-be-scheduled Pods with high resource requirements are classified as employed bees, to-be-scheduled Pods with medium resource requirements are classified as onlookers, and to-be-scheduled Pods with low resource requirements are classified as scouts; it is assumed that the number of bee colonies of the initialized employed bees, onlookers, and scouts is x, m feasible solutions are randomly generated, the fitness function values fit are calculated, and the solutions with the top half fitness function values are taken as the initial feasible solutions; the feasible solution of the kth bee colony is represented as Pos k = (Pos k1 , Pos k2 ,..., Pos kj ,..., Pos km ); k [1, x], x , Pos kj represents the node k to which the jth to-be-scheduled Pod is scheduled and deployed, and its value interval is [1, m].
[0141] Step 2: AABCK strategy in the search phase of the employed bees, the global optimal position is selected from the m-dimensional search space (m to-be-deployed nodes) based on the improved ant colony algorithm, a best search area (i.e., the first search area described above) is formed for Pod scheduling, and the specific formula is as follows:
[0142] P kj,new = P best + (P mean - Pos kj ) (15);
[0143] P t kj,new = P kj,new + P kj,new (n) (16);
[0144] wherein P kj,new is the new node of the jth to-be-scheduled Pod in the kth bee colony, P best is the optimal position of the jth to-be-scheduled Pod on the node calculated by the fitness function in the last iteration, is a parameter for controlling the position change (also referred to as a search step), the value of which is between 1 and 2; is a random number, the value of which is between 0 and 1; P mean represents the average value of the positions in the k bee swarms, which represents an abstract representation of the "average state" of all the information of the previous points, such as the resources, performance, and other characteristics of all the to-be-deployed nodes, and embodies the overall average level of the cluster nodes; P t kj,new is the new node of the to-be-deployed Pod after the adaptive random rule distribution, (n) represents the adaptive random rule distribution.
[0145] Step 3: In the observation bee search stage, the AABCK strategy selects a following scout bee according to the observation peak, uses the adaptive random rule distribution for position updating, selects a suitable node to deploy the to-be-scheduled Pod in the selected best search area (i.e., the first search area described above), and constantly moves to different places within the best search area (i.e., the first search area described above). The specific formula is as follows:
[0146] P t kj,news =P t kj,new +x(j) (P t kj,new -P mean )+y(j) (P t kj,new - (P t kj+1,new -P mean )(17).
[0147] wherein P t kj,news represents the position of the observation bee selected by the observation bee, P t kj,new is the new node of the jth to-be-scheduled Pod after the start of the search, and x(j), y(j) represent the position random numbers of the observation bee in the polar coordinates, both of which take values of (-1, 1); P t kj+1,new represents the new node of the j+1th to-be-scheduled Pod after the search of the scout bee.
[0148] wherein the observation bee selects a scout bee according to a relevant probability value and follows the same, and the probability calculation method is ; wherein, is the fitness value of the new node of the jth to-be-scheduled Pod.
[0149] Step 4: In the scout bee search phase, if the number of times a certain position is repeatedly searched (e.g., the cumulative number of searches by hired bees and observer bees) exceeds the preset maximum search limit, the scout bee searches for a better position across regions from the best position in the best search region (i.e., the position updated in the observer bee search phase above, forming the second search region) through random perturbation. This prevents the algorithm from getting trapped in local optima and obtains the most suitable node for the Pod to be scheduled. The specific formula is as follows:
[0150] P t kj,newss =rand P t kj,news + (18);
[0151] Among them, P t kj,newss This indicates the most suitable node (i.e., the most suitable position) for scheduling the j-th Pod to be scheduled after the scout bee searches. This represents the random disturbance term in polar coordinates, with values of (-1, 1).
[0152] Step 5: Through manual bee colony selection and iteration, continuously update the optimal position of the bee colony until the set maximum number of iterations is reached. If precision is required, the optimal position is output, the target node for each Pod to be scheduled is selected, and the scheduler schedules each Pod to be scheduled to the corresponding target node simultaneously. Figure 3 As shown.
[0153] For example, the Pod to be scheduled is { , , … }, where n represents the total number of Pods, and the target nodes to be filtered are { , , … The mapping relationship between Pods and Nodes is represented by matrix X, as follows:
[0154] (19);
[0155] Wherein, m represents the total number of Node nodes, and n represents the total number of Pods; the element in the matrix X represents whether a certain to-be-scheduled Pod is scheduled to a certain Node node, the element = 1 in the matrix X represents that the corresponding to-be-scheduled Pod is scheduled to the corresponding Node node (based on the determination of the target node) to run, and the element = 0 in the matrix X represents that the corresponding to-be-scheduled Pod is not scheduled to the corresponding Node node to run. For example, X12 = 1 means that the to-be-scheduled Pod 1 is scheduled to the Node node 2 to run.
[0156] It can be understood that based on the target nodes of the to-be-scheduled Pods obtained above, a matrix representing the mapping relationship between the scheduled Pods and the Node nodes in the cluster can be established, for example, the corresponding element value of the target node of the to-be-scheduled Pod is set to 1, and the corresponding element value of other nodes to which the to-be-scheduled Pod does not need to be scheduled is set to 0.
[0157] Specifically, the improved ant colony algorithm is used to perform global optimization on the search space to determine a first search region, including:
[0158] Initialize the ant colony parameters, and initialize the path pheromone concentration to a preset concentration value;
[0159] According to the path pheromone concentration and a preset heuristic function, the probability value of each to-be-scheduled Pod being scheduled to any to-be-deployed node in the search space is calculated.
[0160] Specifically, according to the path pheromone concentration and a preset heuristic function, the probability value of each to-be-scheduled Pod being scheduled to any to-be-deployed node in the search space is calculated, including:
[0161] According to the utilization of the CPU, the memory, the network bandwidth, and the disk space of the corresponding to-be-deployed node when each to-be-scheduled Pod is scheduled to any to-be-deployed node, the average utilization of the CPU, the memory, the network bandwidth, and the disk space of all to-be-deployed nodes in the search space, and the heuristic function, the expected degree of each to-be-scheduled Pod being scheduled to any to-be-deployed node is calculated.
[0162] According to the expected degree of each to-be-scheduled Pod being scheduled to any to-be-deployed node and the path pheromone concentration, the probability value of each to-be-scheduled Pod being scheduled to any to-be-deployed node is calculated.
[0163] According to the probability value of each to-be-scheduled Pod being scheduled to any to-be-deployed node in the search space, the target scheduling node of each to-be-scheduled Pod is determined.
[0164] According to the load balancing degree of the target scheduling node determined at present, the path pheromone concentration is updated;
[0165] Specifically, the updating of the path pheromone concentration according to the load balancing degree of the target scheduling node determined at present comprises:
[0166] According to the utilization of CPU, memory, network bandwidth and disk space of the corresponding target scheduling node when each of the to-be-scheduled Pods is scheduled to the corresponding target scheduling node, and the average utilization of CPU, memory, network bandwidth and disk space of all the target scheduling nodes, the load balancing degree of each of the to-be-scheduled Pods scheduled to the corresponding target scheduling node is calculated as the load balancing degree of the ant scheduling each of the to-be-scheduled Pods;
[0167] Each of the ants is sorted according to the load balancing degree of each of the ants, and the ranking of each of the ants is determined;
[0168] According to the load balancing degree and the ranking of each of the ants, the increment of the path pheromone concentration is calculated;
[0169] According to the path pheromone concentration and the increment thereof, the path pheromone concentration is updated.
[0170] According to the updated path pheromone concentration, the target scheduling node of each of the to-be-scheduled Pods is determined again until the preset iteration termination condition is met, and the final target scheduling node of each of the to-be-scheduled Pods is determined as the first search region.
[0171] In the embodiment of the application, the specific process of globally optimizing the search space by using the improved ant colony algorithm is as follows:
[0172] Step 1: Ant colony parameter initialization, including setting the path pheromone concentration and the importance weight of the heuristic function in the scheduling decision Determine the constant Q in the calculation of the heuristic function, set the volatilization coefficient of the pheromone Determine the coefficient for calculating the pheromone release amount Initialize the number of ants w and the maximum number of iterations max of the ant colony algorithm.
[0173] Step 2: Path pheromone concentration initialization: assign the same path pheromone concentration, such as 1, to all possible paths or nodes.
[0174] In order to avoid premature convergence of the ant colony algorithm to a local optimal solution in the search process, and ensure that the algorithm can more fairly explore various possible optimal resource scheduling modes in the initial stage, the initial path pheromone concentration is set to a uniform value, so that when the ants start searching, the attractiveness of each node to the Pod is equal. The initial path pheromone concentration .
[0175] Step 3: Node selection: the path pheromone concentration and the heuristic function are used to calculate the probability of each to-be-scheduled Pod being scheduled to a specific node. The roulette wheel selection method (also known as the proportional selection method) is used to determine the scheduling target of each to-be-scheduled Pod based on the calculated probability.
[0176] Specifically, the path explored by each ant constitutes a potential solution to resource scheduling. In each iteration, the ant will select the most suitable node for each to-be-scheduled Pod one by one. When the scheduling tasks of all to-be-scheduled Pods are completed by the same ant, it means that the attempt of resource scheduling has ended. When the ant selects a suitable node to allocate to a to-be-scheduled Pod, it will use the roulette wheel strategy to make a decision based on the probability calculated by the path pheromone concentration and a heuristic function. Specifically, the probability of the hth ant selecting the ith to-be-deployed node for the jth to-be-scheduled Pod in the tth iteration is calculated as follows:
[0177] (20);
[0178] wherein, represents the path pheromone concentration of the jth to-be-scheduled Pod selecting the ith to-be-deployed node in the tth iteration, reflecting the frequency of selection of a certain node, thereby affecting the subsequent tendency of the ant to select the node. represents the expected degree of the jth to-be-scheduled Pod selecting the ith to-be-deployed node in the tth iteration, which is usually calculated based on a heuristic function. and are important degree parameters of the path pheromone concentration and the expected degree, respectively, which determine the degree of dependence of the ant on the two when selecting a node. represents the set of Pods that have not been scheduled by the ant h, i.e., the list of Pods that have not been allocated a node by the ant k. When the list contains all to-be-scheduled Pods, it means that the ant k has completed all resource scheduling tasks in the current iteration. At this time, the most suitable node combination found by the ant k for each to-be-scheduled Pod constitutes a potential optimal solution discovered by the ant k in this round of iteration.
[0179] The heuristic function is an index for measuring the expected effect of scheduling the pod to a certain node by the ant, which is directly related to the optimization performance of the ant colony algorithm. The heuristic function not only determines the ability of the algorithm to search for an optimal solution, but also reflects the degree of emphasis of the ant colony algorithm on different optimization objectives. Embodiments of the present application focus on improving the load balancing effect in the cluster, that is, when the ant h decides to select the i th to-be-deployed node for the j th to-be-scheduled pod, if this can significantly improve the load balancing degree of the cluster, the value of the corresponding heuristic function should also be higher. Based on this, embodiments of the present application propose an improved heuristic function to calculate the expected degree of the j th to-be-scheduled pod on the i th to-be-deployed node, as follows:
[0180] (21);
[0181] (22); (23);
[0182] (24);
[0183] (25);
[0184] wherein cpu m represents the CPU utilization of the node m if a to-be-scheduled pod is scheduled to the node m; and represents the average CPU utilization of the nodes in the entire cluster after the to-be-scheduled pod is scheduled; and cpuStd represents the standard deviation of the CPU utilization of all nodes in the entire cluster after resource scheduling. m represents the memory utilization of the node m if a to-be-scheduled pod is scheduled to the node m; and represents the average memory utilization of the nodes in the entire cluster after the to-be-scheduled pod is scheduled; and memStd represents the standard deviation of the network utilization of all nodes in the entire cluster after resource scheduling. m represents the network bandwidth utilization of the node m if a to-be-scheduled pod is scheduled to the node m; and represents the average network bandwidth utilization of the nodes in the entire cluster after the to-be-scheduled pod is scheduled; and netStd represents the standard deviation of the network bandwidth utilization of all nodes in the entire cluster after resource scheduling. m represents the disk utilization of the node m if a to-be-scheduled pod is scheduled to the node m; and represents the average disk utilization of the nodes in the entire cluster after the to-be-scheduled pod is scheduled; and diskStd represents the standard deviation of the disk utilization of all nodes in the entire cluster after resource scheduling. As a heuristic function, it integrates the above performance indicators and adjusts the weight through a constant Q to ensure that the decision of resource scheduling can comprehensively consider the overall performance and load balancing of the cluster.
[0185] Step 4: pheromone concentration update: according to the load balancing degree calculated after each ant completes the scheduling and its ranking among all ants, the increment of pheromone concentration of the ant is determined.
[0186] In the ant colony optimization algorithm, once an ant completes the resource scheduling task for all Pods, it will leave a certain amount of pheromone as a mark on the path it has passed. However, pheromone is not eternal, it will gradually dissipate over time. In the subsequent iteration, the ant will comprehensively consider the pheromone concentration on the current path and the information of the heuristic function to re-plan its moving path. In the embodiment of the present application, the increment of pheromone produced by the ant after completing the Pod scheduling task is not fixed, but closely related to the load balancing degree of the overall resources of the cluster. If the ant can achieve higher load balancing in the scheduling process, the pheromone concentration it releases will also increase accordingly, and through this mechanism, the ant is encouraged to choose scheduling strategies that can achieve higher load balancing.
[0187] Based on this, the embodiment of the present application introduces a reward and punishment mechanism to guide the search process of the ant colony. After each iteration, the load balancing degrees calculated by the scheduling strategies of all ants are sorted. Ants with higher load balancing degrees will get higher pheromone concentration rewards, while ants with lower load balancing degrees will get lower pheromone concentration, thereby accelerating the convergence speed of the algorithm. By giving higher pheromone concentration to the optimal scheduling strategy (i.e. the strategy of scheduling Pods to nodes), the probability of subsequent ants choosing these scheduling strategies can be increased, so as to find the optimal resource scheduling scheme faster. Wherein, the specific calculation method of the load balancing degree lb is as follows:
[0188] (26);
[0189] The embodiment of the application calculates the release amount (i.e. increment) of path pheromone concentration based on a reward and punishment strategy of load balancing degree. The reward and punishment strategy of load balancing degree adopts a linearly decreasing manner to ensure that the ants with higher load balancing degree ranking can obtain higher pheromone concentration reward. Specifically, the ant with the highest load balancing degree ranking will release complete pheromone concentration as a recognition of its efficient scheduling strategy; the ant with the lowest load balancing degree ranking will not release any pheromone concentration because it fails to achieve ideal load balancing in the resource scheduling process; and the ants with the middle load balancing degree ranking will release a value between complete pheromone concentration and zero according to their positions in the load balancing degree ranking, for example, half of the complete pheromone concentration. The reward and punishment strategy of pheromone concentration and the specific pheromone concentration updating manner are as follows:
[0190] (27);
[0191] (28);
[0192] wherein the variable represents the value of the load balancing degree ranking of the hth ant after one iteration, the value range of the variable is from 1 to w; w is the total number of ants; a fixed coefficient represents the coefficient for calculating the released pheromone concentration; represents the coefficient for calculating the pheromone evaporation. Through the above reward and punishment strategy, the ant colony can be guided to evolve towards a better resource scheduling scheme, and the speed of converging to the optimal solution can be accelerated.
[0193] Step 5: Iteration count: the iteration number is increased by 1.
[0194] Step 6: Termination condition judgment: check whether the termination condition (such as reaching the maximum iteration number or finding an optimal solution meeting the accuracy requirement) is met. If the condition is met, stop the iteration and output the optimal resource scheduling scheme, i.e. the above-mentioned best search region (first search region); otherwise, return to Step 3 to continue the iteration search.
[0195] It can be understood that in the employed bee search stage, the bee colony is equivalent to the ant colony, the employed bees in the bee colony are equivalent to the ants in the ant colony, and the bee colony performs the above-mentioned improved ant colony algorithm to search for the global optimization of the to-be-deployed nodes, which can improve the search efficiency and obtain a better optimal solution.
[0196] Specifically, the position of the first search region is updated by adopting a preset adaptive random rule distribution to determine a second search region, which includes:
[0197] By taking the standard Gaussian distribution and the Cauchy distribution as the limiting distributions of continuous probability distributions under a given degree of freedom, an adaptive random regular distribution is obtained;
[0198] The adaptive random rule distribution is used to update the position of the first search region to determine the second search region.
[0199] The t-distribution is a probability distribution characterized by symmetry and a unimodal nature, with its peak at 0. The specific shape of the t-distribution is determined by its degrees of freedom. The decision, when When the value of decreases, the curve of the t-distribution becomes flatter and broader; conversely, when , the curve of the t-distribution becomes flatter and broader. As the value of gradually increases, the t-distribution curve will gradually approach the standard normal distribution curve, that is, when ... As the t-distribution approaches infinity, it becomes extremely close to the standard Gaussian distribution N(0, 1). Specifically, when the degrees of freedom... When the degree of freedom is exactly 1, the shape of the t-distribution is completely identical to the Cauchy distribution C(0,1). Based on this unique property, this embodiment of the invention treats the standard Gaussian distribution and the Cauchy distribution as limiting distributions of the t-distribution under specific degrees of freedom conditions, and constructs an adaptive random regular distribution, that is, when the degree of freedom is exactly 1... As the number of degrees of freedom approaches infinity, the adaptive random regular distribution follows a standard Gaussian distribution N(0,1). When the degree of freedom is 1, the adaptive random regular distribution is a Cauchy distribution C(0,1). For other values, the adaptive random regular distribution follows a t-distribution. In the artificial bee colony algorithm, the adaptive random regular distribution is used to determine the position P obtained after the peak search. t kj,news Perform a location update.
[0200] P t kj,news(更新后) =rand P t kj,news(更新前) +P t kj,news(更新前) (29);
[0201] Where rand is a random number, and P is a random number whose value is in the range (0, 1]. t kj,news(更新后) It is the position after the adaptive random regular distribution has mutated, P t kj,news(更新前) It is the position before the adaptive random regular distribution mutates. Describing the degrees of freedom as Adaptive random regular distribution, It is the number of iterations. , representing the minimum and maximum values of the adaptive random rule distribution.
[0202] the position P after the adaptive random rule distribution is mutated subsequently t kj,news(更新后) The final position obtained by searching the observation peak is used as the final second search region for subsequent investigation of the bee search.
[0203] The embodiment of the application introduces random rule distribution disturbance P t kj,news(更新前) to enhance the flexibility of the bee in the selection of the search space. When the search process falls into a local optimum, the disturbance mechanism can guide the search to jump out of the local limitation, effectively improve the accuracy and efficiency of the search, and accelerate the convergence speed. The adaptive random rule distribution mutation can use the iteration number as a degree of freedom parameter, and realize the dynamic adjustment of the t distribution. In the early stage, due to the small iteration number, the t distribution mutation exhibits the characteristics of the Cauchy distribution, which can improve the global search ability. With the increase of the iteration number, the t distribution mutation gradually tends to be a Gaussian distribution, which can exhibit more fine development ability in the local area, so as to realize effective exploration in the global range and in-depth development in the local area, and realize the combination of global and local advantages. The mutation operator of the adaptive random rule distribution combines the Gaussian operator and the Cauchy operator, which can further enhance the robustness and comprehensiveness of the search.
[0204] Referring to Figure 4 , Figure 4 is a structural block diagram of a resource scheduling device provided by the embodiment of the application, and the resource scheduling device comprises:
[0205] A Pod interception module 11 is configured to intercept Pods created in a Kubernetes cluster to obtain a plurality of to-be-scheduled Pods.
[0206] A node screening module 12 is configured to screen a plurality of to-be-deployed nodes from the Kubernetes cluster according to resource types and resource requirements of the plurality of to-be-scheduled Pods and resource information of nodes in the Kubernetes cluster.
[0207] A Pod scheduling module 13 is configured to determine target nodes of each of the to-be-scheduled Pods from the plurality of to-be-deployed nodes according to a resource scheduling strategy based on an improved artificial bee colony algorithm, and deploy the plurality of to-be-scheduled Pods to the corresponding target nodes.
[0208] In an optional embodiment, the Pod interception module 11 comprises:
[0209] A trapping unit is configured to trap the created Pods in the Kubernetes cluster within a preset trapping period, wherein the trapping period is determined according to a Pod request rate and a Pod delay tolerance.
[0210] A to-be-scheduled Pod determination unit is configured to determine the trapped Pods as to-be-scheduled Pods when the number of the trapped Pods reaches a preset number threshold.
[0211] In an optional embodiment, the node screening module 12 comprises:
[0212] A type division unit is configured to divide each of the to-be-scheduled Pods into a resource type according to a resource requirement of each of the to-be-scheduled Pods.
[0213] A load prediction unit is configured to obtain predicted load data of each of the nodes in a plurality of time units within a future set time according to historical load data of each of the nodes in the Kubernetes cluster, and screen a plurality of candidate nodes from the nodes in the Kubernetes cluster according to the predicted load data of the nodes.
[0214] A node screening unit is configured to screen a plurality of to-be-deployed nodes from the plurality of candidate nodes according to the resource types of the plurality of to-be-scheduled Pods and resource information of the plurality of candidate nodes.
[0215] In an optional embodiment, the load prediction unit comprises:
[0216] A first judgment subunit is configured to judge whether a CPU resource utilization rate of each of the nodes exceeds a preset utilization rate threshold.
[0217] A first candidate node confirmation subunit is configured to regard the corresponding node as a candidate node if the judgment result is negative.
[0218] A load data acquisition subunit is configured to acquire CPU load data collected in a set time period of the corresponding node as historical load data if the judgment result is positive.
[0219] A load data prediction subunit is configured to perform CPU load prediction on the historical load data of the corresponding node by using a preset load prediction model to obtain predicted load data of the corresponding node in a plurality of time units within a future set time.
[0220] A second judgment subunit is configured to judge whether the predicted load data of the corresponding node in the plurality of time units within the future set time meets a preset load condition, wherein the load condition comprises that there is at least a first set number of predicted load data exceeding a preset load threshold.
[0221] The second candidate node confirming subunit is configured to regard a corresponding node as a candidate node when the load condition is satisfied.
[0222] In an optional embodiment, the node screening unit comprises:
[0223] The subunit is configured to determine the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth, and disk space according to the resource type of each to-be-scheduled Pod.
[0224] The resource determining subunit is configured to determine the total resource amount and the used resource amount of each candidate node on CPU, memory, network bandwidth, and disk space according to the resource information of each candidate node, determine the requested resource amount of each to-be-scheduled Pod on CPU, memory, network bandwidth, and disk space, and determine the resource usage and the remaining resource of each candidate node on CPU, memory, network bandwidth, and disk space after scheduling the Pod according to the total resource amount, the used resource amount, and the requested resource amount.
[0225] The performance evaluating subunit is configured to calculate the performance score of each candidate node according to the weight of each to-be-scheduled Pod on CPU, memory, network bandwidth, and disk space, the resource usage, the remaining resource, and the disk read-write speed of each candidate node on CPU, memory, network bandwidth, and disk space.
[0226] The to-be-deployed node screening subunit is configured to screen a plurality of to-be-deployed nodes from the plurality of candidate nodes according to the performance score of each candidate node.
[0227] In an optional embodiment, the Pod scheduling module 13 comprises:
[0228] The initializing unit is configured to initialize a bee swarm according to the plurality of to-be-scheduled Pods and initialize a search space according to the plurality of to-be-deployed nodes.
[0229] The first searching unit is configured to perform global optimization on the search space by using an improved ant colony algorithm in a scout bee searching stage to determine a first search region.
[0230] The second searching unit is configured to perform position updating on the first search region by using a preset adaptive random rule distribution in an observer bee selecting stage to determine a second search region.
[0231] The third searching unit is configured to calculate the fitness value of each position in the second search region and determine the optimal position of the bee swarm according to the fitness value of each position in the second search region; each position corresponds to a to-be-deployed node.
[0232] An iterative updating unit is configured to iteratively update the optimal position of the swarm to determine a most suitable position of the swarm.
[0233] A target node determining unit is configured to determine target nodes corresponding to the plurality of to-be-scheduled Pods according to the to-be-deployed nodes indicated by the most suitable position and the mapping relationship between the to-be-deployed nodes and the plurality of to-be-scheduled Pods indicated by the swarm.
[0234] In an optional embodiment, the first searching unit comprises:
[0235] A parameter initializing subunit is configured to initialize ant colony parameters and initialize a path pheromone concentration to a preset concentration value.
[0236] A probability calculating subunit is configured to calculate a probability value of scheduling each to-be-scheduled Pod to any to-be-deployed node in the search space according to the path pheromone concentration and a preset heuristic function.
[0237] A first node determining subunit is configured to determine a target scheduling node of each to-be-scheduled Pod according to the probability value of scheduling each to-be-scheduled Pod to any to-be-deployed node in the search space.
[0238] A pheromone concentration updating subunit is configured to update the path pheromone concentration according to a load balancing degree of the currently determined target scheduling node.
[0239] A second node determining subunit is configured to redetermine the target scheduling node of each to-be-scheduled Pod according to the updated path pheromone concentration until a preset iteration termination condition is met, to determine a final target scheduling node of each to-be-scheduled Pod as the first search region.
[0240] In an optional embodiment, the probability calculating subunit comprises:
[0241] An expectation degree calculating subunit is configured to calculate an expectation degree of scheduling each to-be-scheduled Pod to any to-be-deployed node by the heuristic function according to the utilization of CPU, memory, network bandwidth and disk space of the corresponding to-be-deployed node when each to-be-scheduled Pod is scheduled to any to-be-deployed node, and the average utilization of CPU, memory, network bandwidth and disk space of all to-be-deployed nodes in the search space.
[0242] A node probability calculating subunit is configured to calculate the probability value of scheduling each to-be-scheduled Pod to any to-be-deployed node according to the expectation degree of scheduling each to-be-scheduled Pod to any to-be-deployed node and the path pheromone concentration.
[0243] In an alternative embodiment, the pheromone concentration updating subunit comprises:
[0244] a load balancing degree calculation subunit configured to calculate a load balancing degree of each of the to-be-scheduled Pods when scheduled to a corresponding target scheduling node, as a load balancing degree of an ant scheduling each of the to-be-scheduled Pods, according to utilization of CPU, memory, network bandwidth and disk space of the corresponding target scheduling node when each of the to-be-scheduled Pods is scheduled to the corresponding target scheduling node, and average utilization of CPU, memory, network bandwidth and disk space of all the target scheduling nodes;
[0245] a ranking subunit configured to rank each of the ants according to the load balancing degree of each of the ants, and determine a ranking of each of the ants;
[0246] a concentration increment calculation subunit configured to calculate an increment of the path pheromone concentration according to the load balancing degree and the ranking of each of the ants;
[0247] a path pheromone concentration updating subunit configured to update the path pheromone concentration according to the path pheromone concentration and the increment thereof.
[0248] In an alternative embodiment, the second searching subunit comprises:
[0249] a random regular distribution construction subunit configured to obtain an adaptive random regular distribution by taking a standard Gaussian distribution and a Cauchy distribution as limit distributions of continuous probability distributions under a condition of a set degree of freedom;
[0250] a position updating subunit configured to perform position updating on the first search region by using the adaptive random regular distribution, and determine a second search region.
[0251] It should be noted that the working processes of the various modules in the resource scheduling apparatus according to the embodiments of the present application can refer to the working processes of the resource scheduling methods according to the above embodiments, and the technical effects achieved are the same as those of the resource scheduling methods according to the above embodiments, which will not be described herein again.
[0252] Referring to Figure 5 , Figure 5 is a structural block diagram of a resource scheduling device provided by the embodiments of the present application. The resource scheduling device comprises a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. The processor 21 implements the steps in each of the above resource scheduling method embodiments when executing the computer program, such as steps S11-S13.
[0253] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the resource scheduling device.
[0254] The resource scheduling device can include, but is not limited to, the processor 21, the memory 22. Those skilled in the art can understand that the schematic diagram is only an example of the resource scheduling device, and does not constitute a limitation on the resource scheduling device, and can include more or fewer components than the diagram, or combine certain components, or different components, for example, the resource scheduling device can also include an input / output device, a network access device, a bus, etc.
[0255] The processor 21 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), ready programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The processor 21 is the control center of the resource scheduling device, which connects all parts of the resource scheduling device through various interfaces and lines.
[0256] The memory 22 can be used to store the computer programs and / or modules, and the processor 21 realizes various functions of the resource scheduling device by running or executing the computer programs and / or modules stored in the memory 22, and calling the data stored in the memory 22. The memory 22 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), and the like; and the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), and the like. In addition, the memory 22 can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.
[0257] When the modules / units integrated in the resource scheduling device are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. When the processor 21 executes the computer program, the steps of the above-mentioned various method embodiments can be realized. The computer program includes computer program code, which can be in the form of source code, object code, an executable file, or some intermediate form. The computer readable medium can include any entity or device capable of carrying the computer program code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0258] It should be noted that the apparatus embodiments described above are merely illustrative, and the units described as separate units can or can not be physically separate, and the units shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. In addition, the connection relationship between the modules in the apparatus embodiment provided by the present application indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement it without creative labor.
[0259] The above is the preferred embodiment of the present application. It should be noted that those skilled in the art can make various improvements and refinements without departing from the principles of the present application, and these improvements and refinements are also considered within the scope of protection of the present application.
Claims
1. A resource scheduling method, characterized in that, include: By intercepting Pods created in the Kubernetes cluster, multiple Pods are obtained that are to be scheduled. Based on the resource types and resource requirements of the multiple Pods to be scheduled, and the resource information of the nodes in the Kubernetes cluster, multiple nodes to be deployed are selected from the Kubernetes cluster. According to the resource scheduling strategy based on the improved artificial bee colony algorithm, the target node of each Pod to be scheduled is determined from the multiple nodes to be deployed, and the multiple Pods to be scheduled are deployed to the corresponding target nodes; The step of determining the target node for each Pod to be scheduled from a plurality of nodes to be deployed, based on a resource scheduling strategy using an improved artificial bee colony algorithm, includes: Initialize the bee colony based on the multiple Pods to be scheduled, and initialize the search space based on the multiple nodes to be deployed; During the hired bee search phase, an improved ant colony algorithm is used to globally optimize the search space and determine the first search area; During the bee selection phase, a preset adaptive random rule distribution is used to update the position of the first search area to determine the second search area; During the scout bee search phase, the fitness value of each location in the second search area is calculated, and the optimal location of the bee colony is determined based on the fitness value of each location in the second search area; wherein, each location corresponds to one node to be deployed; The optimal position of the bee colony is iteratively updated to determine the most suitable position for the bee colony. Based on the node to be deployed indicated by the most suitable location and its mapping relationship with the multiple Pods to be scheduled indicated by the bee colony, the target nodes corresponding to the multiple Pods to be scheduled are determined; The step of using an improved ant colony algorithm to globally optimize the search space and determine the first search region includes: Initialize the ant colony parameters and initialize the path pheromone concentration to the preset concentration value; Based on the path pheromone concentration and a preset heuristic function, calculate the probability value of each scheduled Pod in each population being scheduled to any node to be deployed in the search space. Based on the probability value of each Pod to be scheduled being scheduled to any node to be deployed in the search space, the target scheduling node of each Pod to be scheduled is determined. Update the path pheromone concentration based on the load balancing degree of the currently determined target scheduling node; The target scheduling node for each Pod to be scheduled is re-determined based on the updated path pheromone concentration until the preset iteration termination condition is met, and the final target scheduling node for each Pod to be scheduled is determined as the first search area.
2. The resource scheduling method as described in claim 1, characterized in that, The process of intercepting Pods created in the Kubernetes cluster results in multiple Pods awaiting scheduling, including: Within a preset retention period, Pods created in the Kubernetes cluster are retained; wherein, the retention period is determined based on the Pod request rate and the Pod latency tolerance. If the number of pods that are withheld reaches a preset threshold, the withheld pods will be designated as pods to be scheduled.
3. The resource scheduling method as described in claim 1, characterized in that, The step of selecting multiple nodes to be deployed from the Kubernetes cluster based on the resource types and resource requirements of the multiple Pods to be scheduled and the resource information of the nodes in the Kubernetes cluster includes: Based on the resource requirements of each Pod to be scheduled, the Pods to be scheduled are classified into different types to determine the resource type of each Pod to be scheduled. Based on the historical load data of each node in the Kubernetes cluster, the predicted load data of each node for multiple time units within a set future time period is obtained, and based on the predicted load data of the nodes, multiple candidate nodes are selected from the nodes of the Kubernetes cluster. Based on the resource types of the multiple Pods to be scheduled and the resource information of the multiple candidate nodes, multiple nodes to be deployed are selected from the multiple candidate nodes.
4. The resource scheduling method as described in claim 3, characterized in that, The process involves obtaining predicted load data for each node over a predetermined period of time based on historical load data of each node in the Kubernetes cluster, and then selecting multiple candidate nodes from the nodes of the Kubernetes cluster based on the predicted load data of the nodes, including: Determine whether the CPU resource utilization of each node exceeds a preset utilization threshold; If not, the corresponding node will be considered a candidate node; If so, obtain the CPU load data collected within the specified time period of the corresponding node as historical load data; Based on the historical load data of the corresponding node, CPU load is predicted using a preset load prediction model to obtain the predicted load data of the corresponding node for multiple time units within a set future time period. Determine whether the predicted load data of the corresponding node in multiple time units within a future set time period meets the preset load conditions; the load conditions include: there exists at least a first set number of predicted load data exceeding the preset load threshold; When the load conditions are met, the corresponding node is considered a candidate node.
5. The resource scheduling method as described in claim 3, characterized in that, The step of selecting multiple deployment nodes from multiple candidate nodes based on the resource types of multiple Pods to be scheduled and the resource information of multiple candidate nodes includes: Based on the resource type of each Pod to be scheduled, determine the weight of each Pod to be scheduled in terms of CPU, memory, network bandwidth, and disk space; Based on the resource information of each candidate node, determine the total resource amount and used resource amount of each candidate node in CPU, memory, network bandwidth, and disk space, and the requested resource amount of the Pod to be scheduled in CPU, memory, network bandwidth, and disk space. Based on the total resource amount, the used resource amount, and the requested resource amount, determine the resource usage and remaining resource amount of each candidate node in CPU, memory, network bandwidth, and disk space after scheduling the Pod. Based on the weights of each Pod to be scheduled in terms of CPU, memory, network bandwidth, and disk space, and the resource usage, remaining resources, and disk read / write speed of each candidate node in terms of CPU, memory, network bandwidth, and disk space, calculate the performance score of each candidate node. Based on the performance scores of each candidate node, a plurality of nodes to be deployed are selected from the plurality of candidate nodes.
6. The resource scheduling method as described in claim 1, characterized in that, The step of calculating the probability value of each scheduled Pod in each population being scheduled to any node to be deployed in the search space based on the path pheromone concentration and a preset heuristic function includes: Based on the utilization of CPU, memory, network bandwidth, and disk space of the corresponding node when each scheduled Pod is scheduled to any node to be deployed, and the average utilization of CPU, memory, network bandwidth, and disk space of all nodes to be deployed in the search space, the expected degree of scheduling each scheduled Pod to be deployed to any node to be deployed is calculated through the heuristic function. Based on the expected degree of each scheduled Pod being scheduled to any deployment node and the path pheromone concentration, calculate the probability value of each scheduled Pod being scheduled to any deployment node.
7. The resource scheduling method as described in claim 1, characterized in that, The step of updating the path pheromone concentration based on the currently determined load balancing degree of the target scheduling node includes: Based on the utilization of CPU, memory, network bandwidth, and disk space of the corresponding target scheduling node when each Pod to be scheduled is scheduled to the corresponding target scheduling node, and the average utilization of CPU, memory, network bandwidth, and disk space of all the target scheduling nodes, the load balancing degree of each Pod to be scheduled to the corresponding target scheduling node is calculated, and it is used as the load balancing degree of the ants that schedule each Pod to be scheduled. The ants are sorted according to their respective load balancing degrees to determine the ranking of each ant; The increment of the path pheromone concentration is calculated based on the load balancing degree and ranking of each ant. The path pheromone concentration is updated based on the path pheromone concentration and its increment.
8. The resource scheduling method as described in claim 1, characterized in that, The step of updating the position of the first search region using a preset adaptive random rule distribution to determine the second search region includes: By taking the standard Gaussian distribution and the Cauchy distribution as the limiting distributions of continuous probability distributions under a given degree of freedom, an adaptive random regular distribution is obtained; The adaptive random rule distribution is used to update the position of the first search region to determine the second search region.
9. A resource scheduling device, characterized in that, include: The Pod interception module is used to intercept Pods created in a Kubernetes cluster, resulting in multiple Pods to be scheduled. The node filtering module is used to filter out multiple nodes to be deployed from the Kubernetes cluster based on the resource types and resource requirements of the multiple Pods to be scheduled and the resource information of the nodes in the Kubernetes cluster. The Pod scheduling module is used to determine the target node for each Pod to be scheduled from multiple nodes to be deployed according to a resource scheduling strategy based on an improved artificial bee colony algorithm, and to deploy the multiple Pods to be scheduled to the corresponding target nodes. The Pod scheduling module includes: An initialization unit is used to initialize a bee colony based on the multiple Pods to be scheduled, and to initialize a search space based on the multiple nodes to be deployed. The first search unit is used to perform global optimization of the search space using an improved ant colony algorithm during the hired bee search phase, and to determine the first search area. The second search unit is used to update the position of the first search area using a preset adaptive random rule distribution during the observation bee selection phase, and to determine the second search area. The third search unit is used to calculate the fitness value of each position in the second search area during the scout bee search phase, and determine the optimal position of the bee colony based on the fitness value of each position in the second search area; wherein each position corresponds to one node to be deployed; An iterative update unit is used to iteratively update the optimal position of the bee colony to determine the most suitable position for the bee colony. The target node determination unit is used to determine the target nodes corresponding to the multiple Pods to be scheduled based on the node to be deployed indicated by the most suitable location and its mapping relationship with the multiple Pods to be scheduled indicated by the bee colony; The first search unit includes: The parameter initialization subunit is used to initialize the ant colony parameters and initialize the path pheromone concentration to a preset concentration value. The probability calculation subunit is used to calculate the probability value of each scheduled Pod in each population being scheduled to any node to be deployed in the search space based on the path pheromone concentration and a preset heuristic function. The first node determination subunit is used to determine the target scheduling node for each of the scheduled Pods based on the probability value of each Pod being scheduled to be deployed to any node in the search space. The pheromone concentration update subunit is used to update the path pheromone concentration based on the load balancing degree of the currently determined target scheduling node. The second node determination subunit is used to redetermine the target scheduling node of each of the Pods to be scheduled based on the updated path pheromone concentration, until the preset iteration termination condition is met, and to determine the final target scheduling node of each of the Pods to be scheduled as the first search area.
10. A resource scheduling device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the resource scheduling method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the resource scheduling method as described in any one of claims 1 to 8.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the resource scheduling method according to any one of claims 1 to 8.
Citation Information
Patent Citations
K8s-based pod intelligent balanced scheduling method, equipment, equipment and storage medium
CN117349022A