A method and system for dynamically adjusting container resources in a cloud environment
By dynamically adjusting container resources in a cloud computing environment, the server overload and waste problems caused by unreasonable resource configuration are solved, the rational allocation and utilization of resources are achieved, and the normal operation of servers and containers is guaranteed.
Patent Information
- Application Number
- CN202210705012.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-06-21
AI Technical Summary
In a cloud computing environment, unreasonable configuration of container resources can lead to server resource overload or resource waste, affecting the service quality of servers and containers.
By obtaining the resource usage and effective resource capacity on the server, we can determine whether there are idle resources or resource overload, migrate the container with the highest resource usage, generate a resource allocation policy, adjust the resource upper limit of the container, and reasonably allocate the server's idle resources to ensure the normal operation of the server and containers.
It effectively avoids resource waste, ensures the operating quality of servers and containers, improves resource utilization, and avoids idle waste caused by unreasonable resource allocation.
Smart Images

Figure CN114968492B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cloud computing servers, and in particular relates to a method and system for dynamically adjusting container resources in a cloud environment. Background Art
[0002] Initialization containers include Docker and K8S (Kubernetes). When allocating resources, the following problems often arise:
[0003] 1) If resource limits are not set or if too many resources are allocated, server resources will be overloaded, affecting the service quality of the server and container;
[0004] 2) When resources are allocated too little, it will lead to resource waste and affect the quality of container services. Summary of the Invention
[0005] In order to solve the problem of server overload or resource waste caused by unreasonable container resource configuration, the present invention provides a method and system for dynamically adjusting container resources in a cloud environment, including the following steps:
[0006] In a first aspect, the present disclosure provides a method for dynamically adjusting container resources in a cloud environment, comprising the steps of:
[0007] Obtain resource usage of all containers on a first server, an upper limit of effective resource capacity of the first server, and idle effective resource capacity of the first server;
[0008] Determining a total resource load on the first server based on the resource usage of all containers on the first server;
[0009] determining, based on the effective resource capacity upper limit of the first server, the total resource load, and the idle effective resource capacity, whether the first server has idle resources or a resource load overload; if the first server has idle resources, no resource allocation is required for the container; and if the first server has a resource load overload, resource allocation is required for the container;
[0010] When the first server is overloaded, traverse the resource usage of all the containers to determine the container with the highest resource usage;
[0011] Migrating the first container to a second server where idle resources are greater than those of the first container;
[0012] Generate a first resource configuration policy, and use the first resource configuration policy to perform resource configuration on the container for which no resource upper limit is set;
[0013] Calculate the sum of resource upper limits of all containers according to the resource allocation policy set of all containers;
[0014] Determine the difference between the sum of the resource upper limits of all containers and the effective resource upper limit of the first server; if the sum of the resource upper limits of all containers is greater than the effective resource upper limit of the first server, regenerate a second resource configuration policy for the container whose resource upper limit has not been adjusted and configure the container accordingly; otherwise, maintain the first resource configuration policy for the container;
[0015] Calculating the effective resources of each container, determining the effective idle resources of all containers based on the effective resources of each container, and calculating the effective idle resources of the first server that are not allocated to containers and the effective idle resources on the first server based on the effective resource upper limit of the first server and the effective idle resources of all containers;
[0016] Adjusting the resource configuration upper limit of the container according to the size of the effective idle resources of the container, and regenerating a third resource configuration policy to adjust the resources of the container;
[0017] Calculate the total amount of resources that need to be increased for all containers;
[0018] Resources are allocated to the container from the idle resources of the first server that are not allocated to the container based on the size of the idle resources of the first server that are not allocated to the container and the sum of all resources that need to be adjusted upward, and from the valid idle resources on the first server based on the size of the valid idle resources and the sum of all resources that need to be adjusted upward.
[0019] Secondly, a system for dynamically adjusting container resources in a cloud environment includes a container layer, a middleware layer, a kernel layer, and a hardware layer;
[0020] The container layer is used to set the container;
[0021] The middleware layer includes a virtualization and containerization conversion unit and a resource limit dynamic adjustment unit;
[0022] The kernel layer includes an operating system kernel and a driver module thereof;
[0023] The hardware layer includes physical servers and GPU modules;
[0024] The resource quota dynamic adjustment unit includes a resource monitoring module, a resource quota calculation module and a resource quota configuration module;
[0025] The resource monitoring module is used to periodically collect the load of the first server and the container when they are running;
[0026] The resource limit calculation module is used to calculate the real-time resource limit of the container according to the load of the container during runtime and generate a resource allocation strategy;
[0027] The resource quota configuration module is used to adjust the resource configuration of the container according to the resource configuration policy.
[0028] The beneficial effects of the present invention are as follows: when the physical server resources are sufficient, the resource requests of each container are not interfered with; when the server resources are overloaded, the operation quality of the server and container is guaranteed by migrating the container with the highest resource usage, expanding the container resources, and limiting the maximum resource usage of the server; for the situation where some containers in the physical server have insufficient resources and other containers have excess resources, the idle resources are allocated to the container with insufficient resources, solving the idle waste problem caused by unreasonable configuration of the upper limit of container resources.
[0029] On the basis of the above technical solution, the present invention can also be improved as follows.
[0030] Furthermore, the condition for the existence of idle resources in the first server is that the total resource load is less than the product of the effective resource upper limit of the first server and the server remaining resource abundance determination coefficient; the condition for the existence of resource load overload in the first server is that the total resource load is greater than the effective resource capacity upper limit of the first server.
[0031] The beneficial effect of adopting the above further solution is that it is possible to accurately determine whether there are idle resources in the first server and whether there is resource overload in the first server.
[0032] Further, generating a first resource configuration policy, and using the first resource configuration policy to configure resources for the container for which no resource upper limit is set, includes:
[0033] Traversing the resource configuration policy sets of all the containers in the first server to determine the container for which no resource upper limit is set;
[0034] Determine the proportion of the resource usage of the container without a resource upper limit to the total resource load;
[0035] The first resource configuration policy is generated according to the proportion of the resource usage of the container without setting the resource upper limit to the total resource load.
[0036] The beneficial effect of adopting the above further solution is that a first resource allocation strategy is generated according to the proportion of resource usage of containers without resource upper limits to the total resource load, which is conducive to improving resource allocation effects.
[0037] Furthermore, for the container whose resource upper limit has not been adjusted, regenerating a second resource configuration policy to configure the container includes:
[0038] Traversing the resource configuration policy sets of all the containers in the first server, and determining the containers whose resource upper limits have not been adjusted using the first resource configuration policy;
[0039] Determine the proportion of the resource usage of the container whose resource upper limit has not been adjusted to the total resource load;
[0040] A second resource configuration policy is regenerated according to the proportion of the resource usage of the container whose resource upper limit has not been adjusted to the total resource load.
[0041] The beneficial effect of adopting the above further solution is that a second resource allocation strategy is generated according to the proportion of resource usage of containers whose resource upper limits have not been adjusted to the total resource load, which is conducive to improving the resource allocation effect.
[0042] Furthermore, allocating resources to the container from the idle resources of the first server that are not allocated to the container based on the size of the sum of all resources that need to be adjusted upward and the idle resources of the first server that are not allocated to the container, and from the available idle resources of the first server based on the size of the sum of all resources that need to be adjusted upward and the available idle resources of the first server, includes:
[0043] If the idle resources in the first server that are not allocated to the container are greater than or equal to the sum of all resources that need to be increased, allocate resources from the idle resources in the first server that are not allocated to the container to the container, generate a fourth resource allocation policy, and use the fourth resource allocation policy to configure resources for the container;
[0044] If the available idle resources on the first server are greater than or equal to the sum of all resources that need to be increased, allocate resources from the available idle resources on the first server to the container, generate a fifth resource allocation policy, and use the fifth resource allocation policy to configure resources for the container;
[0045] If the effective idle resources on the first server are less than the sum of all resources that need to be increased, resources are divided from the effective idle resources on the first server to the container, a sixth resource allocation strategy is generated, and resources are allocated to the container using the sixth resource allocation strategy.
[0046] The beneficial effect of adopting the above further solution is that, based on the size of the idle resources on the first server that are not allocated to the container and the sum of all resources that need to be adjusted upward, resources are divided from the idle resources on the first server that are not allocated to the container, and based on the size of the effective idle resources on the first server and the sum of all resources that need to be adjusted upward, resources are divided from the effective idle resources on the first server to the container. This allows different resources to be added to different containers for different scenarios, thereby improving the utilization rate of effective idle resources and avoiding resource waste.
[0047] Furthermore, the container resource configuration is adjusted according to the resource configuration policy by using Cgroups to adjust the CPU, memory, and disk IO resource limits to protect the normal operation of the server; and using Open vSwitch to adjust the network bandwidth resource limit.
[0048] The beneficial effect of adopting the above further solution is that by using Cgroups to adjust the limits of CPU, memory, and disk IO resources, it is possible to limit the resources of a process or process group, and by using Open vSwitch to adjust the limits of network bandwidth resources, the efficiency of adjusting the limits of network bandwidth resources can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is a flowchart of a method for dynamically adjusting container resources in a cloud environment provided by Example 1 of the present invention;
[0050] Figure 2 This is a schematic diagram of the abstract hierarchical framework of physical server resources in a cloud environment in Example 2 of the present invention;
[0051] Figure 3 A flowchart illustrating the dynamic adjustment process of container resources. DETAILED DESCRIPTION
[0052] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0053] Example 1
[0054] As an example, as shown in the attached Figure 1 As shown, to solve the above technical problems, this embodiment provides a method for dynamically adjusting container resources in a cloud environment, including the following steps:
[0055] Obtain resource usage of all containers on the first server, an upper limit of effective resource capacity of the first server, and idle effective resource capacity of the first server;
[0056] Determining a total resource load on the first server based on resource usage of all containers on the first server;
[0057] Determine whether the first server has idle resources or resource overload based on the effective resource capacity upper limit, the total resource load, and the idle effective resource capacity of the first server; if the first server has idle resources, no resource allocation is required for the container; if the first server has resource overload, resource allocation is required for the container;
[0058] When the first server is overloaded, the resource usage of all containers is traversed to determine the first container with the highest resource usage;
[0059] Migrating the first container to a second server where idle resources are greater than those of the first container;
[0060] Generate a first resource configuration policy, and use the first resource configuration policy to configure resources for the container for which no resource upper limit is set;
[0061] Calculate the sum of all container resource limits based on the resource allocation policy set for all containers.
[0062] Determine the difference between the sum of the resource upper limits of all containers and the effective resource upper limit of the first server. If the sum of the resource upper limits of all containers is greater than the effective resource upper limit of the first server, regenerate a second resource configuration policy for the containers whose resource upper limits have not been adjusted and configure them accordingly; otherwise, the containers maintain the first resource configuration policy.
[0063] Calculate the effective resources of each container, determine the effective idle resources of all containers based on the effective resources of each container, and calculate the effective idle resources of the first server that are not allocated to the containers and the effective idle resources on the first server based on the effective resource upper limit of the first server and the effective idle resources of all containers;
[0064] Adjust the resource allocation upper limit of the container based on the size of the effective idle resources of the container, and regenerate the third resource allocation policy to adjust the resources of the container;
[0065] Calculate the total amount of resources that need to be increased for all containers;
[0066] Resources are allocated to the container from the idle resources of the first server that are not allocated to the container according to the size of the idle resources of the first server that are not allocated to the container and the sum of all resources that need to be adjusted upward, and from the valid idle resources on the first server according to the size of the valid idle resources on the first server and the sum of all resources that need to be adjusted upward.
[0067] The beneficial effects of the present invention are as follows: when the physical server resources are sufficient, the resource requests of each container are not interfered with; when the server resources are overloaded, the operation quality of the server and container is guaranteed by migrating the container with the highest resource usage, expanding the container resources, and limiting the maximum resource usage of the server; for the situation where some containers in the physical server have insufficient resources and other containers have excess resources, the idle resources are allocated to the container with insufficient resources, solving the idle waste problem caused by unreasonable configuration of the upper limit of container resources.
[0068] Optionally, the condition for the existence of idle resources on the first server is that the total resource load is less than the product of the effective resource upper limit of the first server and the server's remaining resource abundance determination coefficient; the condition for the existence of resource overload on the first server is that the total resource load is greater than the effective resource capacity upper limit of the first server.
[0069] In actual application, it is possible to accurately determine whether there are idle resources on the first server and whether there is resource overload on the first server.
[0070] Optionally, generating a first resource configuration policy and using the first resource configuration policy to configure resources for a container for which no resource upper limit is set includes:
[0071] Traversing the resource configuration policy sets of all containers in the first server to determine the containers for which resource upper limits are not set;
[0072] Determine the proportion of resource usage of containers without resource caps to the total resource load;
[0073] A first resource allocation policy is generated according to a ratio of resource usage of containers for which no resource upper limit is set to the total resource load.
[0074] In actual application, generating a first resource allocation strategy based on the proportion of resource usage of containers without resource upper limits to the total resource load is beneficial to improving resource allocation effects.
[0075] Optionally, for a container whose resource upper limit has not been adjusted, a second resource configuration policy is generated to configure the container, including:
[0076] Traversing the resource configuration policy set of all containers in the first server, and determining a container whose resource upper limit has not been adjusted using the first resource configuration policy;
[0077] Determine the proportion of resource usage of containers that have not adjusted resource caps to the total resource load;
[0078] A second resource allocation policy is regenerated based on the ratio of the resource usage of the container whose resource upper limit has not been adjusted to the total resource load.
[0079] In actual application, the second resource allocation strategy is generated according to the proportion of resource usage of containers whose resource upper limits have not been adjusted to the total resource load, which is conducive to improving the resource allocation effect.
[0080] Optionally, allocating resources to the container from the idle resources of the first server that are not allocated to the container based on the sum of the idle resources of the first server that are not allocated to the container and all the resources that need to be adjusted upward, and from the valid idle resources of the first server based on the sum of the valid idle resources of the first server and all the resources that need to be adjusted upward, includes:
[0081] If the idle resources in the first server that are not allocated to the container are greater than or equal to the sum of all resources that need to be increased, allocate resources from the idle resources in the first server that are not allocated to the container to the container, generate a fourth resource allocation policy, and use the fourth resource allocation policy to configure resources for the container;
[0082] If the available idle resources on the first server are greater than or equal to the sum of all resources that need to be increased, allocate resources from the available idle resources on the first server to the container, generate a fifth resource allocation policy, and use the fifth resource allocation policy to allocate resources to the container;
[0083] If the available idle resources on the first server are less than the sum of all resources that need to be increased, resources are divided from the available idle resources on the first server to the container, a sixth resource allocation strategy is generated, and resources are allocated to the container using the sixth resource allocation strategy.
[0084] In actual application, resources are divided to containers from the idle resources not allocated to containers on the first server according to the size of the idle resources not allocated to containers on the first server and the sum of all resources that need to be adjusted upward, and from the effective idle resources on the first server according to the size of the effective idle resources on the first server and the sum of all resources that need to be adjusted upward. This can increase different resources for different containers for different scenarios, improve the utilization rate of effective idle resources, and avoid resource waste.
[0085] In actual application, let c i Represents a container, C Total Represents all containers c running on a single server i The collection of p ci Indicates resource configuration strategy, resource configuration strategy p ci Represented by a two-tuple: p ci =(cr MiniReq ,cr Capping ) ci , among which, cr MiniReq Indicates the minimum resource requirements of the container, crCapping Indicates the upper limit of container resources and satisfies cr MiniReq ≤cr Capping ;P Total Represents container c i Resource configuration strategy collection:
[0086] P Total ={p c1 ,...,p ci ,...,p cn}={...,(cr MiniReq ,cr Capping ) ci ,...};
[0087] THR Idle Indicates the server's remaining resource abundance determination coefficient; generally, set THR Idle =0.5;THR Efficient Indicates the server's effective resource coefficient; generally, set THR Efficient =0.9;
[0088] PR Capping Indicates the upper limit of effective server resources, PR Capping =PR Physical ×THR Efficient Among them, PR Physical is the total physical resources of the server (including CPU, memory, network, disk IO, etc.); T Interval , which indicates the collection time period of the resource monitoring module.
[0089] The above process of the present invention is specifically as follows:
[0090] The set of all running containers on the first server is collected at intervals, recorded as CR ConUsage , Among them, res c1 ,...,res ci ,...,res cn is the resource usage of a single container running on the first server. Let the collection time period be T Interval , then the set C of all running containers on the first server Total In the acquisition time period T Interval The total resource load during the period is:
[0091]
[0092] If the total resource load on the first server is less than the product of the effective resource upper limit of the first server and the remaining resource abundance determination coefficient of the first server, that is: This indicates that a large amount of resources are idle, and no resource adjustment is performed on the first server;
[0093] If the total resource load on the first server is greater than the effective resource limit of the first server, that is: It means that the first server is overloaded; let the excess resource usage be CR Exceed , the excess resource usage is equal to the total resource load on the first server minus the effective resource upper limit of the first server, that is:
[0094] The total resource load CR of all containers running on the first server ConUsage , find the container with the highest resource usage and record it as the first container cj. The resource usage of the first container is res cj , directly migrate it to a server with suitable idle resources, that is, migrate the first container to the second server whose idle resources are greater than those of the first container; at this time, let the idle physical server resources be PR Available , then: PR Available =res cj -CR Exceed ;
[0095] Update the set C of all running containers on the first server Total =C Total -{cj}, and the sum of resource loads on the first server: {cj} represents the set of the first container cj; if the idle physical server resources are less than 0, that is, PR Available <0, then update the excess resource usage CR Exceed =CR Exceed -res cj Otherwise, if the idle physical server resources are greater than 0, that is: PR Available ≥0, then the resource configuration policy set P of all containers in the first server is used. Total , generating a first resource configuration policy, and using the first resource configuration policy to configure resources for containers that do not have a resource upper limit set, optionally including:
[0096] Traverse the resource configuration policy set P of all containers in the first server Total , determine the container ck,p that does not set resource caps ck satisfy Is null, null means empty, does not exist, recorded as
[0097] Determine the resource usage of the container ck without setting resource caps res ck Total resource load of the first server Proportion of:
[0098] Generate a new resource allocation strategy, recorded as the first resource allocation strategy; optional, the first resource allocation strategy:
[0099] p ck =(cr MiniReq ,Max(cr MiniReq ,PR Capping ×Wgt ck )) ck ;
[0100] Satisfy constraints
[0101] Calculate the sum of all container resource limits based on the resource allocation policy set for all containers:
[0102]
[0103] Determine the size of the sum of all container resource limits and the effective resource limit of the first server. The sum of all container resource limits is If the sum of all container resource limits is greater than the effective resource limit of the first server, that is, CRS Capping >PR Capping , then for the resource limit cr that has not been adjusted Capping If the container cq is not configured correctly, the second resource configuration policy is regenerated to configure the container; otherwise, the container maintains the first resource configuration policy;
[0104] The second resource allocation strategy is generated by: According to the ratio of the resource usage of the container that has not adjusted the resource limit to the total resource load of the first server Wgt cq , regenerate the second resource configuration strategy; optionally, the second resource configuration strategy is:
[0105]
[0106] Among them, p cq Configure the policy for the second resource, cr MiniReq is the minimum resource requirement for the container,
[0107] Calculate the effective resources (cr Available ) ci :
[0108]
[0109] According to the effective resources (cr Available ) ci Determine the effective free resources CRS for all containers Available:
[0110]
[0111] Calculate the effective idle resources PR on the first server that are not allocated to containers based on the effective resource upper limit of the first server and the effective idle resources of all containers. HostFree and the effective idle resources RS on the first server Available ;
[0112] PR HostFree =PR Capping -CRS Capping ;
[0113] RS Available =CRS Available +PR HostFree ;
[0114] For containers with idle resources, according to the size of the container's effective idle resources, if (cr Available ) ci >0, adjust the resource allocation upper limit of the container and generate a third resource allocation policy to adjust the resources of the container;
[0115] Optional, third resource allocation strategy:
[0116] p ci =(cr MiniReq ,Max(cr MiniReq ,cr Capping -(cr Available ) ci ×Wgt Available )) ci ;
[0117] For resource overloaded containers, based on the size of the container's overloaded resources, if the container ci's effective resources (cr Available ) ci <0, the upper limit of container resource configuration needs to be adjusted, and the resource amount planned for the overloaded container is increased by
[0118] Then, add different resources to different container CIs for different scenarios, including:
[0119] Calculate the total amount of resources that need to be increased for all containers
[0120] Based on the idle resources PR in the first server that are not allocated to the container HostFreeResources are allocated to the container from the idle resources on the first server that are not allocated to the container, based on the total size of all resources that need to be increased, and from the available idle resources on the first server based on the total size of all resources that need to be increased. Optionally, the first server is a host server.
[0121] Specifically, if From PR HostFree Divide resources Δcr ci Generate the fourth resource configuration policy p for container ci ci4 =(cr MiniReq ,cr Capping +Δcr ci ) ci ; Use the fourth resource allocation strategy to adjust the resources of the container; Among them, the resources provided by the idle container are not used, and the total amount of resources provided by the idle container is 0. Available The proportion is: Therefore, in the third resource allocation strategy, there is actually no need to adjust the resources of the idle containers.
[0122] like From RS Available Divide resources Δcr ci Generate the fifth resource configuration strategy for container ci: p ci5 =(cr MiniReq ,cr Capping +Δcr ci ) ci ;
[0123] Among them, PR is preferred HostFree , and the total amount of resources provided by idle containers is In CRS Available The proportion is: For containers with idle resources, according to the size of the container's effective idle resources, if (cr Available ) ci >0, adjust the resource allocation upper limit of the container and use the third resource allocation policy to adjust the resources of the container.
[0124] like From RS Available Divide resources Generate the sixth resource configuration strategy for container ci:
[0125]
[0126] RS Available The resources will be used up, where the total amount of resources provided by the idle containers is: (RS Available -PRHostFree )=CRS Available , in CRS Available The proportion is: For containers with idle resources, according to the size of the container's effective idle resources, if (cr Available ) ci >0, adjust the resource allocation upper limit of the container and use the third resource allocation policy to adjust the resources of the container.
[0127] Optionally, the resource quota configuration module issues a resource configuration policy to adjust the resources of the container ci.
[0128] Example 2
[0129] Based on the same principle as the method shown in Example 1 of the present invention, as shown in the attached Figure 2 As shown, a schematic diagram of the abstract hierarchical framework of physical server resources in a cloud environment, an embodiment of the present invention further provides a system for dynamically adjusting container resources in a cloud environment, including a container layer, a middleware layer, a kernel layer, and a hardware layer;
[0130] The container layer is used to set up the container;
[0131] The middleware layer includes a virtualization and containerization conversion unit and a resource limit dynamic adjustment unit;
[0132] The kernel layer includes the operating system kernel and its driver modules;
[0133] The hardware layer includes physical servers and GPU modules;
[0134] Resource limit dynamic adjustment unit, including resource monitoring module, resource limit calculation module and resource limit configuration module;
[0135] A resource monitoring module, configured to periodically collect the load of the first server and the container during runtime;
[0136] The resource limit calculation module is used to calculate the real-time resource limit of the container based on the load at runtime and generate the resource allocation strategy;
[0137] The resource limit configuration module is used to adjust the resource configuration of the container according to the resource configuration policy.
[0138] Optionally, container resource configuration can be adjusted based on resource allocation policies by using Cgroups to adjust CPU, memory, and disk IO resource limits, and using Open vSwitch to adjust network bandwidth resource limits.
[0139] In actual application, using Cgroups to adjust the limits of CPU, memory, and disk IO resources can limit the resources of a process or process group. Using Open vSwitch to adjust the limits of network bandwidth resources can improve the efficiency of network bandwidth resource limit adjustment.
[0140] As attached Figure 3 As shown, the process diagram of the dynamic adjustment process of container resources includes resource monitoring, policy calculation and policy configuration.
[0141] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for dynamically adjusting container resources in a cloud environment, characterized in that: Including steps: Obtain resource usage of all containers on a first server, an upper limit of effective resource capacity of the first server, and idle effective resource capacity of the first server; Determining a total resource load on the first server based on the resource usage of all containers on the first server; determining, based on the effective resource capacity upper limit of the first server, the total resource load, and the idle effective resource capacity, whether the first server has idle resources or a resource load overload; if the first server has idle resources, no resource allocation is required for the container; and if the first server has a resource load overload, resource allocation is required for the container; When the first server is overloaded, traverse the resource usage of all the containers to determine the first container with the highest resource usage; Migrating the first container to a second server where idle resources are greater than those of the first container; Generate a first resource configuration policy, and use the first resource configuration policy to perform resource configuration on the container for which no resource upper limit is set; Calculate the sum of resource upper limits of all containers according to the resource allocation policy set of all containers; Determine the difference between the sum of the resource upper limits of all containers and the effective resource upper limit of the first server; if the sum of the resource upper limits of all containers is greater than the effective resource upper limit of the first server, generate a second resource allocation policy for the container whose resource upper limit has not been adjusted and configure the container; otherwise, the container maintains the first resource allocation policy; Calculating the effective resources of each container, determining the effective idle resources of all containers based on the effective resources of each container, and calculating the effective idle resources of the first server that are not allocated to containers and the effective idle resources on the first server based on the effective resource upper limit of the first server and the effective idle resources of all containers; Adjusting the resource configuration upper limit of the container according to the size of the effective idle resources of the container, and regenerating a third resource configuration policy to adjust the resources of the container; Calculate the total amount of resources that need to be increased for all containers; Resources are allocated to the container from the idle resources of the first server that are not allocated to the container based on the size of the idle resources of the first server that are not allocated to the container and the sum of all resources that need to be adjusted upward, and from the valid idle resources on the first server based on the size of the valid idle resources and the sum of all resources that need to be adjusted upward.
2. According to the method for dynamically adjusting container resources in a cloud environment in claim 1, it is characterized in that: The condition for the existence of idle resources on the first server is that the total resource load is less than the product of the effective resource upper limit of the first server and the server remaining resource abundance determination coefficient; the condition for the existence of resource load overload on the first server is that the total resource load is greater than the effective resource capacity upper limit of the first server.
3. The method for dynamically adjusting container resources in a cloud environment according to claim 1, characterized in that: Generating a first resource configuration policy, and using the first resource configuration policy to perform resource configuration on the container for which no resource upper limit is set, includes: Traversing the resource configuration policy sets of all the containers in the first server to determine the container for which no resource upper limit is set; Determine the proportion of the resource usage of the container without a resource upper limit to the total resource load; The first resource configuration policy is generated according to the proportion of the resource usage of the container without setting the resource upper limit to the total resource load.
4. The method for dynamically adjusting container resources in a cloud environment according to claim 1, characterized in that: For the container whose resource upper limit has not been adjusted, generating a second resource configuration policy to configure the container, including: Traversing the resource configuration policy sets of all the containers in the first server, and determining the containers whose resource upper limits have not been adjusted using the first resource configuration policy; Determine the proportion of the resource usage of the container whose resource upper limit has not been adjusted to the total resource load; A second resource configuration strategy is regenerated according to the proportion of the resource usage of the container whose resource upper limit has not been adjusted to the total resource load.
5. The method for dynamically adjusting container resources in a cloud environment according to claim 1, characterized in that: Allocating resources to the container from the idle resources of the first server that are not allocated to the container according to the sum of the idle resources of the first server that are not allocated to the container and the sum of all resources that need to be adjusted upward, and from the effective idle resources on the first server according to the sum of the effective idle resources on the first server and the sum of all resources that need to be adjusted upward, including: If the idle resources in the first server that are not allocated to the container are greater than or equal to the sum of all resources that need to be increased, allocate resources from the idle resources in the first server that are not allocated to the container to the container, generate a fourth resource allocation policy, and use the fourth resource allocation policy to configure resources for the container; If the available idle resources on the first server are greater than or equal to the sum of all resources that need to be increased, allocate resources from the available idle resources on the first server to the container, generate a fifth resource allocation policy, and use the fifth resource allocation policy to configure resources for the container; If the effective idle resources on the first server are less than the sum of all resources that need to be increased, resources are divided from the effective idle resources on the first server to the container, a sixth resource allocation strategy is generated, and resources are allocated to the container using the sixth resource allocation strategy.
6. A system for dynamically adjusting container resources in a cloud environment based on the method for dynamically adjusting container resources in a cloud environment according to claim 1, characterized in that: Includes container layer, middleware layer, kernel layer and hardware layer; The container layer is used to set the container; The middleware layer includes a virtualization and containerization conversion unit and a resource limit dynamic adjustment unit; The kernel layer includes an operating system kernel and a driver module thereof; The hardware layer includes physical servers and GPU modules; The resource quota dynamic adjustment unit includes a resource monitoring module, a resource quota calculation module and a resource quota configuration module; The resource monitoring module is used to periodically collect the load of the first server and the container when they are running; The resource limit calculation module is used to calculate the real-time resource limit of the container according to the load of the container during runtime and generate a resource allocation strategy; The resource quota configuration module is used to adjust the resource configuration of the container according to the resource configuration policy.
7. The system for dynamically adjusting container resources in a cloud environment according to claim 6, characterized in that: The method of adjusting the container resource configuration according to the resource configuration policy is to use Cgroups to adjust the limits of CPU, memory, and disk IO resources, and use Open vSwitch to adjust the limits of network bandwidth resources.
Citation Information
Patent Citations
A method and apparatus for managing resources in a cloud data system
CN109144727A
Open and universal intelligent satellite software system architecture
CN111813561A