A container resource scaling method based on real-time usage of container applications
By monitoring resource usage in real time in the container cluster and predicting demands using the secondary moving average method, and combining application priority and generational recycling algorithm for resource scheduling, the problem of low resource utilization rate of container clusters is solved, and efficient resource management and business stability are achieved.
Patent Information
- Application Number
- CN202210337837.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-01
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-04-01
AI Technical Summary
The prior art is difficult to achieve efficient utilization of resource scheduling in container clusters, especially in scenarios such as online services and deep learning. The existing solution threshold setting is subjective and affects business stability.
By laying acquisition probes in the container cluster, monitoring resource usage in real time, predicting future resource requirements using the secondary moving average method, and dynamic resource scaling is carried out according to application priorities and generational recycling algorithms to optimize resource allocation.
It has achieved the improvement of resource utilization rate of container clusters, reduced resource waste, and ensured business stability and efficient resource scheduling.
Smart Images

Figure CN114675937B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and mainly relates to a container resource scaling method based on the real-time usage of container applications. Background Art
[0002] In recent years, the growth of enterprise network system clusters and the steady increase in hardware resources have also led to increased difficulties in software operations and deployment, resulting in low system resource utilization and uneven machine usage. Container technology isolates and packages program runtime environments, facilitating the entire process of program development, rollout, testing, and maintenance. Containers can also share the host's operating system, consuming fewer resources than virtual machines. However, container deployment and resource scheduling have long been challenging research challenges in the industry. Maintaining service performance while minimizing container resource waste, rationally predicting container memory requirements, and organically allocating container resources based on these predictions have become pressing challenges.
[0003] There are currently many solutions to this problem. For example, invention CN110647392A provides an intelligent elastic scaling method based on container clusters. First, by setting elastic scaling thresholds, the maximum CPU usage, maximum memory usage, maximum disk IO, maximum network throughput, longest request response time, and maximum request rate of the target time period during container operation are determined. Then, after all containers are started, the above indicators of the containers are monitored and compared with the thresholds. When the thresholds are exceeded, deletions and additions are made directly at the container level. The above scheme can effectively schedule resources, but the threshold setting is subjective and has no clear basis. In addition, additions, deletions, modifications, and queries at the container level will affect existing businesses, especially in scenarios such as online business elasticity, large-scale computing training, deep learning GPUs, or shared GPU training and reasoning. Summary of the Invention
[0004] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a container resource scaling method based on the real-time usage of container applications, which monitors the usage of application resources in the container in real time through built-in probes.
[0005] The objective of the present invention is achieved through the following technical solution: A container resource scaling method based on the real-time usage of container applications, comprising the following specific steps:
[0006] (1) Create a container cluster and deploy collection probes to monitor the resource usage of each application in the container in real time;
[0007] (2) Determine whether the container cluster has been started and set a unified status monitoring point. The unified status monitoring point is the deployment location of the collection probe, usually a management server, data server, etc. When the collection probe detects that the container cluster has been started, it begins to monitor the resource usage of the container. The collection probe is used to collect detailed resource information within the container, namely the maximum memory usage, maximum CPU usage, maximum network throughput, and maximum hard disk usage described below.
[0008] (3) When the container cluster is running normally, the resource usage of each application within a fixed time interval is obtained, and the quadratic moving average method is used to predict the resource usage of each application in the container in the future, so as to perform dynamic resource scaling;
[0009] (4) Based on the status of each application, the application score is calculated according to the application priority, and resource reduction scheduling is performed using the generational method.
[0010] Furthermore, in step (1), the maximum memory usage, maximum CPU usage, maximum network throughput, and maximum hard disk usage of each application in the container are collected, and the recorded set is:
[0011]
[0012] in
[0013] Among them, Apst i Represents the status of application i, Represents the performance data of application i in its current state j minutes ago. max_mem is the maximum memory usage, max_cpu is the maximum CPU usage, max_netflow is the maximum network throughput, and max_diskuse is the maximum disk usage.
[0014] Furthermore, in step (3),
[0015] (3.1) P represents the current elastic scaling resource indicator, and Q represents all available resources in the current container cluster. By monitoring the resource usage of each application:
[0016]
[0017] Where n represents the total number of applications in the container;
[0018] (3.2) Let P represent the predicted performance index during the application operation process. Take the sliding window within the past j moments as the time series, and use the quadratic moving average method to calculate the actual performance index of the container application detected in the window;
[0019] is the performance data of application i in its current state j minutes ago, then the average value of the application set in the container at time j is:
[0020]
[0021] The average value sequence at time t is:
[0022] The quadratic moving average at time t is:
[0023] The predicted value at time j+t is:
[0024] in,
[0025] (3.3) When container resources need to be increased, that is, When the remaining resources meet the demand, Directly based on New resources; when the remaining resources cannot meet the increased demand, Prioritize resource reduction.
[0026] Furthermore,
[0027] (1) When container resources need to be reduced, they are reduced based on the application status in the previous j time points, and resource reduction scheduling is performed according to the application priority. By performing weighted calculations based on the application importance priority and the most recent usage time, each indicator is calculated separately. According to the priority of resource demand, applications are scheduled in sequence to reduce resource allocation. The application priority is sorted according to the application startup priority after the container is established, and the resource reduction is performed based on the application used earliest by the user.
[0028] The application score is calculated as follows:
[0029] score i ={4-max mem-maxcpu-max netflow-maxdiskuse}*(1-aplv)*(1-aptl)
[0030] Formula (7)
[0031] The score irepresents the score of application i. aplv represents the priority of the current application, which is calculated according to the Linux system PR value and normalized to 0-1. When the PR values are the same, system-started applications are weighted 0.2, and user-started applications are weighted 0.1. aptl represents the proportion of application runtime within the time period, that is, the current application's most recent runtime divided by the runtime at timej, in the range of 0-1.
[0032] (2) The resources that need to be expanded are The resources that can be released by a single application are E i , according to the above score i Release them one by one in descending order until resource requirements are met.
[0033] Furthermore, a generational recycling algorithm is used to reduce resources in memory, hard disk, and network. That is, resource blocks are classified into "new generation" and "old generation" according to the idle time after use by the process. Resource blocks with a short survival cycle are divided into the "new generation" and directly recycled using the "copy algorithm". Memory blocks with a long survival cycle are divided into the "old generation" and used using the "mark-sweep algorithm". When memory recycling occurs, it is recorded and fed back to the server in a timely manner for use as a performance indicator.
[0034] The beneficial effects of the present invention are as follows: the present invention obtains the resource usage of each application in the container by presetting probes inside the container cluster, and coordinates and schedules the container resources according to the predicted situation of the container resources, thereby solving the problem of low overall resource utilization of the cluster. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION
[0036] The present invention will be described in detail below with reference to the accompanying drawings and embodiments:
[0037] like Figure 1 As shown in the figure, a container resource scaling method based on the real-time usage of container applications is shown in the figure. The specific steps are as follows:
[0038] (1) Create a container cluster and deploy collection probes to monitor the resource usage of each application in the container in real time; collect the maximum memory usage, maximum CPU usage, maximum network throughput, and maximum hard disk usage data of each application in the container at a minute-level granularity, and the record set is:
[0039]
[0040] in
[0041] Among them, Apst i Represents the state of application i, which consists of the state set of the application in the recent period. Represents the performance data (application status) of application i in its current state j minutes ago. The application status is composed of multiple indicators. By default, j ranges from 0 to 59, with max_mem representing the maximum memory usage, max_cpu representing the maximum CPU usage, max_netflow representing the maximum network throughput, and max_diskuse representing the maximum disk usage.
[0042] (2) Determine whether the container cluster has been started and set a unified status monitoring point. The unified status monitoring point is the deployment location of the collection probe, usually a management server, data server, etc. When the collection probe detects that the container cluster has been started, it begins to monitor the resource usage of the container. The collection probe is used to collect detailed resource information within the container, namely the maximum memory usage, maximum CPU usage, maximum network throughput, and maximum hard disk usage described below.
[0043] (3) When the container cluster is running normally, the resource usage of each application within a fixed time interval is obtained, and the quadratic moving average method is used to predict the resource usage of each application in the container in the future, so as to perform dynamic resource scaling;
[0044] (3.1) P represents the current elastic scaling resource indicator, and Q represents all available resources in the current container cluster. By monitoring the resource usage of each application:
[0045]
[0046] Where n represents the total number of applications in the system;
[0047] (3.2), use This represents the predicted performance indicator during application operation. Data analysis applications are highly phased in their computation, and data closer to the current prediction time point has a greater impact. To address trends during application operation, a sliding window over the past j moments is used as the time series, and the actual performance indicators of container applications detected within the window are calculated using the quadratic moving average method.
[0048] is the performance data of application i in its current state j minutes ago, then the average value of the application set in the container at time j is:
[0049]
[0050] The average value sequence at time t is:
[0051] The quadratic moving average at time t is:
[0052] The predicted value at time j+t is:
[0053] in,
[0054] (3.3) When container resources need to be increased, that is, When the remaining resources meet the demand, Directly based on New resources, when the remaining resources cannot meet the increased demand, Prioritize resource reduction.
[0055] (4) When container resources need to be reduced, they are reduced based on the status of the application in the previous j time points of the system, and resource reduction scheduling is performed based on the priority of the application. The system performs weighted calculations based on the application importance priority and the most recent usage time, calculates each indicator separately, and schedules the application in sequence according to the priority of resource demand, reducing resource allocation. The application priority is sorted according to the application startup priority after the container is established, and the application is reduced based on the earliest use of the user.
[0056] The application score is calculated as follows:
[0057] score i ={4-max mem-maxcpu-max netflow-maxdiskuse}*(1-aplv)*(1-aptl)
[0058] Formula (7)
[0059] The score i represents the score of application i. aplv represents the priority of the current application, which is calculated according to the Linux system PR value and normalized to 0-1. When the PR values are the same, system-started applications are weighted 0.2, and user-started applications are weighted 0.1. aptl represents the proportion of application runtime within the time period, that is, the current application's most recent runtime divided by the runtime at timej, in the range of 0-1.
[0060] The resources that can be expanded as needed are The resources that can be released by a single application are E i , according to the above score i Release them one by one in descending order until resource requirements are met.
[0061] Specifically, a generational recycling algorithm is used in resources to shrink memory, hard disk, and network. That is, resource blocks are classified into "new generation" and "old generation" according to the idle time after use by the process. Resource blocks with a short survival cycle are divided into the "new generation" and directly recycled using the "copy algorithm". Memory blocks with a long survival cycle are divided into the "old generation" and used using the "mark-sweep algorithm". When memory recycling occurs, it is recorded and fed back to the server in a timely manner for use as a performance indicator.
[0062] In summary, the present invention proposes a container resource scaling method based on the real-time usage of container applications. Built-in probes are used to collect the resource usage of each application in the container in real time, making more refined predictions about the resource usage of the container in the next phase. At the same time, a priority algorithm is used during resource scaling to make resource adjustments more focused. For elastic resource scaling, "stretching" means allocating more resources, which is easy to implement. However, "scaling" is different. Even if a running application only occupies 1% of the resources, reclaiming a small portion of the remaining 99% of resources will affect the operation of the application. In other words, in the process of "scaling," some applications will inevitably be affected and stopped. The present invention calculates the priority of each application, and when releasing resources, it determines which applications will be stopped first to minimize the impact on the entire system. The present invention can solve the resource scheduling and allocation problem of container clusters and save system resources.
[0063] It is understandable that for those skilled in the art, any equivalent replacement or change to the technical solution and inventive concept of the present invention should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A container resource scaling method based on real-time container application usage, characterized by: The specific steps are as follows: (1) Create a container cluster and deploy collection probes to monitor the resource usage of each application in the container in real time; (2) Determine whether the container cluster has been started and set a unified status monitoring point; (3) When the container cluster is running normally, the resource usage of each application within a fixed time interval is obtained, and the quadratic moving average method is used to predict the resource usage of each application in the container in the future, so as to perform dynamic resource scaling; (4) Based on the status of each application, the application score is calculated according to the application priority, and resource reduction scheduling is performed using the generational method; In step (1), the maximum memory usage, maximum CPU usage, maximum network throughput, and maximum hard disk usage of each application in the container are collected, and the recorded set is: in Among them, Apst i Represents the status of application i, Represents the performance data of application i in its current state j minutes ago. max_mem is the maximum memory usage, max_cpu is the maximum CPU usage, max_netflow is the maximum network throughput, and max_diskuse is the maximum disk usage. In step (3), (3.1) P represents the current elastic scaling resource indicator, and Q represents all available resources in the current container cluster. By monitoring the resource usage of each application: Where n represents the total number of applications in the container; (3.2), use Represents the predicted performance indicators during application operation. The sliding window within the past j moments is used as the time series, and the actual performance indicators of the container application detected within the window are calculated using the quadratic moving average method; is the performance data of application i in its current state j minutes ago, then the average value of the application set in the container at time j is: The average value sequence at time t is: The quadratic moving average at time t is: The predicted value at time j+t is: in, (3.3) When container resources need to be increased, that is, When the remaining resources meet the demand, Directly based on New resources; when the remaining resources cannot meet the increased demand, Prioritize resource reduction; When container resources need to be reduced, they are reduced based on the application status at the previous j time points, and resource reduction is scheduled based on application priority. A weighted calculation is performed based on application importance and recent usage time, and each metric is calculated separately. Applications are scheduled in order based on resource demand priority, reducing resource allocation. Application priority is sorted based on the application startup priority after the container is created, and resource reduction is performed based on the application that was used earliest by the user. The application score is calculated as follows: score i ={4-max mem-max cpu-max netflow-max diskuse}*(1-aplv)*(1-aptl) The score i represents the score of application i. aplv represents the priority of the current application, which is calculated according to the Linux system PR value and normalized to 0-1. When the PR values are the same, system-started applications are weighted 0.2, and user-started applications are weighted 0.
1. aptl represents the proportion of application runtime within the time period, that is, the current application's most recent runtime divided by the runtime at timej, in the range of 0-1. The resources that can be expanded as needed are The resources that can be released by a single application are E i , according to the above score i Release them one by one in descending order until resource requirements are met.
2. The container resource scaling method based on real-time container application usage according to claim 1 is characterized in that: A generational recycling algorithm is used to reduce memory, hard disk, and network resources. Resource blocks are classified into "new generation" and "old generation" according to the length of time they remain idle after use by a process. Resource blocks with short life cycles are classified as "new generation" and directly recycled using the "copy algorithm." Memory blocks with long life cycles are classified as "old generation" and recycled using the "mark-sweep algorithm." Whenever memory recycling occurs, it is recorded and promptly fed back to the server for use as a performance indicator.
Citation Information
Patent Citations
Intelligent elastic telescoping method based on container cluster
CN110647392A
Sudden changed load oriented container cloud elastic supplying container number predication method and system thereof
CN107404409A