A Scheduling Method, Device, Equipment and Medium for Resource and Task Adaptation

By building a demand relationship model between tasks and resources, and combining greedy algorithms and immune algorithms to schedule tasks and resources, the problems of low task scheduling efficiency and low resource utilization in the existing technology are solved, and the optimal adaptation and efficient scheduling of resources and tasks in the middle-end video are achieved.

CN118672746BActive Publication Date: 2025-05-30LINEWELL SOFTWARE
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410714617.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2025-05-30
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

In the prior art, there are problems such as low task scheduling efficiency, low resource utilization, poor overall system performance, strict scenario constraints, and high complexity of solution methods.

Method used

By building a demand relationship model between tasks and resources, combining greedy algorithms and immune algorithms, adjusting task priority and resource allocation, the optimal adaptation between tasks and resources is achieved.

Benefits of technology

It improves task scheduling efficiency, resource utilization and overall system performance, reduces the complexity of the constraints and solution methods on the scene, and realizes the optimal scheduling of the video middle platform resources and tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672746B_ABST
    Figure CN118672746B_ABST
Patent Text Reader

Abstract

The present invention provides a scheduling method, device, equipment and medium for resource and task adaptation, including building a demand relationship model between tasks and resources: defining a correlation task model TP between tasks and K8s Pods; task scheduling based on a greedy algorithm: adjusting the task priority in the correlation task model TP, building a task processing queue according to the task priority, and counting the total resource usage until the total resource usage reaches the system limit resource threshold; resource scheduling based on an immune algorithm: defining a Pod demand table and a resource relationship, defining a related resource scheduling target model, and using an immune algorithm to solve the resource scheduling target model to achieve allocation of Pods on actual running working nodes. The advantages of the present invention: rapid convergence can be achieved, task scheduling efficiency, resource utilization and overall system performance can be improved, and the global optimization effect can also be improved to achieve optimal scheduling of video mid-stage resources and task adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of resource scheduling, and particularly relates to a scheduling method, device, equipment and medium for resource-task adaptation. Background Art

[0002] The video middle platform is a video capability base built on a cloud platform, specifically used to provide video capability support for industry customers. With the significant growth trend of video surveillance and image analysis tasks, the dependence on and requirements for parsing task scheduling and computing resources have also increased synchronously. The current task and resource scheduling system is facing an important challenge, that is, how to find the optimal solution among the many mutually restrictive goals of ensuring task execution efficiency, reasonably controlling resource consumption, improving resource sharing degree, and maximizing resource utilization rate.

[0003] Of course, there are also some related solutions in the prior art that can realize the scheduling and processing of tasks and resources, but there are still problems such as low task scheduling efficiency, low resource utilization rate, poor overall system performance, strict scene constraint conditions, and high complexity of the solution method. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a scheduling method, device, equipment and medium for resource-task adaptation, so as to solve the problems in the prior art such as low task scheduling efficiency, low resource utilization rate, poor overall system performance, strict scene constraint conditions, and high complexity of the solution method.

[0005] In the first aspect, the present invention provides a scheduling method for resource-task adaptation, and the method includes the following steps:

[0006] Construct a demand relationship model between tasks and resources: Define an associated task model TP between tasks and K8s Pods;

[0007] Task scheduling based on the greedy algorithm: Adjust the task priorities in the associated task model TP, construct a task processing queue according to the task priorities, and calculate the total resource usage until the total resource usage reaches the system limit resource threshold;

[0008] Resource scheduling based on the immune algorithm: Define the relationship between the Pod demand table and resources, define the relevant resource scheduling target model, and use the immune algorithm to solve the resource scheduling target model to realize the allocation of Pods on the actual working nodes.

[0009] In the second aspect, the present invention provides a scheduling device for resource-task adaptation, and the device includes a model construction module, a task scheduling module, and a resource scheduling module;

[0010] The model construction module is used to construct a demand relationship model between tasks and resources: define an association task model TP between tasks and K8sPods;

[0011] The task scheduling module is used for task scheduling based on the greedy algorithm: adjust the task priorities in the association task model TP, construct a task processing queue according to the task priorities, and calculate the total resource usage until the total resource usage reaches the system's limit resource threshold;

[0012] The resource scheduling module is used for resource scheduling based on the immune algorithm: define the relationship between the Pod demand table and resources, define the relevant resource scheduling target model, and use the immune algorithm to solve the resource scheduling target model to achieve the allocation of Pods on the actual working nodes.

[0013] In a third aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.

[0014] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.

[0015] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: By combining the greedy algorithm and the immune algorithm, two different types of algorithms are fused. Utilizing the efficiency of the greedy algorithm and the global search ability of the immune algorithm, when solving the resource and task scheduling problems of a complex video middle platform, it is possible to achieve fast convergence, improve task scheduling efficiency, resource utilization rate, and overall system performance, and also improve the global optimization effect, achieve the optimal scheduling of video middle platform resources and tasks, and at the same time reduce the constraint conditions of the scenario and the complexity of the solution method.

[0016] The above description is only an overview of the technical solutions of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features, and advantages of the present invention more obvious and understandable, the following specifically gives the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The present invention will be further described below with reference to the drawings in conjunction with embodiments.

[0018] Figure 1 It is the execution flow chart of the method in Embodiment 1 of the present invention;

[0019] Figure 2 It is the structural schematic diagram of the device in Embodiment 2 of the present invention;

[0020] Figure 3 This is a schematic diagram of the structure of an electronic device in Embodiment 3 of the present invention;

[0021] Figure 4 Schematic diagram of the structure of the medium in the fourth embodiment of the present invention. DETAILED DESCRIPTION

[0022] The core inventive concept of the technical solution in the embodiments of the present application is: by studying the demand relationship model between tasks and resources, and designing a task scheduling algorithm based on a greedy algorithm according to the view parsing task priority; at the same time, studying the multi-objective problems related to the computing power algorithm, and by constructing the Pareto optimal frontier, designing the optimal resource allocation model that meets the business resource requirements and the resource scheduling algorithm based on the immune algorithm; through the above two-stage task and resource association scheduling algorithm, the optimal scheduling of video middleware resources and task adaptation is achieved.

[0023] Embodiment 1

[0024] This embodiment provides a scheduling method for resource and task adaptation, such as Figure 1 As shown, the method comprises the following steps:

[0025] Step S1, build a demand relationship model between tasks and resources: define the correlation task model TP between tasks and K8s Pod; K8s (Kubernetes) is Google's open source container cluster management system, which provides a series of complete functions such as deployment and operation, resource scheduling, service discovery and dynamic scaling for containerized applications based on Docker technology, improving the convenience of large-scale container cluster management; Pod is a combination of several related containers running on the Node node. The containers contained in the Pod run on the same host machine, use the same network namespace, IP address and port, and can communicate through localhost; Pod is the smallest unit for Kubernetes to create, schedule and manage. It provides a higher level of abstraction than containers, making deployment and management more flexible. A Pod can contain one container or multiple related containers;

[0026] Step S2, Task Scheduling Based on Greedy Algorithm: Adjust the task priorities in the associated task model TP, construct a task processing queue according to the task priorities, and calculate the total resource usage until the total resource usage reaches the system's limit resource threshold. The greedy algorithm is a simpler and faster design technique for some problems seeking optimal solutions. The characteristic of designing an algorithm with the greedy method is to proceed step by step, often making an optimal choice based on a certain optimization measure in the current situation without considering various possible overall situations. It saves the large amount of time required to exhaust all possibilities to find the optimal solution. It adopts a top-down approach and makes successive greedy choices iteratively. Each time a greedy choice is made, the problem to be solved is reduced to a smaller-scale sub-problem. Through each step of greedy choice, an optimal solution to the problem can be obtained. Although it is necessary to ensure obtaining a local optimal solution at each step, the resulting global solution is sometimes not necessarily optimal.

[0027] After the above task scheduling and the association between tasks and Pods, the association set of tasks and Pods that need to allocate resources can be obtained. Next, it is to schedule and arrange suitable nodes for the Pods in the associated task model TP.

[0028] Step S3, Resource Scheduling Based on Immune Algorithm: Define the relationship between the Pod demand table and resources, define the relevant resource scheduling target model, and use the immune algorithm to solve the resource scheduling target model to achieve the allocation of Pods on the actual working nodes. The immune algorithm is a computational method that simulates the mechanism of the biological immune system. It draws on the principle of the interaction between antibodies and antigens in the biological immune system. In the biological immune system, antibodies can recognize and neutralize foreign antigens (such as viruses, bacteria, etc.). This process involves biological phenomena such as the generation, selection, cloning, and mutation of antibodies. The immune algorithm abstracts these biological principles into algorithm operations to solve optimization problems.

[0029] By combining the greedy algorithm and the immune algorithm, this invention integrates two different types of algorithms. Utilizing the efficiency of the greedy algorithm and the global search ability of the immune algorithm, when solving the resource and task scheduling problems of a complex video middle platform, it can achieve rapid convergence, improve task scheduling efficiency, resource utilization rate, and the overall performance of the system. It can also improve the global optimization effect, achieve the optimal scheduling of video middle platform resource and task adaptation, and at the same time reduce the constraint conditions of the scenario and the complexity of the solution method.

[0030] In the embodiment of the present invention, the specific definition of the associated task model TP between tasks and K8sPods is as follows:

[0031] Based on the K8s Pod resource management and business rule analysis, define the association task model TP between tasks and K8s Pods, specifically as shown in the following formula (1):

[0032] TP = {P 11 , P 12 , P 21 ,..., P tp} (1)

[0033] In formula (1), P tp represents the task model between the t-th task and the p-th Pod, where t represents the number of tasks and p represents the number of Pods.

[0034] Since resource scheduling is based on Kubernetes (K8s) container Pod resource management, through analysis based on business rules, the association task model TP between tasks and K8s Pods can be defined. In the specific implementation of the present invention, the solution of the association task model TP between tasks and K8s Pods can be mainly achieved through the following steps:

[0035] (1) After creating the algorithm analysis task, the scheduling platform calculates the amount of data to be processed per second according to the number of analysis channels supported by the task. For example, assume that the number of analysis channels supported by the task is 1000 channels, and each channel is parsed once every 5 seconds, then the amount of data to be processed per second is 1000 / 5 = 200.

[0036] (2) According to the data processing capacity requirements and algorithm capabilities (this part is mainly configured manually when the algorithm is accessed), calculate the required number of algorithm container Pods and associate the hardware resource requirements of the Pods with the hardware resource requirements set during algorithm registration. For example, assume that according to the above-mentioned task data volume of 200 to be processed per second, and each Pod can process a maximum of 20 task data volumes per second, then the required number of Pods is 200 / 20 = 10.

[0037] Since for a large number of video image parsing tasks in the video middle platform, when resources are insufficient, some tasks need to be excluded, and the association relationship between tasks, that is, task scheduling, needs to be considered during the exclusion process. The task scheduling of the present invention adopts a greedy algorithm. In the specific implementation of the present invention, the task scheduling based on the greedy algorithm specifically includes:

[0038] (1) Obtain the maximum priority in the task subset from the association task model TP as the extreme value, and assign the extreme value to all associated tasks, that is, modify their priorities, so as to adjust the task priorities in the association task model TP;

[0039] (2) Sort the tasks from high to low according to the task priorities to construct the task processing queue TaskQueue;

[0040] (3) Iteratively process the task queue TaskQueue, retrieve tasks one by one from the task queue TaskQueue, and calculate the total resource usage ResourceUse;

[0041] (4) Determine whether the total resource usage ResourceUse reaches the set system limit resource threshold TotalResource. If so, delete subsequent tasks, that is, eliminate subsequent tasks; if not, return to (1) and continue processing;

[0042] (5) Complete task screening. The specific implementation program is as follows:

[0043]

[0044]

[0045] In the embodiments of the present invention, the definition of the relationship between the Pod requirement table and resources specifically includes:

[0046] Map all K8s Pod sets required by the task to the set of worker nodes, thereby constructing the target policy matrix STRATEGY. The specific definition of the target policy matrix STRATEGY is as follows in formula (2):

[0047]

[0048] In formula (2), S NP represents the relationship between worker node N and Pod P node. When S NP is 1, it means that Pod P node is allocated on worker node N. When S NP is 0, it means that there is no allocation relationship between worker node N and Pod P node; N represents a total of N worker nodes, n represents any worker node between 1 and N; P represents a total of P Pods, and p represents any Pod node between 1 and P;

[0049] The main goal that the resource scheduling algorithm needs to achieve is to optimize the target policy matrix STRATEGY, that is, to find the optimal solution in this solution space; when solving the target policy matrix STRATEGY, the following requirements need to be met: the resources on each worker node are limited, and the total resources of the resident running Pods need to be constrained. Specifically, the following formula (3) needs to be satisfied:

[0050]

[0051] In formula (3), It is indicated that j is an integer, where j represents the j-th worker node; N represents the total number of worker nodes; i represents the i-th Pod; m represents the number of Pods on the worker node j; resource(S jp ) represents the resources required by the Pod p node resident on the worker node j; resource(Node j ) represents the total resources on the worker node j.

[0052] In an embodiment of the present invention, the defined resource scheduling target model specifically includes:

[0053] Based on the Pareto Optimal Front, multiply the multi-objective functions to find the optimal solution to the problem, thereby building a resource scheduling model. The specific process is as shown in the following formulas (4)-(6):

[0054]

[0055] In formulas (4)-(6), D 1 and D 2 both represent constants. D 1 and D 2 are used to convert the minimum value problem into a maximum value problem. The values of D 1 and D 2 are determined by observing the values in the experiment so that the optimal values of the two optimization objectives are not negative; x represents the decision vector; β is a parameter for adjusting the weight, and this β is used to ensure that the extreme value of the affinity objective is less than 1, which is an experimental parameter; f 1 (x) is the first objective function, representing the average resource loss rate of all worker nodes; f 2 (x) is the second objective function, representing the negation of the affinity for all worker nodes; represents the normalized value of the first objective function, represents the normalized value of the second objective function; F(x) represents the final optimization objective function, and maxF(x) represents the optimal objective solution;

[0056] In the specific implementation of the present invention, the specific calculation formula of the first objective function f 1 (x) is as shown in the following formulas (4.1) and (4.2):

[0057]

[0058] In formulas (4.1) and (4.2), ULOST n represents the resource loss rate on the worker node n; represents the resource loss amount on the worker node n; represents the total resource amount on the worker node n; N represents the number of worker nodes;

[0059] The second objective function f 2 (x) has the specific calculation formula as the following formulas (5.1) and (5.2). Formula (5.1) represents the affinity between Pods:

[0060] f 2 (x) = -(∑∑AFFINITY ij ) (5.1)

[0061]

[0062] Where x ij represents the relationship between the i-th Pod and the j-th Pod in the Pod relationship matrix. Here, the Pod relationship matrix refers to S in the target policy matrix STRATEGY NP ; P represents the number of Pods; AFFINITY represents the value obtained by normalizing the magnitude of the affinity value. Since the result of summing the affinity degrees will vary around a value greater than 1, normalization is needed to adjust the value to the range of 0 to 1; AFFINITY ij represents the affinity between Pod node i and Pod node j; The affinity calculation rule of f(x ij ) is as follows: The affinity between homogeneous Pod nodes on the same working node is -1, the affinity between associated Pod nodes on different working nodes is 2, and the affinity between Pod nodes in other cases is 0.

[0063] In a multi-objective optimization problem, the Pareto optimal front is the set composed of all optimal solutions. The present invention uses the Pareto optimal front to fuse two indicators of the resource loss rate and the Pod node affinity, thereby establishing a resource scheduling model, which can reduce resource fragmentation and the resource loss rate during resource allocation to improve resource utilization; at the same time, in order to reduce the large differences between objective functions, resulting in a small impact of other objective functions on the final result, the present invention performs normalization processing on relevant objective functions.

[0064] Define the antigen as the optimization problem, the antibody as the problem solution, the number of antigens as the number of optimization sub-objectives, and make the following definitions based on the immune algorithm:

[0065] Suppose there are H antibodies, each antibody has M gene positions, and each gene position has S discrete values to choose from (that is, each gene position has k 1 , k 2 ,..., k s a total of S discrete values to choose from), then define the fitness of the antibody as the following formula (7):

[0066] fit j = ((D1 -f 1 (x i )) * 0.5) * (D 2 -f 2 (x i )) (7)

[0067] In Equation (7), j = {1,...H}, i = {1,...S}; in the immune algorithm iteration, take the maximum value of fit j as the solution; D 1 、D 2 、f 1 (x) and f 2 (x) have the same meanings as those represented by the above Equations (4)-(6).

[0068] Define the concentration of the j-th antibody as the following Equation (8):

[0069]

[0070] In Equation (8), H represents having H antibodies, X jv represents the density of the j-th type of antibody, |X jv | 2 represents the second-order norm of antibody v in the j-th type of antibody;

[0071] The concentration of an antibody refers to the number or density of a certain type of antibody in an antibody population, that is, the frequency of the appearance of this solution in the search space.

[0072] Assume that the number of algorithm generations is g, and the mutation probability of the gene position Φ i of antibody X i is controlled by the following Equations (9) and (10):

[0073]

[0074] In Equations (9) and (10), P i represents the mutation probability of antibody X i ; α represents a constant; random represents a random number, others represents a conditional judgment; i = {1,...,M}, when Φ(i) is 1, it means to select to mutate this gene position, and the mutation constraint condition is Among them, represents the resource units occupied by k Pods resident on worker node n, NR n represents the total resource units owned by worker node n, n represents the worker node, m represents the Pod node, PR represents the resources occupied by the Pod, and NR represents the total resources of the worker node; it should be noted that: 1. in Equation (9) represents a floating-point number;

[0075] The mutation probability of an antibody refers to the probability that a particular antibody mutates when generating a new antibody; antibody mutation means generating a new antibody by introducing some random changes based on an existing antibody; mutations usually include operations such as gene mutation and gene recombination, which can make the newly generated antibody have better fitness, thus promoting the convergence of the search algorithm.

[0076] In the embodiments of the present invention, the specific steps of using the immune algorithm to solve the resource scheduling objective model include:

[0077] First, initialization: Randomly generate a group of initial solutions as the population, and calculate the fitness of each solution;

[0078] Second, selection: Calculate the antibody concentration according to the fitness of each solution and sort them. At the same time, select a part of the solutions with the best fitness as antibodies for the subsequent evolution process;

[0079] Third, cloning: Clone the selected antibodies to generate a group of cloned antibodies;

[0080] Fourth, mutation: Perform random mutation operations on the cloned antibodies to generate new solutions. Among them, the random mutation operations include at least one of the following: NodeSelectors and Labels mutation, Affinity and Anti-Affinity rule mutation, Taints and Tolerations mutation, resource requests and limits mutation;

[0081] Fifth, optimization: Select a part of the excellent solutions to add to the next generation population according to the fitness of each solution;

[0082] Sixth, termination condition: When the preset number of iterations or the target fitness is reached, stop the immune algorithm and output the optimal solution. The specific implementation code is as follows:

[0083] Initialize the population;

[0084] Initialize the iteration counter L and set the target fitness Q;

[0085] Calculate the fitness value fit;

[0086] While (L > 0 or fit < Q)

[0087] { / / Start of iteration

[0088] Calculate the affinity of the Pod nodes;

[0089] / * Calculate the antibody concentration * /

[0090] Calculate the antibody concentration according to the fitness;

[0091] Sort to obtain the sorted population list new_pods;

[0092] / * Selection operation * /

[0093] Select multiple optimal solutions from new_pods and clone and evolve;

[0094] / * Mutation operation * /

[0095] Mutate individuals according to a certain probability Pi;

[0096] / * Evaluation operation * /

[0097] Calculate the fitness fit of the individual;

[0098] / * Immune selection operation * /

[0099] Compare the fitness of an individual with the fitness of a similar individual;

[0100] Take the maximum value as one generation according to the rule;

[0101] / * Update operation * /

[0102] Update the population to generate the next generation;

[0103] L = L - 1;

[0104] } / / End of iteration;

[0105] Output the optimal solution.

[0106] Based on the same inventive concept, this application also provides a device corresponding to the method in Embodiment 1. For details, see Embodiment 2.

[0107] Embodiment 2

[0108] In this embodiment, a scheduling device for resource and task adaptation is provided, as Figure 2 shown. The device includes a model construction module, a task scheduling module, and a resource scheduling module;

[0109] The model building module is used to build a demand relationship model between tasks and resources: define the correlation task model TP between tasks and K8sPod; K8s (Kubernetes) is Google's open source container cluster management system, which provides a series of complete functions such as deployment and operation, resource scheduling, service discovery and dynamic scaling for containerized applications based on Docker technology, improving the convenience of large-scale container cluster management; Pod is a combination of several related containers running on the Node node. The containers contained in the Pod run on the same host machine, use the same network namespace, IP address and port, and can communicate through localhost; Pod is the smallest unit for Kubernetes to create, schedule and manage. It provides a higher level of abstraction than containers, making deployment and management more flexible. A Pod can contain one container or multiple related containers;

[0110] The task scheduling module is used for task scheduling based on the greedy algorithm: adjusting the task priority in the associative task model TP, building a task processing queue according to the task priority, and counting the total resource usage until the total resource usage reaches the system limit resource threshold; the greedy algorithm is a simpler and faster design technology for some optimal solution problems; the characteristic of designing an algorithm using the greedy method is that it is carried out step by step, and the optimal choice is often made according to a certain optimization measure based on the current situation, without considering various possible overall situations. It saves a lot of time that must be spent on exhausting all possibilities to find the optimal solution, and adopts a top-down, iterative method to make successive greedy choices. Each greedy choice simplifies the problem to a smaller sub-problem. Through each step of greedy selection, an optimal solution to the problem can be obtained. Although it is necessary to ensure that a local optimal solution can be obtained at each step, the resulting global solution is sometimes not necessarily the optimal;

[0111] After the above task scheduling and the association between tasks and Pods, we can get the association set of tasks and Pods that need to allocate resources. The next step is to schedule the Pods in the associated task model TP to the appropriate nodes.

[0112] The resource scheduling module is used for resource scheduling based on the immune algorithm: defining the relationship between the Pod demand table and resources, defining the relevant resource scheduling target model, and using the immune algorithm to solve the resource scheduling target model to achieve the allocation of Pods on the actual working nodes; the immune algorithm is a computational method that simulates the mechanism of the biological immune system. It draws on the principle of the interaction between antibodies and antigens in the organism's immune system. In the biological immune system, antibodies can recognize and neutralize foreign antigens (such as viruses, bacteria, etc.). This process involves biological phenomena such as antibody generation, selection, cloning, and mutation. The immune algorithm abstracts these biological principles into algorithm operations for solving optimization problems.

[0113] In the present invention, by combining the greedy algorithm and the immune algorithm, two different types of algorithms are fused. Utilizing the efficiency of the greedy algorithm and the global search ability of the immune algorithm, when solving the resource and task scheduling problems of a complex video middleware platform, it can achieve rapid convergence, improve task scheduling efficiency, resource utilization rate, and overall system performance. It can also improve the global optimization effect, achieve the optimal scheduling of the adaptation of video middleware platform resources and tasks, and at the same time reduce the constraint conditions for the scenario and the complexity of the solution method.

[0114] In an embodiment of the present invention, in the model construction module, the definition of the association task model TP between the task and the K8sPod is specifically as follows:

[0115] Based on the K8sPod resource management and business rule analysis, the association task model TP between the task and the K8sPod is defined, specifically as shown in the following formula (1):

[0116] TP = {P 11 , P 12 , P 21 ,..., P tp} (1)

[0117] In formula (1), P tp represents the task model between the t-th task and the p-th Pod, where t represents the number of tasks and p represents the number of Pods.

[0118] Since resource scheduling is based on Kubernetes (K8s) container Pod resource management, based on business rule analysis, the association task model TP between the task and the K8sPod can be defined. In the specific implementation of the present invention, the solution of the association task model TP between the task and the K8sPod can be mainly achieved through the following steps:

[0119] (1) After creating an algorithm analysis task, the scheduling platform calculates the amount of data to be processed per second based on the number of analysis channels required by the task. For example, assume that the number of analysis channels required by the task is 1000, and each channel is parsed once every 5 seconds. Then the amount of data to be processed per second is 1000 / 5 = 200.

[0120] (2) According to the data processing capacity requirements and algorithm capabilities (this part is mainly configured manually when the algorithm is accessed), calculate the required number of algorithm container Pods and associate the hardware resource requirements of the Pods with the hardware resource requirements set during algorithm registration. For example, assume that based on the above task data volume of 200 per second, the maximum task data volume that each Pod can process per second is 20. Then the number of required Pods is 200 / 20 = 10.

[0121] Due to a large number of video image parsing tasks for the video middle platform, when resources are insufficient, some tasks need to be excluded. And during the exclusion process, the association relationship between tasks, that is, task scheduling, needs to be considered. The task scheduling of the present invention adopts a greedy algorithm. When the present invention is specifically implemented, the task scheduling module is specifically used for:

[0122] (1) Obtain the maximum priority in the task subset from the relevance task model TP as the extreme value, and assign the extreme value to all associated tasks, that is, modify their priorities, so as to adjust the task priorities in the relevance task model TP;

[0123] (2) Sort the tasks from high to low according to the task priorities to construct a task processing queue TaskQueue;

[0124] (3) Iterate the task processing queue TaskQueue, take out tasks one by one from the task processing queue TaskQueue, and count the total resource usage ResourceUse;

[0125] (4) Determine whether the total resource usage ResourceUse reaches the set system limit resource threshold TotalResource. If so, delete the subsequent tasks, that is, exclude the subsequent tasks; if not, return to (1) and continue to process;

[0126] (5) Complete task screening.

[0127] In the embodiment of the present invention, in the resource scheduling module, the definition of the relationship between the Pod requirements table and resources specifically includes:

[0128] Map all K8s Pod sets required by the task to the set of working nodes, so as to construct a target policy matrix STRATEGY. The specific definition of the target policy matrix STRATEGY is as shown in the following formula (2):

[0129]

[0130] In formula (2), S NP represents the relationship between the working node N and the Pod P node. When S NP is 1, it means that the Pod P node is allocated on the working node N. When S NP is 0, it means that there is no allocation relationship between the working node N and the Pod P node; N represents a total of N working nodes, n represents any working node between 1 and N; P represents a total of P Pods, and p represents any Pod node between 1 and P;

[0131] The main goal that the resource scheduling algorithm needs to achieve is to optimize the objective policy matrix STRATEGY, that is, to find the optimal solution within this solution space; when solving the objective policy matrix STRATEGY, the following requirements need to be met: the resources on each working node are limited, and the total resources of the resident running Pods need to be constrained, specifically, the following formula (3) needs to be satisfied:

[0132]

[0133] In formula (3), represents that j is an integer, j represents the jth working node; N represents the total number of working nodes; i represents the ith Pod; m represents the number of Pods on the working node j; resource(S jp ) represents the resources required by the Pod p node resident on the working node j; resource(Node j ) represents the total resources on the working node j.

[0134] In the embodiment of the present invention, in the resource scheduling module, the specifically defined resource scheduling target model includes:

[0135] Based on the Pareto Optimal Front, multiply the multi-objective functions to find the optimal solution to the problem, thereby building a resource scheduling model. The specific process is as the following formulas (4)-(6):

[0136]

[0137] In formulas (4)-(6), D 1 and D 2 both represent constants. D 1 and D 2 are used to convert the minimum value problem into a maximum value problem. D 1 and D 2The value is determined by observing the values in the experiment so that the optimal values of the two optimization objectives are not negative; x represents the decision vector; β is a parameter for adjusting the weight, and this β is used to ensure that the extreme value of the affinity objective is less than 1 and is an experimental parameter; f 1 (x) is the first objective function, representing the average resource loss rate of all worker nodes; f 2 (x) is the second objective function, representing the negation of the affinity for all worker nodes; represents the normalized value of the first objective function, represents the normalized value of the second objective function; F(x) represents the final optimization objective function, and maxF(x) represents the optimal objective solution;

[0138] In the specific implementation of the present invention, the specific calculation formula of the first objective function f 1 (x) is as shown in the following formulas (4.1) and (4.2):

[0139]

[0140] In formulas (4.1) and (4.2), ULOST n represents the resource loss rate on worker node n; represents the resource loss amount on worker node n; represents the total resource amount on worker node n; N represents the number of worker nodes;

[0141] The specific calculation formula of the second objective function f 2 (x) is as shown in the following formulas (5.1) and (5.2), and formula (5.1) represents the affinity between Pods:

[0142] f 2 (x) = -(∑∑AFFINITY ij ) (5.1)

[0143]

[0144] where, x ij represents the relationship between the i-th Pod and the j-th Pod in the Pod relationship matrix, where the Pod relationship matrix refers to S in the target policy matrix STRATEGY NP ; P represents the number of Pods; AFFINITY represents the value obtained by normalizing the magnitude of the affinity value. Since the result of summing the affinity degrees will vary around a value greater than 1, normalization is required to adjust the value to between 0 and 1; AFFINITY ij represents the affinity between Pod node i and Pod node j; f(x ij) The affinity calculation rules are as follows: The affinity of homogeneous Pod nodes on the same worker node is -1, the affinity of associated Pod nodes on different worker nodes is 2, and the affinity between Pod nodes in other cases is 0.

[0145] In the multi-objective optimization problem, the Pareto optimal front is the set of all optimal solutions. This invention uses the Pareto optimal front to fuse two indicators of resource loss rate and Pod node affinity, thereby building a resource scheduling model, which can reduce resource fragmentation and resource loss rate during resource allocation to improve resource utilization. At the same time, in order to reduce the large differences between objective functions, resulting in a small impact of other objective functions on the final result, this invention performs normalization processing on relevant objective functions.

[0146] Define the antigen as the optimization problem, the antibody as the problem solution, and the number of antigens as the number of optimization sub-goals, and make the following definitions based on the immune algorithm:

[0147] Suppose there are H antibodies, each antibody has M gene positions, and each gene position has S discrete values to choose from (that is, each gene position has k 1 , k 2 ,..., k s a total of S discrete values to choose from), then the fitness of the antibody is defined as the following formula (7):

[0148] fit j = ((D 1 - f 1 (x i )) * 0.5) * (D 2 - f 2 (x i )) (7)

[0149] In formula (7), j = {1,... H}, i = {1,... S}; in the immune algorithm iteration, take the maximum value of fit j as the solution; D 1 , D 2 , f 1 (x) and f 2 (x) have the same meanings as those represented by the above formulas (4) - (6).

[0150] Define the concentration of the jth antibody as the following formula (8):

[0151]

[0152] In formula (8), H represents having H antibodies, X jv represents the density of the jth type of antibody, |X jv | 2Denote the second-order norm of antibody v in the j-th class of antibodies;

[0153] The concentration of an antibody refers to the number or density of a certain type of antibody in an antibody population, that is, the frequency of occurrence of this solution in the search space.

[0154] Assume that the algorithm generation number is g, and antibody X i The gene position Φ i The mutation probability of is controlled by the following equations (9) and (10):

[0155]

[0156] In equations (9) and (10), P i Denotes the mutation probability of antibody X i ; α represents a constant; random represents a random number, others represents conditional judgment; i = {1,..., M}, when Φ(i) is 1, it means to select to mutate this gene position, and the mutation constraint is Among them, Denotes the resource units occupied by k Pods resident on worker node n, NR n Denotes the total resource units owned by worker node n, n represents the worker node, m represents the Pod node, PR represents the resources occupied by the Pod, NR represents the total resources of the worker node; it should be noted that: 1. in equation (9) represents this is a floating-point number;

[0157] The mutation probability of an antibody refers to the probability that a certain antibody mutates when generating a new antibody; antibody mutation means generating a new antibody by introducing some random changes on the basis of an antibody; mutation usually includes operations such as gene mutation and gene recombination, which can make the newly generated antibody have better fitness, thereby promoting the convergence of the search algorithm.

[0158] In the embodiment of the present invention, in the resource scheduling module, the specific steps of using the immune algorithm to solve the resource scheduling target model include:

[0159] First, initialization: Randomly generate a group of initial solutions as the population, and calculate the fitness of each solution;

[0160] Second, selection: Calculate the antibody concentration according to the fitness of each solution and sort them, and at the same time select a part of the solutions with the best fitness as antibodies for subsequent evolution;

[0161] Third, cloning: Clone the selected antibodies to generate a group of cloned antibodies;

[0162] Fourth, Mutation: Perform random mutation operations on the cloned antibodies to generate new solutions. The random mutation operations include at least one of the following: NodeSelectors and Labels mutation, Affinity and Anti-Affinity rule mutation, Taints and Tolerations mutation, resource requests and limits mutation;

[0163] Fifth, Optimization: Select a part of the excellent solutions and add them to the next generation population according to the fitness of each solution;

[0164] Sixth, Termination Condition: When the preset number of iterations or the target fitness is reached, stop the immune algorithm and output the optimal solution.

[0165] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1. For details, see Embodiment 3.

[0166] Embodiment 3

[0167] This embodiment provides an electronic device, as Figure 3 shown, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, any implementation manner in Embodiment 1 can be realized.

[0168] Since the electronic device introduced in this embodiment is the device used to implement the method in Embodiment 1 of this application, based on the method introduced in Embodiment 1 of this application, those skilled in the art can understand the specific implementation manner and various variations of the electronic device in this embodiment. Therefore, the specific implementation of how this electronic device realizes the method in the embodiments of this application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiments of this application belongs to the scope to be protected by this application.

[0169] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1. For details, see Embodiment 4.

[0170] Embodiment 4

[0171] This embodiment provides a computer-readable storage medium, as Figure 4 shown, on which a computer program is stored. When the computer program is executed by a processor, any implementation manner in Embodiment 1 can be realized.

[0172] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, an apparatus, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0173] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses, and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0174] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device that implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0176] Although the specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments we described are illustrative rather than used to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered by the scope of the claims of the present invention.

Claims

1. A scheduling method for resource and task adaptation, characterized in that: The method comprises the following steps: Build a demand relationship model between tasks and resources: define the correlation task model TP between tasks and K8sPod; Task scheduling based on the greedy algorithm: adjust the task priority in the associated task model TP, build a task processing queue according to the task priority, and calculate the total resource usage until the total resource usage reaches the system limit resource threshold, including: (1) Obtain the maximum priority in the task subset from the associated task model TP as the extreme value, and assign extreme values ​​to all associated tasks, thereby adjusting the task priorities in the associated task model TP; (2) Sort tasks from high to low according to their priority and build a task processing queue TaskQueue; (3) Iterate the task processing queue TaskQueue, take out tasks one by one from the task processing queue TaskQueue, and calculate the total resource usage ResourceUse; (4) Determine whether the total resource usage ResourceUse reaches the set system resource limit threshold TotalResource. If yes, delete the subsequent tasks; if not, return to (1) to continue processing; (5) Complete task screening; Resource scheduling based on immune algorithm: Define the relationship between the Pod demand table and resources, define the relevant resource scheduling target model, and use the immune algorithm to solve the resource scheduling target model to allocate the Pod on the actual running working nodes.

2. A scheduling method for resource and task adaptation according to claim 1, characterized in that: The task model TP that defines the association between the task and the K8sPod is specifically: Based on K8sPod resource management and business rule analysis, the task model TP that represents the association between tasks and K8sPod is defined as follows: TP={P 11 ,P 12 ,P 21 ,...,P tp } (1) In formula (1), P tp Represents the task model between the tth task and the pth Pod, where t represents the number of tasks and p represents the number of Pods.

3. A scheduling method for resource and task adaptation according to claim 1, characterized in that: The definition of the Pod requirement table and resource relationship specifically includes: Map all K8s Pod sets required for the task to the set of working nodes to construct the target strategy matrix STRATEGY. The specific definition of the target strategy matrix STRATEGY is as follows: In formula (2), S NP Represents the relationship between the working node N and the Pod P node. When S NP 1 means that Pod P node is allocated to worker node N. NP 0 means that there is no allocation relationship between working node N and Pod P node; N means there are N working nodes in total, n means any working node between 1 and N; P means there are P Pods in total, p means any Pod node between 1 and P; When solving the target strategy matrix STRATEGY, the following requirements must be met: the resources on each working node are limited, and the total resources of the resident Pods need to be constrained. Specifically, the following formula (3) must be satisfied: In formula (3), Indicates that j is an integer, j represents the jth working node; N represents the total number of working nodes; i represents the i-th Pod; m represents the number of Pods on working node j; resource(S jp ) represents the resources required by the Pod p node residing on the worker node j; resource(Node j ) represents the total resources on worker node j.

4. The method for scheduling resource and task adaptation according to claim 1, characterized in that: The resource scheduling target model related to the definition specifically includes: Based on the Pareto optimal frontier, the multi-objective functions are multiplied to find the optimal solution to the problem, thereby building a resource scheduling model. The specific process is shown in the following formulas (4)-(6): In equations (4)-(6), D1 and D2 are both constants. D1 and D2 are used to convert the minimum problem into the maximum problem. The values ​​of D1 and D2 are determined by observing the values ​​in the experiment so that the optimal values ​​of the two optimization objectives are not negative; x represents the decision vector; β is a parameter for adjusting the weight, which is used to ensure that the extreme value of the affinity target is less than 1 and is an experimental parameter; f1(x) is the first objective function, which represents the average resource loss rate of all working nodes; f2(x) is the second objective function, which represents the inversion of the affinity of all working nodes; represents the normalized value of the first objective function, represents the normalized value of the second objective function; F(x) represents the final optimization objective function, and maxF(x) represents the optimal objective solution; The antigen is defined as the optimization problem, the antibody is defined as the solution, the number of antigens is the number of optimization sub-goals, and the following definitions are made based on the immune algorithm: Assuming that there are H antibodies, each antibody has M gene positions, and each gene position has S discrete values ​​to choose from, the fitness of the antibody is defined as the following formula (7): fit j =((D1-f1(x i ))*0.5)*(D2-f2(x i )) (7) In formula (7), j = {1,...H}, i = {1,...S}; in the immune algorithm iteration, fit j The maximum value of is taken as the solution; The concentration of the jth antibody is defined as the following formula (8): In formula (8), H represents H antibodies, X jv represents the density of the j-th antibody, |X jv |2 represents the second-order norm of antibody v in the jth class of antibodies; Assume that the algorithm algebra is g, antibody X i The gene position Φ i The mutation probability of is controlled by the following equations (9) and (10): In equations (9) and (10), P i Represents antibody X i The mutation probability; α represents a constant; random represents a random number, and others represents a conditional judgment; i = {1,...,M}, when Φ(i) is 1, it means that the gene position is selected for mutation, and the mutation constraint is in, Represents the resource units occupied by k Pods residing on worker node n, NR n Represents the total resource units owned by worker node n, where n represents the worker node, m represents the Pod node, PR represents the resources occupied by the Pod, and NR represents the total resources of the worker node.

5. A scheduling method for resource and task adaptation according to claim 4, characterized in that: The specific steps of using the immune algorithm to solve the resource scheduling target model include: First, initialization: randomly generate a set of initial solutions as the population, and calculate the fitness of each solution; Second, selection: Calculate the antibody concentration according to the fitness of each solution and sort them, and select a part of the solutions with the best fitness as antibodies for the subsequent evolution process; Third, cloning: cloning the selected antibodies to produce a group of cloned antibodies; Fourth, mutation: Perform random mutation operations on the cloned antibodies to generate new solutions, where the random mutation operations include at least one of the following: node selector and label mutation, affinity and anti-affinity rule mutation, stain and tolerance mutation, resource request and restriction mutation; Fifth, according to the fitness of each solution, select some excellent solutions to join the next generation population; Sixth, termination condition: When the preset number of iterations or target fitness is reached, the immune algorithm is stopped and the optimal solution is output.

6. A scheduling device for resource and task adaptation, characterized in that: The device includes a model building module, a task scheduling module and a resource scheduling module; The model building module is used to build a demand relationship model between tasks and resources: define the correlation task model TP between tasks and K8s Pods; The task scheduling module is used for task scheduling based on the greedy algorithm: adjusting the task priority in the associated task model TP, building a task processing queue according to the task priority, and calculating the total resource usage until the total resource usage reaches the system limit resource threshold, specifically including: (1) Obtain the maximum priority in the task subset from the associated task model TP as the extreme value, and assign extreme values ​​to all associated tasks, thereby adjusting the task priorities in the associated task model TP; (2) Sort tasks from high to low according to their priority and build a task processing queue TaskQueue; (3) Iterate the task processing queue TaskQueue, take out tasks one by one from the task processing queue TaskQueue, and calculate the total resource usage ResourceUse; (4) Determine whether the total resource usage ResourceUse reaches the set system resource limit threshold TotalResource. If yes, delete the subsequent tasks; if not, return to (1) to continue processing; (5) Complete task screening; The resource scheduling module is used for resource scheduling based on the immune algorithm: defining the relationship between the Pod demand table and the resources, defining the relevant resource scheduling target model, and using the immune algorithm to solve the resource scheduling target model to achieve the allocation of the Pod on the actual running working node.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Container scheduling method based on improved genetic algorithm

    CN118113417A