Method and apparatus for optimizing computing resources of multi-task container cluster
By filtering and migrating containers in a multi-task container cluster, and optimizing resource utilization and migration times using the Hungarian algorithm and depth-first search algorithm, the problem of load imbalance is solved, and more efficient resource management is achieved.
Patent Information
- Application Number
- CN202110574006.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-25
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2041-05-25
AI Technical Summary
Existing technologies lack effective methods to simultaneously improve resource utilization and reduce container migrations in multi-tasking container clusters, especially under unbalanced load conditions, and cannot balance resource fragmentation and migration efficiency.
By obtaining the resource utilization rate of the target node, a second target container is selected. Container migration is performed based on the Hungarian algorithm, and task scheduling is optimized by combining a depth-first search algorithm to achieve resource ratio matching and task migration.
It improved resource utilization, reduced the number of container migrations, ensured a more balanced cluster load, and improved the overall system operating efficiency.
Smart Images

Figure CN115391023B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular to a method and device for optimizing computing resources of a multi-task container cluster. BACKGROUND
[0002] With the rapid development of cloud computing and big data, container technology, as the most basic cornerstone of cloud native technology, has gradually emerged. In the actual construction of a Docker container cloud computing environment, due to the fact that containers will carry multiple tasks to run on nodes, and the dynamic change characteristics of cluster workloads, load imbalance is caused.
[0003] The existing technical solutions can effectively reduce resource fragmentation and improve resource utilization for unstable workloads of a single task and large changes in container size, or reduce the number of container migrations by using traditional container migration strategies, but lack a method that takes both into account and is optimal at the same time. In addition, there is currently a lack of methods for handling load imbalance when multiple tasks occur.
[0004] In summary, the related art lacks a method for simultaneously improving resource utilization and reducing the number of container migrations when handling load imbalance for at least one task. SUMMARY
[0005] The present application provides a method and device for optimizing computing resources of a multi-task container cluster to solve the technical problem of simultaneously improving resource utilization and reducing the number of container migrations when handling load imbalance for at least one task in the related art.
[0006] In a first aspect, the present application provides a method for optimizing computing resources of a multi-task container cluster, comprising:
[0007] obtaining the resource utilization of a target node, the target node being at least one node in the cluster;
[0008] obtaining a first target container on the target node based on the resource utilization of the target node, the first target container being at least one container on the target node;
[0009] obtaining the resource proportion of the target node and the first target container, respectively;
[0010] filtering the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container;
[0011] sorting the second target container in a predetermined order based on the resource requirements of all tasks in the second target container;
[0012] scheduling the second target container to a first target node based on the sorting result, the first target node being one of the target nodes having deployed containers;
[0013] migrating the second target container based on the Hungarian algorithm.
[0014] In one embodiment, the resource usage of the target node includes at least one of a central processing unit (CPU) resource usage of the target node and a memory resource usage of the target node.
[0015] The first target container on the target node is obtained based on the resource usage of the target node, specifically including:
[0016] In a case where the CPU resource usage of the target node is less than a first preset threshold or the memory resource usage of the target node is less than the first preset threshold, the first target container on the target node is obtained.
[0017] In one embodiment, the first target container is filtered based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container, specifically including:
[0018] In a case where the resource proportion of the target node and the resource proportion of the first target container satisfy a preset condition, the first target container is filtered to obtain the second target container.
[0019] The preset condition is |I c1 / I r1 -I c2 / I r2 |>Δk, I c1 / I r1 denotes the resource proportion of the target node, I c2 / I r2 denotes the resource proportion of the first target container, I c1 denotes a CPU resource demand of the target node, I r1 denotes a memory resource demand of the target node, I c2 denotes a CPU resource demand of the first target container, I r2 denotes a memory resource demand of the first target container, and Δk is a second preset threshold.
[0020] In one embodiment, the second target container is scheduled to a first target node based on the sorting result, specifically including:
[0021] The sorted second target container is respectively deployed to each of the target nodes having deployed containers.
[0022] calculate a deviation ratio of CPU resource and memory resource of each node;
[0023] select the node with the minimum deviation ratio as a first target node;
[0024] schedule the second target container to the first target node.
[0025] In one embodiment, the migration of the second target container based on the Hungarian algorithm specifically comprises:
[0026] obtain a first container and a second container based on the second target container, the first container and the second container being any two different containers in the second target container;
[0027] match the first container and the second container based on the Hungarian algorithm to obtain a target matching result;
[0028] migrate the computing task in the first container and the computing task in the second container based on the target matching result.
[0029] In one embodiment, the matching of the first container and the second container based on the Hungarian algorithm to obtain a target matching result specifically comprises:
[0030] obtain a first target computing task in the first container, the first target computing task being any computing task in the first container;
[0031] obtain a second target computing task connected to the first target computing task from the second container based on a depth-first search (DFS) algorithm;
[0032] obtain a target matching result based on the first target computing task and the second target computing task.
[0033] In one embodiment, the computing resource optimization method of the multi-task container cluster further comprises:
[0034] obtain update information of the second target container configuration;
[0035] update local configuration information of the second target container based on the update information.
[0036] In a second aspect, the present application provides a computing resource optimization device of a multi-task container cluster, comprising:
[0037] a first obtaining unit configured to obtain resource usage of a target node, the target node being at least one node in a cluster;
[0038] The second obtaining unit is configured to obtain a first target container on the target node based on a resource usage ratio of the target node, the first target container being at least one container on the target node.
[0039] The third obtaining unit is configured to respectively obtain resource ratios of the target node and the first target container.
[0040] The screening unit is configured to screen the first target container based on the resource ratio of the target node and the resource ratio of the first target container, to obtain a second target container.
[0041] The sorting unit is configured to sort the second target container in a preset order based on resource demands of all tasks in the second target container.
[0042] The scheduling unit is configured to schedule the second target container to the first target node based on a sorting result, the first target node being one node in the target node on which a container has been deployed.
[0043] The migration unit is configured to migrate the second target container based on a Hungarian algorithm.
[0044] In a third aspect, the present application provides an electronic device, which comprises a memory and a memory storing a computer program, and the processor implements the steps of the method for optimizing computing resources of a multi-task container cluster according to the first aspect when executing the program.
[0045] In a fourth aspect, the present application provides a processor-readable storage medium, which stores a computer program, and the computer program is used to make the processor execute the steps of the method for optimizing computing resources of a multi-task container cluster according to the first aspect.
[0046] The method and device for optimizing computing resources of a multi-task container cluster provided by the present application can obtain a first target container on a target node based on a resource usage ratio of the target node, screen the first target container based on a resource ratio of the target node and a resource ratio of the first target container, obtain a second target container, sort the second target container in a preset order based on resource demands of all tasks in the second target container, schedule the second target container to a first target node based on a sorting result, and migrate the second target container based on a Hungarian algorithm, so that the resource utilization rate can be improved, the number of container migrations can be reduced, the cluster load can be made more balanced, and the overall operation efficiency of the system can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0047] In order to make the technical solutions in the present application or the prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0048] Figure 1 is a flowchart of the method for optimizing computing resources of a multi-task container cluster provided by the present application;
[0049] Figure 2 is a flowchart of the method for migrating the second target container based on the Hungarian algorithm provided by the present application;
[0050] Figure 3 is a scenario diagram of finding an augmented path based on the Depth-First-Search (DFS) algorithm provided by the present application;
[0051] Figure 4 is a structural diagram of the device for optimizing computing resources of a multi-task container cluster provided by the present application;
[0052] Figure 5 is a structural diagram of the electronic device provided by the present application. DETAILED DESCRIPTION
[0053] In order to make the technical solutions in the present application or the prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0054] Due to the diversity of tasks to be processed in the container, after the cluster runs for a period of time, the central processing unit (CPU) usage rate and the memory usage rate of each computing node are not balanced, resulting in the problem of inclination of computing resources.
[0055] For example, the CPU resource usage rate of a certain task to be processed on a certain computing node is very high, but the memory resource usage rate is very low, resulting in a large number of resource fragments on the computing node, and further resulting in that the remaining resources of the computing node cannot be allocated, causing great waste of computing resources of the computing node and reducing the utilization rate of resources.
[0056] The existing solutions mainly process the load imbalance of a single to-be-processed task, can effectively reduce resource fragmentation, improve resource utilization, or reduce the number of container migrations by using a traditional container migration strategy, and lack a method that can improve resource utilization while reducing the number of container migrations.
[0057] In addition, in a cloud computing environment based on a distributed framework, to-be-processed tasks carried by different containers are related or cooperative with each other, and the existing technical solutions mainly process the situation of load imbalance of a single task, and the situation of load imbalance of multiple tasks needs to be solved urgently.
[0058] In order to solve the technical problem that the resource utilization and the number of container migrations can be improved simultaneously when at least one task appears load imbalance in the related art, an embodiment of the present application provides a method for optimizing computing resources of a multi-task container cluster, Figure 1 is a flowchart of the method for optimizing computing resources of the multi-task container cluster provided by the embodiment of the present application. As shown in Figure 1 The method for optimizing computing resources of the multi-task container cluster provided by the present application comprises the following steps:
[0059] Step 100, obtaining a resource utilization rate of a target node, the target node being at least one node in the cluster.
[0060] The cluster is used to indicate at least one host that is physically centralized and uniformly managed, and each host is independent of each other but managed by a single system.
[0061] The node is used to indicate a data terminal device, for example, any host in the cluster. At least one container is deployed on the node.
[0062] The resource utilization rate is used to indicate the proportion of the used resource amount to the total resource amount of the target node.
[0063] Optionally, the resource utilization rate comprises at least one of a CPU resource utilization rate and a memory resource utilization rate.
[0064] The CPU resource utilization rate is used to indicate the proportion of the used CPU resource amount to the total CPU resource amount of the target node.
[0065] The memory resource utilization rate is used to indicate the proportion of the used memory resource amount to the total memory resource amount of the target node.
[0066] In an implementation, the total CPU resource of a certain node is R1, the total memory resource is R2, the used CPU resource is C1, the used memory resource is P1, the CPU resource requirement of a certain container is C2, the memory resource requirement is P2, and after the container is deployed on the node, the CPU resource usage of the node is the memory resource usage is
[0067] Step 101, obtaining a first target container on the target node based on the resource usage of the target node, the first target container being at least one container on the target node.
[0068] Optionally, the resource usage of the target node includes at least one of the CPU resource usage of the target node and the memory resource usage of the target node.
[0069] The obtaining of the first target container on the target node based on the resource usage of the target node specifically includes:
[0070] In a case where the CPU resource usage of the target node is less than a first preset threshold or the memory resource usage of the target node is less than the first preset threshold, the first target container on the target node is obtained.
[0071] A container is used to indicate the virtualization of an operating system layer and is a running instance of an image.
[0072] An image is a template for creating a container.
[0073] Optionally, the first preset threshold is 30%.
[0074] It should be noted that the first target container is all containers on the target node in a case where the CPU resource usage of the target node is less than the first preset threshold or the memory resource usage of the target node is less than the first preset threshold.
[0075] In an implementation, in a case where the CPU resource usage of the target node is less than 30% or the memory resource usage of the target node is less than 30%, the first target container on the target node is obtained.
[0076] Step 102, obtaining resource ratios of the target node and the first target container respectively.
[0077] The resource ratio is the ratio of the CPU resource amount and the memory resource amount.
[0078] In an implementation, the resource ratio of the target node and the resource ratio of the first target container are obtained.
[0079] Step 103, screening the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container.
[0080] Optionally, the screening of the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container specifically comprises:
[0081] In a case where the resource proportion of the target node and the resource proportion of the first target container satisfy a preset condition, the first target container is screened to obtain a second target container.
[0082] The preset condition is |I c1 / I r1 -I c2 / I r2 |>Δk, I c1 / I r1 represents the resource proportion of the target node, I c2 / I r2 represents the resource proportion of the first target container, I c1 represents the CPU resource demand of the target node, I r1 represents the memory resource demand of the target node, I c2 represents the CPU resource demand of the first target container, I r2 represents the memory resource demand of the first target container, and Δk is a second preset threshold.
[0083] The second target container is at least one container in the first target container.
[0084] It should be noted that the second target container is used for scheduling to the target node on which the container has been deployed.
[0085] In an implementation, in a case where the resource proportion of the target node and the resource proportion of the first target container satisfy a preset condition, the first target container is screened to obtain a second target container.
[0086] Further, the second target container is taken out from the target node, and the second target container is scheduled to other nodes on which the container has been deployed in the target node.
[0087] Step 104, sorting the second target container in a preset order based on resource demands of all tasks in the second target container.
[0088] The resource demand of the task is the resource amount required by a to-be-processed task, for example, CPU resource amount and memory resource amount.
[0089] The total resource requirement of all tasks is the sum of the resource requirement of each task to be processed.
[0090] It should be noted that each second target container contains a plurality of tasks to be processed.
[0091] In an embodiment, the preset order is a descending order.
[0092] In an embodiment, all second target containers are sorted in descending order according to the total resource requirement of all tasks in each second target container.
[0093] Step 105, based on the sorting result, the second target container is scheduled to the first target node, and the first target node is a node in the target node that has deployed a container.
[0094] Optionally, the second target container is scheduled to the first target node based on the sorting result, specifically comprising:
[0095] deploying the sorted second target container to each node in the target node that has deployed a container, respectively;
[0096] calculating the bias ratio of CPU resources and memory resources of each node;
[0097] selecting the node with the smallest bias ratio as the first target node;
[0098] scheduling the second target container to the first target node.
[0099] It should be noted that when all sorted second target containers are scheduled to each node in the target node that has deployed a container in descending order, each node can deploy all second target containers, or at least one node can only deploy part of the second target containers in the front of the order.
[0100] In an embodiment, the bias ratio of CPU resources and memory resources of each node represents the variance of CPU resource usage and memory usage of each node.
[0101] Further, the variance of CPU resource usage and memory usage of each node is calculated by using formulas (1)-(4):
[0102] ψ = (x-avg) 2 + (y-avg) 2 (1)
[0103] avg = (x+y) / 2 (2)
[0104]
[0105]
[0106] Wherein, ψ represents the variance of CPU resource usage and memory usage of a node, avg represents the average resource usage of a node, x represents the CPU resource usage of a node, y represents the memory resource usage of a node, C1 represents the used CPU resource amount of a node, R1 represents the total CPU resource amount of a node, C2 represents the used memory resource amount of a node, and R2 represents the total memory resource amount of a node.
[0107] In an implementation, the sorted second target container is deployed to a node in the target node that has already deployed a container as much as possible, the deviation ratio of CPU resource and memory resource of the node is calculated, the above steps are repeated for each node in the target node that has already deployed a container, and the deviation ratio of CPU resource and memory resource of each node is calculated. The deviation ratio of CPU resource and memory resource of each node is sorted in ascending order.
[0108] Further, the node ranked first is the node with the smallest deviation ratio, which is taken as the first target node, and the second target container is scheduled to the first target node.
[0109] In an implementation, if the second target container cannot be completely scheduled to the second target node, the unscheduled second target container is scheduled to the node ranked second based on the ranking result of each node until the second target container is completely scheduled.
[0110] In step 106, the second target container is migrated based on the Hungarian algorithm.
[0111] In order to further reduce the deviation ratio of CPU resource and memory resource of the node and reduce resource fragmentation, the Hungarian algorithm is introduced to determine the container migration strategy and obtain the optimal matching of container migration.
[0112] The Hungarian algorithm is a common algorithm in bipartite graph matching, and the core idea is to find an augmenting path to solve the optimal matching method of bipartite graph. The basic principle of the algorithm is to reassign based on the matching in priority order and then add new matching.
[0113] Wherein, the bipartite graph includes two vertex sets and an edge set, the vertex set includes at least one vertex, and the edge set includes a set of edges obtained by matching any vertex in the two vertex sets.
[0114] Matching is used to indicate that any two edges in the edge set do not depend on the same vertex.
[0115] The method for optimizing computing resources of a multi-task container cluster provided by the embodiment of the present application can obtain a first target container on a target node through resource usage of the target node, screen the first target container based on a resource proportion of the target node and a resource proportion of the first target container, obtain a second target container, sort the second target container in a preset order based on all task resource demands in the second target container, schedule the second target container to the first target node based on the sorting result, and migrate the second target container based on the Hungarian algorithm, so as to improve resource utilization, reduce the number of container migrations, ensure more balanced cluster load, and improve overall system operation efficiency.
[0116] Figure 2 is a flowchart of the process of migrating the second target container based on the Hungarian algorithm provided by the embodiment of the present application. As shown in Figure 2 , based on any of the above embodiments, the migrating the second target container based on the Hungarian algorithm specifically includes:
[0117] Step 200, obtaining a first container and a second container based on the second target container, the first container and the second container being any two different containers in the second target container.
[0118] It should be noted that the Hungarian algorithm is used to match any two different containers in the second target container, to obtain a plurality of matching results, and in the case of satisfying the highest task execution efficiency of the node, the least resource fragmentation, the least number of container migrations, and the smallest host CPU memory deviation ratio, a target matching result is selected from the plurality of matching results.
[0119] Step 201, matching the first container and the second container based on the Hungarian algorithm to obtain a target matching result.
[0120] Optionally, the matching the first container and the second container based on the Hungarian algorithm to obtain a target matching result specifically includes:
[0121] obtaining a first target computing task in the first container, the first target computing task being any computing task in the first container;
[0122] obtaining a second target computing task connected to the first target computing task from the second container based on a depth-first search (DFS) algorithm;
[0123] obtaining a target matching result based on the first target computing task and the second target computing task.
[0124] In combination with Figure 3 The basic principle of finding an augmented path based on the DFS algorithm is specifically described. Figure 3This is a schematic diagram of a scenario where an augmenting path is found based on the Depth-First-Search (DFS) algorithm, as provided in an embodiment of the present invention.
[0125] like Figure 3 As shown, set X includes four vertices: X1, X2, X3, and X4, and set Y includes four vertices: Y1, Y2, Y3, and Y4. A line connecting a vertex in set X to a vertex in set Y represents an augmenting path, indicating that the two vertices are matched.
[0126] The process of finding augmenting paths based on the DFS algorithm is as follows:
[0127] Step 300: Obtain an unmatched vertex X from set X. i Find the vertex X in set Y. i Matching vertex Y j .
[0128] Step 301, if Y j If not matched, then vertex X i With vertex Y j Connecting them, as an augmenting path, represents vertex X. i With vertex Y j Matching.
[0129] Step 302, if Y j If a match has been found, then retrieve the match between vertex Y and set X. j Matching vertex X m , obtain edge (X m ,Y j ), will (X m ,Y j ) changed to unmatched, (X i ,Y j If ) is set to match, then vertex X i With vertex Y j The connection is the re-found augmenting path.
[0130] Step 303: Obtain the next unmatched vertex X in set X. i+1 Repeat step 300.
[0131] Step 304: Find all augmenting paths within set X and set Y to determine the final matching result between set X and set Y.
[0132] It should be noted that the condition for the first target computing task to be connected to the second target computing task is that neither the first target computing task nor the second target computing task is occupied, and the configuration information and resource utilization of the second target computing task meet the requirements of the first target computing task.
[0133] The target matching result is used to indicate that the first container is matched with the second container in a case that a node performs a task with the highest efficiency, the least resource fragmentation, the least container migration times, and the minimum host CPU memory deviation ratio.
[0134] In an implementation, the matching process of the first container and the second container is as follows: obtaining a first target computing task that is not matched in the first container, combining the basic principle of finding an augmented path by using the DFS algorithm, obtaining a second target computing task connected with the first target computing task from the second container in a case that the target computing tasks are connected, and then obtaining that multiple target computing tasks in the first container and the second container are connected, as the matching result of the first container and the second container.
[0135] Further, based on the matching process, each two different containers in the second target container are matched to obtain multiple matching results, and in a case that a node performs a task with the highest efficiency, the least resource fragmentation, the least container migration times, and the minimum host CPU memory deviation ratio, the first container is matched with the second container from the multiple matching results, as the target matching result.
[0136] In step 202, based on the target matching result, the computing tasks in the first container and the computing tasks in the second container are migrated to each other.
[0137] It should be noted that the migration of the computing tasks in the first container and the computing tasks in the second container indicates that the computing tasks connected in the first container and the second container can be scheduled to each other.
[0138] For example, when the first target computing task in the first container and the second target computing task in the second container are migrated to each other, the second target computing task can be scheduled to the position of the first target computing task in the first container, and similarly, the first target computing task can be scheduled to the position of the second target computing task in the second container.
[0139] The method for optimizing computing resources of a multi-task container cluster provided by the embodiment of the application obtains the first container and the second container based on the second target container, matches the first container and the second container based on the Hungarian algorithm, obtains the target matching result, and migrates the computing tasks in the first container and the computing tasks in the second container to each other based on the target matching result, thereby further reducing resource fragmentation, improving resource utilization, reducing container migration times, ensuring more balanced cluster load, and improving overall system operation efficiency.
[0140] Based on any of the above embodiments, before the second target container is scheduled to the first target node based on the sorting result, the method further includes:
[0141] obtaining update information configured for the second target container;
[0142] updating the local configuration information of the second target container based on the update information.
[0143] In order to realize the container scheduling to the node and achieve the purpose of further resource allocation, the local configuration information of the second target container needs to be updated according to the update information of the second target container configuration.
[0144] The update information is used to indicate the specification of the second target container.
[0145] The local configuration information is stored in the node corresponding to the second target container.
[0146] In an embodiment, the update information of the second target container configuration is listened to by the scale-out and scale-in module, the local configuration information in the node corresponding to the second target container is updated based on the update information, and after the updating is completed, the second target container is scheduled to the first target node based on the sorting result.
[0147] The multi-task container cluster computing resource optimization method provided by the embodiment of the application obtains the update information of the second target container configuration, updates the local configuration information of the second target container based on the update information, and further realizes the further allocation of resources, so as to achieve the purposes of effectively reducing resource fragmentation, improving resource utilization, reducing the number of container migrations, ensuring that the cluster load is more balanced, and improving the overall operation efficiency of the system.
[0148] The multi-task container cluster computing resource optimization device provided by the application will be described below. The multi-task container cluster computing resource optimization device described below can be correspondingly referred to the multi-task container cluster computing resource optimization method described above.
[0149] Figure 4 is a structural schematic diagram of the multi-task container cluster computing resource optimization device provided by the embodiment of the application, as Figure 4 shown, the multi-task container cluster computing resource optimization device comprises a first acquisition unit 400, a second acquisition unit 401, a third acquisition unit 402, a screening unit 403, a sorting unit 404, a scheduling unit 405 and a migration unit 406, wherein,
[0150] The first acquisition unit 400 is configured to acquire the resource utilization of a target node, and the target node is at least one node in the cluster.
[0151] The second acquisition unit 401 is configured to acquire a first target container on the target node based on the resource utilization of the target node, and the first target container is at least one container on the target node.
[0152] The third obtaining unit 402 is configured to respectively obtain resource proportions of the target node and the first target container;
[0153] The screening unit 403 is configured to screen the first target container based on the resource proportion of the target node and the resource proportion of the first target container, to obtain a second target container;
[0154] The sorting unit 404 is configured to sort the second target container in a preset order based on resource demands of all tasks in the second target container.
[0155] The scheduling unit 405 is configured to schedule the second target container to a first target node based on a sorting result, the first target node being a node in the target nodes that has deployed a container.
[0156] The migration unit 406 is configured to migrate the second target container based on a Hungarian algorithm.
[0157] The multi-task container cluster computing resource optimization device provided by the embodiment of the application can obtain a first target container on a target node based on a resource usage rate of the target node, screen the first target container based on a resource proportion of the target node and a resource proportion of the first target container, obtain a second target container, sort the second target container in a preset order based on resource demands of all tasks in the second target container, schedule the second target container to a first target node based on a sorting result, and migrate the second target container based on a Hungarian algorithm, so that the resource utilization rate can be improved, the number of container migrations can be reduced, the cluster load can be balanced, and the overall system operation efficiency can be improved.
[0158] Optionally, the second obtaining unit 401 is further configured to:
[0159] The resource usage rate of the target node includes at least one of a central processing unit (CPU) resource usage rate of the target node and a memory resource usage rate of the target node.
[0160] The first target container on the target node is obtained based on the resource usage rate of the target node, and specifically includes:
[0161] In a case where the CPU resource usage rate of the target node is less than a first preset threshold or the memory resource usage rate of the target node is less than the first preset threshold, the first target container on the target node is obtained.
[0162] Optionally, the screening unit 403 is further configured to:
[0163] In a case where the resource proportion of the target node and the resource proportion of the first target container satisfy a preset condition, the first target container is screened to obtain the second target container.
[0164] wherein the preset condition is |I c1 / I r1 -I c2 / I r2 |>Δk, I c1 / I r1 represents the resource proportion of the target node, I c2 / I r2 represents the resource proportion of the first target container, I c1 represents the CPU resource requirement of the target node, I r1 represents the memory resource requirement of the target node, I c2 represents the CPU resource requirement of the first target container, I r2 represents the memory resource requirement of the first target container, and Δk is a second preset threshold.
[0165] Optionally, the scheduling unit 405 is further configured to:
[0166] deploy each of the sorted second target containers to each node in the target nodes that has already deployed a container;
[0167] calculate a deviation ratio of CPU resources and memory resources of each node;
[0168] select a node with the smallest deviation ratio as a first target node;
[0169] schedule the second target container to the first target node.
[0170] Optionally, the migration unit 406 is further configured to:
[0171] obtain a first container and a second container based on the second target container, the first container and the second container being any two different containers in the second target container;
[0172] match the first container and the second container based on a Hungarian algorithm to obtain a target matching result;
[0173] migrate a computing task in the first container and a computing task in the second container based on the target matching result.
[0174] Optionally, the matching the first container and the second container based on the Hungarian algorithm to obtain the target matching result specifically includes:
[0175] obtain a first target computing task in the first container, the first target computing task being any computing task in the first container;
[0176] The second target computation task, which is connected to the first target computation task, is obtained from the second container based on the depth-first search (DFS) algorithm.
[0177] Based on the first target calculation task and the second target calculation task, the target matching result is obtained.
[0178] Optionally, the computing resource optimization device for the multi-task container cluster further includes:
[0179] An update unit is used to obtain update information of the configuration of the second target container;
[0180] The local configuration information of the second target container is updated based on the updated information.
[0181] The computing resource optimization device for multi-task container clusters provided by this invention can achieve... Figures 1 to 2 The various processes implemented in the method embodiments achieve the same technical effect, and will not be described again here to avoid repetition.
[0182] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 can call a computer program in the memory 530 to execute the steps of a multi-task container cluster computing resource optimization method, such as including:
[0183] Obtain the resource utilization rate of the target node, where the target node is at least one node within the cluster;
[0184] The first target container on the target node is obtained based on the resource utilization rate of the target node. The first target container is at least one container on the target node.
[0185] Obtain the resource ratios of the target node and the first target container respectively;
[0186] Based on the resource ratio of the target node and the resource ratio of the first target container, the first target container is filtered to obtain the second target container;
[0187] Based on the resource requirements of all tasks within the second target container, the second target container is sorted in a preset order;
[0188] scheduling the second target container to a first target node based on the sorting result, the first target node being one of the target nodes in which a container has been deployed;
[0189] migrating the second target container based on the Hungarian algorithm.
[0190] In addition, the logical instructions in the memory 530 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0191] On the other hand, the present application also provides a computer program product, which comprises a computer program stored on a non-transitory computer readable storage medium, and the computer program comprises program instructions, when the program instructions are executed by a computer, the computer can execute the multi-task container cluster computing resource optimization method provided by the above-mentioned methods, and the method comprises:
[0192] obtaining resource utilization of a target node, the target node being at least one node in the cluster;
[0193] obtaining a first target container on the target node based on the resource utilization of the target node, the first target container being at least one container on the target node;
[0194] obtaining resource proportions of the target node and the first target container, respectively;
[0195] filtering the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container;
[0196] sorting the second target container in a predetermined order based on the total task resource demand amount in the second target container;
[0197] scheduling the second target container to a first target node based on the sorting result, the first target node being one of the target nodes in which a container has been deployed;
[0198] migrate the second target container based on the Hungarian algorithm.
[0199] In another aspect, the embodiments of the present application also provide a processor-readable storage medium, which stores a computer program for causing a processor to execute the method provided by the above-mentioned embodiments, for example, comprising:
[0200] obtaining a resource usage rate of a target node, the target node being at least one node in a cluster;
[0201] obtaining a first target container on the target node based on the resource usage rate of the target node, the first target container being at least one container on the target node;
[0202] obtaining a resource proportion of the target node and the first target container, respectively;
[0203] screening the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container;
[0204] ordering the second target container in a preset order based on a total amount of task resource demand in the second target container;
[0205] scheduling the second target container to a first target node based on the ordering result, the first target node being one node in the target node on which a container has been deployed;
[0206] migrate the second target container based on the Hungarian algorithm.
[0207] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to a magnetic memory (such as a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.), an optical memory (such as a CD, a DVD, a BD, a HVD, etc.), and a semiconductor memory (such as a ROM, an EPROM, an EEPROM, a non-volatile memory (NAND FLASH), a solid-state disk (SSD)), etc.
[0208] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments. Those skilled in the art can understand and implement without creative labor.
[0209] Those skilled in the art can clearly understand the technical solutions of the various embodiments from the above description of the embodiments, and the various embodiments can be implemented by means of software with the necessary general hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0210] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for optimizing computing resources of a multi-task container cluster, characterized in that, The method comprises the following steps: obtaining resource utilization of a target node, the target node being at least one node in a cluster; obtaining a first target container on the target node based on the resource utilization of the target node, the first target container being at least one container on the target node; obtaining resource proportions of the target node and the first target container respectively; screening the first target container based on the resource proportion of the target node and the resource proportion of the first target container to obtain a second target container; sorting the second target container in a preset order based on resource demands of all tasks in the second target container; scheduling the second target container to a first target node based on the sorting result, the first target node being one node in the target node on which a container has been deployed; migrating the second target container based on the Hungarian algorithm, comprising: obtaining a first container and a second container based on the second target container, the first container and the second container being any two different containers in the second target container; matching the first container and the second container based on the Hungarian algorithm to obtain a target matching result; and migrating a computing task in the first container and a computing task in the second container based on the target matching result.
2. The method of claim 1, wherein, The resource utilization of the target node comprises at least one of a central processing unit (CPU) resource utilization of the target node and a memory resource utilization of the target node. The first target container on the target node is obtained based on the resource utilization of the target node, specifically comprising: in a case where the CPU resource utilization of the target node is less than a first preset threshold or the memory resource utilization of the target node is less than the first preset threshold, the first target container on the target node is obtained.
3. The method of claim 1, wherein, The first target container is screened based on the resource proportion of the target node and the resource proportion of the first target container to obtain the second target container, specifically comprising: in a case where the resource proportion of the target node and the resource proportion of the first target container satisfy a preset condition, the first target container is screened to obtain the second target container. wherein the preset condition is |I c1 / I r1 -I c2 / I r2 |>Δk, I c1 / I r1 represents the resource proportion of the target node, I c2 / I r2 represents the resource proportion of the first target container, I c1 represents the CPU resource requirement amount of the target node, I r1 represents the memory resource requirement amount of the target node, I c2 represents the CPU resource requirement amount of the first target container, I r2 represents the memory resource requirement amount of the first target container, and Δk is a second preset threshold.
4. The method of claim 1, wherein, The second target container is scheduled to the first target node based on the sorting result, specifically comprising: the second target container after sorting is deployed to each node in the target node on which a container has been deployed; a deviation ratio of CPU resources and memory resources of each node is calculated; a node with the smallest deviation ratio is selected as the first target node; the second target container is scheduled to the first target node.
5. The method of claim 1, wherein, The first container and the second container are matched based on the Hungarian algorithm to obtain the target matching result, specifically comprising: a first target computing task in the first container is obtained, the first target computing task being any computing task in the first container; a second target computing task connected to the first target computing task is obtained from the second container based on a depth-first search (DFS) algorithm; the target matching result is obtained based on the first target computing task and the second target computing task.
6. The method of claim 1, wherein, Before the scheduling the second target container to the first target node based on the sorting result, the method further comprises: obtaining update information of the second target container configuration; updating the local configuration information of the second target container based on the update information.
7. A computing resource optimization device for a multi-task container cluster, characterized in that, The method comprises: a first obtaining unit configured to obtain resource usage of a target node, the target node being at least one node in a cluster; a second obtaining unit configured to obtain a first target container on the target node based on the resource usage of the target node, the first target container being at least one container on the target node; a third obtaining unit configured to obtain resource proportions of the target node and the first target container respectively; a screening unit configured to screen the first target container based on the resource proportion of the target node and the resource proportion of the first target container, to obtain a second target container; a sorting unit configured to sort the second target container in a preset order based on resource demands of all tasks in the second target container; a scheduling unit configured to schedule the second target container to a first target node based on a sorting result, the first target node being one node in the target node on which a container has been deployed; a migration unit configured to migrate the second target container based on a Hungarian algorithm, comprising: obtaining a first container and a second container based on the second target container, the first container and the second container being any two different containers in the second target container; matching the first container and the second container based on the Hungarian algorithm, to obtain a target matching result; and migrating computing tasks in the first container and computing tasks in the second container based on the target matching result.
8. An electronic device comprising a processor and a memory having a computer program stored therein, characterized in that, The processor executes the computer program to implement the steps of the method for optimizing computing resources of a multi-task container cluster according to any one of claims 1 to 6.
9. A processor-readable storage medium, comprising: The processor readable storage medium stores a computer program, and the computer program is configured to enable the processor to execute the steps of the method for optimizing computing resources of a multi-task container cluster according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for processing cloud platform resource fragments and related equipment
CN110474966A
Method for processing cloud platform resource fragments and related equipment
CN110493317A
Data processing method, device and system and computer readable storage medium
CN111966496A