A cloud platform container downgrading method, device, system and storage medium

By obtaining and analyzing the historical and real-time load data of the container, determining whether the container needs to be down-regulated, and rolling back the quota when an exception occurs, the complex problem of container down-regulated methods in the existing technology is solved, and the accuracy and efficiency of down-regulated are improved.

CN112162827BActive Publication Date: 2025-04-04TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011124014.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-20
Publication Date
2025-04-04
Estimated Expiration
2040-10-20

AI Technical Summary

Technical Problem

In the prior art, the container downloading method is complex and has a high loading degree. The analysis data is not easy to be used directly to determine whether the downloading is allowed, resulting in the urgent need for a simple and effective container downloading method.

Method used

By acquiring the historical load data of at least one container and the load data of the same day, it is analyzed whether the container needs to be down-allocated, and the preset parameters of the container are adjusted from the first quota to the second quota to achieve down-allocated. When an exception condition occurs, roll back to the first quota.

Benefits of technology

It improves the accuracy and efficiency of container down-loading, combines historical and real-time load data for analysis, ensures the improvement of container resource utilization, and at the same time, the quota can be rolled back when abnormalities occur to ensure the normal operation of the container.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112162827B_ABST
    Figure CN112162827B_ABST
Patent Text Reader

Abstract

The present invention provides a method for downgrading cloud platform containers, including: obtaining historical load data and current day load data of at least one container; analyzing whether to downgrade the container based on the historical load data and current day load data of any container; adjusting the preset parameters of the container from the first quota to the second quota based on the determination of downgrading the container, so as to achieve downgrading the container, the second quota value is less than the first quota; and rolling back the preset parameters of the container from the second quota to the first quota based on satisfying a preset abnormal condition. In this solution, based on the historical load data and current day load data of the container, it is analyzed to determine whether to downgrade the container, combining the historical situation and the current day load situation, the accuracy of the analysis is higher, and, when an abnormality occurs, the preset parameters of the container can also be rolled back to achieve restoration of the container quota to ensure that the container can operate normally.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of container cloud technology, and more specifically, to a cloud platform container downgrading method, device, system and storage medium. Background Art

[0002] Container cloud is an emerging product form in cloud computing technology. In terms of computing form, container is a lightweight virtualization technology. It is a lightweight, portable, self-contained software packaging technology that enables applications to run in the same way almost anywhere.

[0003] The load of a container affects its use of physical resources, and quota reduction (downgrading) is to modify the cgroup (control groups) configuration to which the container belongs, thereby reducing the upper limit of physical resources that the container can use. Therefore, downgrading the container is essential in the process of container application.

[0004] In the prior art, the method of downgrading a container is a method of evaluating future loads. For example, relevant time series prediction algorithms such as AR (Auto Regressive Model) and MA (Moving Average Model) are used to predict future loads based on historical complex sample points to determine whether downgrading is required. Among them, the AR model is a statistical method for processing time series. It uses several sampling points before the current time of container X, that is, X1 to Xt-1 to predict the current load Xt. In the MA model, it is believed that the current load value is explained by giving different weights to random values ​​in the past, and the random values ​​and weights are obtained through data training. The AR and MA algorithms have high load levels, and the data obtained by analysis is not easy to be used directly to determine whether downgrading is allowed. Therefore, a simple and effective container downgrading method is urgently needed. Summary of the invention

[0005] In view of this, the present invention provides a cloud platform container downsizing method to overcome the problem of complex container downsizing methods in the prior art.

[0006] To achieve the above object, the present invention provides the following technical solutions:

[0007] A cloud platform container downgrading method, comprising:

[0008] Obtain historical load data and current load data of at least one container;

[0009] Based on the historical load data and the current load data of any container, analyzing whether to downgrade the configuration of the container;

[0010] Based on the determination of downgrading the container, adjusting a preset parameter of the container from a first quota to a second quota to achieve downgrading the container, wherein the value of the second quota is less than the first quota;

[0011] Based on satisfying a preset abnormal condition, the preset parameters of the container are rolled back from the second quota to the first quota.

[0012] A cloud platform container downgrading device, comprising:

[0013] An acquisition module, used for acquiring historical load data and current load data of at least one container;

[0014] An analysis module, configured to analyze whether to downgrade the configuration of any container based on the historical load data and the current load data of the container;

[0015] a downgrading module, configured to adjust a preset parameter of the container from a first quota to a second quota based on determining that the container is downgraded, so as to achieve downgrading of the container, wherein the value of the second quota is less than the first quota;

[0016] The rollback module is used to roll back the preset parameters of the container from the second quota to the first quota based on satisfying a preset abnormal condition.

[0017] A cloud platform container downgrading system, comprising: a host machine and a processor;

[0018] Wherein, the host machine is provided with a management agent unit and at least one container;

[0019] The processor includes: a load statistics summary service unit, a load analysis unit, a database and a scheduling decision service unit;

[0020] The management agent unit is used to obtain the real-time load data of each container on the host machine to which it belongs, and report it to the load statistics summary service unit;

[0021] The load statistics summary service unit is used to calculate the load data of the container according to a preset calculation period to obtain the load data of the container on the same day, and store it in the database;

[0022] The scheduling decision service unit is used to analyze whether to downgrade the container based on the current day load data and historical load data in the database. When it is determined that the container is downgraded, the preset parameters of the container are adjusted from the first quota to the second quota to achieve the downgrade of the container, and the value of the second quota is less than the first quota; based on meeting the preset abnormal conditions, the preset parameters of the container are rolled back from the second quota to the first quota.

[0023] A computer-readable storage medium includes instructions, wherein when the instructions are executed on a computer device, the computer device executes any one of the methods described above.

[0024] Through the above technical solutions, it can be known that compared with the prior art, the present invention provides a method for downgrading cloud platform containers, including: obtaining historical load data and current day load data of at least one container; analyzing whether to downgrade the container based on the historical load data and current day load data of any container; adjusting the preset parameters of the container from the first quota to the second quota based on the determination of downgrading the container, so as to achieve downgrading the container, the second quota value is less than the first quota; based on satisfying the preset abnormal conditions, rolling back the preset parameters of the container from the second quota to the first quota. In this solution, based on the historical load data and current day load data of the container, it is analyzed to determine whether to downgrade the container, combining the historical situation and the current day load situation, the accuracy of the analysis is higher, and, when an abnormality occurs, the preset parameters of the container can also be rolled back to achieve the restoration of the quota of the container and ensure the normal operation of the container. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0026] Figure 1 A schematic diagram of the structure of a cloud platform container downsizing system provided by an embodiment of the present invention;

[0027] Figure 2 A flowchart of a cloud platform container downgrading method provided in Example 1 of the present invention;

[0028] Figure 3 A flowchart of the steps of obtaining the daily load data of a container provided in Example 1 of the present invention;

[0029] Figure 4 A flow chart of the cloud platform container downgrading method provided in Embodiment 2 of the present invention;

[0030] Figure 5 Another flow chart of the cloud platform container downgrading method provided in Embodiment 2 of the present invention;

[0031] Figure 6 A structural block diagram of a cloud platform container downsizing device provided by an embodiment of the present invention;

[0032] Figure 7 A schematic diagram of the software architecture for implementing the cloud platform container downsizing system provided by an embodiment of the present invention;

[0033] Figure 8 A hardware structure block diagram of a cloud platform container downsizing device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in 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. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] Figure 1 Schematic diagram of the architecture of the cloud platform container downsizing system provided by an embodiment of the present invention. The cloud platform container downsizing method provided by an embodiment of the present invention can be implemented by the cloud platform container downsizing system; Figure 1 , the cloud platform container downsizing system may include: a host machine 10 and a processor 20.

[0036] Among them, at least one container and a management agent unit (node ​​agent, specifically a process deployed on each host machine for managing containers) are set in the host machine.

[0037] There may be multiple host machines in the system.

[0038] The processor specifically executes the cloud platform container downgrading method in the present invention.

[0039] The management agent unit collects the load data of the container in the host machine to which it belongs, and uploads the load data to the processor for processing.

[0040] based on Figure 1 The cloud platform container downgrade system shown, Figure 2 A flowchart of the cloud platform container downsizing method provided in Example 1 of the present invention is shown, referring to Figure 2 , the process may include:

[0041] Step S10: Obtain historical load data and current load data of at least one container;

[0042] The cloud platform in the present invention involves multiple host machines, and multiple containers can be set in each host machine.

[0043] The load data of each container on each host in the cloud platform is obtained, and the load data includes historical load data and current day load data.

[0044] The historical load data represents the historical load status of the container, and the current day load data represents the current day load status of the container.

[0045] The load data includes container CPU (central processing unit) load data and container memory load data. Moreover, the container CPU load data includes CPU usage and CPU limitation rate. The container memory load data is reflected by memory usage.

[0046] The specific process of obtaining the load data for the day will be described in the subsequent embodiments, which will not be described in detail in this embodiment.

[0047] The historical load data may be load data of the previous several days, such as 7 days, 10 days, 15 days or other values. The specific number of days of the historical load data may be set according to actual conditions and is not limited in the embodiments of the present invention.

[0048] Specifically, a database is provided in the cloud platform, and the daily load data of each container involved in the cloud platform is uploaded to the database for storage.

[0049] The step of obtaining historical load data of at least one container includes:

[0050] Obtain the peak-mean value of the container in the most recent preset days from a preset database,

[0051] The peak-to-average value is an average value of a preset number of load data items ranked from high to low in any one day.

[0052] In a specific implementation, the management process node agent set on the host machine performs sampling according to the sampling period, collects the load data of the container and reports it to the cloud platform.

[0053] Specifically, the peak-to-average value is an average value calculated for several points with the highest load on the container in a day.

[0054] For example, the peak-to-average value is the average of the 10 points with the highest load throughout the day. The number of the highest loads can be set according to actual conditions.

[0055] In the specific implementation, the peak average value of the load for the day is calculated every day and recorded in the database according to time for reference when downgrading the container.

[0056] Step S20: Based on the historical load data and the current load data of any container, analyzing whether to downgrade the configuration of the container;

[0057] When determining whether a container needs to be downgraded, the historical load data of the container and the load data of the day are analyzed and determined.

[0058] Specifically, based on the comparison result of the average load peak of the container CPU load in the historical load data of the container with the quota, the CPU limitation rate, and the comparison result of the peak-average value of the load data of the day with the quota, when both meet specific conditions, it is determined to reduce the CPU quota.

[0059] Specifically, based on the comparison result of the peak-average value of the memory load in the historical load data of the container with the quota, combined with the comparison result of the peak-average value of the load on the day with the quota, when both meet specific conditions, it is determined to reduce the memory quota.

[0060] Step S30: Based on the determination that the configuration of the container is to be downgraded, adjusting the preset parameters of the container from the first quota to the second quota to achieve the downgrade of the container;

[0061] The second quota value is smaller than the first quota value.

[0062] Specifically, when it is determined to downgrade the configuration of a container, the quota of the container is adjusted downward based on a preset adjustment rule.

[0063] The adjustment rule may specifically be a reduction ratio or a specific reduction value.

[0064] In specific implementation, the quota of the container can be gradually reduced according to the actual situation, such as reducing it once a day to achieve a gradual and stable reduction. The quota of the container can also be directly reduced by a larger value. If an abnormal situation caused by the reduction occurs the next day, the quota of the container will be rolled back.

[0065] Among them, the cloud platform has quota adjustment values ​​set, such as 10%, 18%, 20%, 25%, etc., 1 CPU core, 1000MB (MByte), 0.8 CPU core, 800MB, etc., which can be set according to actual conditions.

[0066] As a specific example, when analysis shows that the peak and average values ​​of the container CPU load in the previous 7 days are both lower than 45% of the quota, and the restriction rate is lower than 10%, and the peak and average values ​​of today's load data are also lower than 45% and 10%, try to reduce the CPU quota by 20%.

[0067] As a specific example, when the analysis shows that the peak-average load of the container memory load in the previous 15 days is less than 50% of the quota, and the peak-average load today is also less than 50%, try to reduce the memory quota by 20%.

[0068] In the specific implementation, the container load reduction operation is performed once a day. When the peak-average load of the container CPU and the peak-average load of the container memory continue to be very low, the quota will be continuously reduced until the load is no longer lower than the threshold after the reduction.

[0069] For example, if the user configures a quota of 1.5 CPU cores and 1000MB, it will be reduced to 1 core and 800MB after one downgrade. If the load is still low, it will be reduced to 0.64 cores and 640MB until the container load analyzed on the day is no longer lower than the quota.

[0070] Step S40: based on satisfying a preset abnormal condition, rolling back the preset parameters of the container from the second quota to the first quota.

[0071] Specifically, after the container is downgraded, the running state of the container becomes abnormal due to the downgrade. Therefore, the running state of the container is detected. When the abnormal conditions are met, the quota of the container is rolled back to restore the quota before the downgrade. The purpose is to prevent the downgrade from causing abnormal operation of the container and ensure the normal operation of the container.

[0072] Specifically, the judgment of whether the abnormal condition is met is described in detail in the subsequent embodiments, which will not be described in detail in this embodiment.

[0073] It should be noted that, in a specific implementation, step S40 is not a necessary step for each downgrade. If, after the container is downgraded, no abnormal condition that meets the preset conditions occurs during operation, normal operation is sufficient and step S40 will not occur.

[0074] In this solution, the resource utilization efficiency of the container can be improved by downgrading the container to a low load. On the one hand, when the utilization rate of the physical resources of the container is improved, it can save the cost of service deployment for users. On the other hand, when the load level of all containers on the platform is improved, the resource utilization efficiency of the entire platform will also be improved, making the platform's resources run efficiently.

[0075] In summary, a cloud platform container downgrading method provided by an embodiment of the present invention includes: obtaining historical load data and current day load data of at least one container; analyzing whether to downgrade the container based on the historical load data and current day load data of any container; adjusting the preset parameters of the container from the first quota to the second quota based on the determination of downgrading the container, so as to achieve downgrading the container, the second quota value is less than the first quota; and rolling back the preset parameters of the container from the second quota to the first quota based on satisfying a preset abnormal condition. In this solution, based on the historical load data and current day load data of the container, it is analyzed to determine whether to downgrade the container. The historical situation and the current day load situation are combined, and the accuracy of the analysis is higher. Moreover, when an abnormality occurs, the preset parameters of the container can also be rolled back to achieve the restoration of the quota of the container and ensure the normal operation of the container.

[0076] Figure 3 A flow chart of obtaining the daily load data of a container in Embodiment 1 of the present invention is shown.

[0077] The step of obtaining the load data of at least one container on the same day includes:

[0078] Get the memory load data and CPU load data of at least one container on the current day.

[0079] The load data includes container memory load data and container CPU load data. In this embodiment, the current load data of the container is determined by the container memory load data and the container CPU load data.

[0080] In the present invention, the memory load data is represented by memory usage, and the container CPU load data includes CPU usage and restriction rate.

[0081] Specifically, refer to Figure 3 , the process may include:

[0082] Among them, steps S1011-1013 in (A) are the process of obtaining the memory load data of the container on the day, steps S1014-1016 in (B) are the process of obtaining the CPU usage rate of the container on the day, and steps S1017-1019 in (C) are the process of obtaining the CPU restriction rate of the container on the day. The three processes can be implemented simultaneously in the specific implementation.

[0083] Step S1011: Obtain the memory quota value of the container and the memory usage value of any cycle;

[0084] The memory quota value is the memory quota assigned to the container when the quota was last adjusted, and the memory usage value is the value of the memory used by the container on that day.

[0085] In a specific implementation, the memory usage value is collected based on a preset collection cycle. A day includes several collection cycles, and the memory usage value is the memory usage value collected in any cycle of the day.

[0086] In a specific implementation, the value in the memory.limit_in_bytes file (a file used to record the limited memory quota value) under the cgroup (control group, control group in Linux) to which the container belongs is obtained. This value is the memory quota value, which is represented by mem_byte in this embodiment; the value of the total_rss parameter item (the amount of resident memory used by the container, in bytes) in the memory.stat file (a file used to record the current memory usage of the container) under the cgroup to which the container belongs is obtained. This value is the memory usage value, which is represented by rss_mem in this embodiment.

[0087] Since the quota is a fixed value, the memory quota value only needs to be obtained once a day, and based on the collection cycle, the memory usage value is collected according to the collection cycle.

[0088] It should be noted that the value of the total_rss item in the memory.stat file is an absolute value, that is, as the container runs, the value of the total_rss item is accumulated, and this value represents the usage of the container memory.

[0089] Step S1012: Calculate the memory usage rate of any cycle based on the ratio of the memory usage value to the memory quota value;

[0090] The memory usage value indicates the memory usage in the current calculation cycle, and the memory quota value indicates the memory quota for the container. The ratio of the two is the memory usage rate of the container in the current cycle.

[0091] Specifically, the memory usage rate = memory usage value / memory quota value

[0092] That is, the memory usage = rss_mem / mem_byte

[0093] In a specific implementation, sampling can be performed according to a preset sampling period. In order to reduce the amount of data processing, a larger calculation period can be used to calculate the load of the container, and the load data with the largest sampling value in the calculation period is used as the basis for calculating the load.

[0094] For example, the sampling period is 15 seconds and the calculation period is 1 minute. The node agent performs sampling every 15 seconds and takes the maximum sampling value within one minute as the load of the container for that minute. The load for that minute is used to calculate the memory usage, CPU usage, and restriction rate.

[0095] Step S1013: Calculate the peak-average value of the container memory load based on the memory usage rate of each cycle of the day;

[0096] Specifically, the memory usage rates of several cycles in each day are sorted, a preset number of memory usage rates are selected from large to small, and the average value is calculated to obtain the peak average value of the load of the container memory.

[0097] The peak-average value of the container's memory load represents the upper limit of the container's memory demand in a day.

[0098] Step S1014: based on the preset collection cycle of the day, respectively obtain the time slice value of the CPU;

[0099] The time slice value of the CPU is an absolute value, which increases with the CPU usage time.

[0100] Specifically, the time slice value collected in the previous cycle represents the time slice of the CPU at the sampling moment of the cycle, and the time slice value collected in the next cycle represents the time slice of the CPU at the sampling moment of the cycle. The difference between the two represents the increment of the CPU time slice in one cycle.

[0101] Specifically, the CPU time slice value can be obtained by obtaining the value in the cpuacct.usage file under the cgroup to which the container belongs (a report automatically generated by the cpuacct subsystem (CPU accounting), which displays the CPU resources used by tasks in the cgroup).

[0102] Step S1015: Calculate the CPU usage rate of any collection period based on the difference of the collected time slice values, the collection period duration, and the current CPU quota of the container;

[0103] The difference between the time slice values ​​obtained from two consecutive collections represents the increment of the CPU time slice in a cycle, that is, the usage. The CPU usage in the collection cycle is calculated based on the duration of the collection cycle and the current quota of the container CPU.

[0104] Specifically, obtain the value in the cpuacct.usage file under the cgroup to which the container belongs as the start time. In this embodiment, u_start is used to represent the start time. Obtain the duration of the sampling period, such as the agent sleeping for 15 seconds (1.5*10^10 nanoseconds). Obtain the value in the cpuacct.usage file again as the end time. In this embodiment, u_end is used to represent the end time. Then use the following formula to calculate the CPU usage in the sampling period:

[0105] 15-second CPU usage = (u_end-u_start) / (1.5*10^10)*container cpu quota

[0106] Step S1016: Calculate the peak-average value of the container CPU load based on the CPU usage rate in each cycle of the day;

[0107] Among them, a day contains several cycles. Based on the CPU usage of each cycle, the CPU usage is sorted according to the size of the value, and a preset number of CPU usages are selected from large to small and the average value is calculated to obtain the peak average value of the CPU load of the container.

[0108] In a specific implementation, sampling can be performed according to a preset sampling period. In order to reduce the amount of data processing, a larger calculation period can be used to calculate the load of the container, and the load data with the largest sampling value in the calculation period is used as the basis for calculating the load.

[0109] In this embodiment of the present invention, the CPU load data includes a usage rate and a restriction rate. Steps S1013-1014 are the process of obtaining the usage rate of the container CPU on that day, and steps S1015-1016 are the process of obtaining the restriction rate of the container CPU on that day.

[0110] Step S1017: Obtain the number of times the CPU is limited and the number of times of sampling within a preset period;

[0111] The CPU limitation indicates the conflict between the container's demand for CPU usage and the CPU quota, specifically, the container's demand for CPU usage is greater than the CPU quota. The number of limitations is the number of times the CPU demand is greater than the CPU quota within a preset period.

[0112] In specific implementation, during the operation of the container, the CPU demand changes according to the real-time situation of the program. For example, if the CPU demand is 1 core and the CPU quota is 0.8 cores, the CPU is restricted. At this time, the number of CPU restrictions is increased by 1.

[0113] Specifically, the values ​​of the nr_periods parameter (characterizing the number of CPU restrictions) and the nr_throttled parameter (number of samplings) in the cpu.stat file under the cgroup to which the container belongs are obtained as the starting values. In this embodiment, p_start and th_start are respectively used as the starting values ​​of the CPU restrictions and the starting values ​​of the sampling times. In the next collection cycle, the values ​​of nr_periods and nr_throttled are obtained again as the ending values. In this embodiment, p_end and th_end are respectively used as the ending values ​​of the CPU restrictions and the sampling times.

[0114] In specific implementation, the CPU time slice value, limited number of times, and sampling number of times are recorded in the cgroup file system. The general file path is / sys / fs / cgroup / cpu / container_id / . The above values ​​can be obtained by reading the file, for example, / sys / fs / cgroup / cpu / kubepods / container_id / cpu.stat.

[0115] Step S1018: Calculate the CPU restriction rate in any period based on the ratio of the CPU restriction times to the sampling times;

[0116] The CPU limitation rate represents the CPU limitation of the container within a preset time period, and is obtained based on the ratio of the number of limitations to the number of sampling times.

[0117] The following formula is used to calculate the CPU limitation rate in the sampling period:

[0118] CPU limitation rate = (th_end-th_start) / (p_end-p_start)

[0119] In a specific implementation, sampling can be performed according to a preset sampling period. In order to reduce the amount of data processing, a larger calculation period can be used to calculate the load of the container, and the load data with the largest sampling value in the calculation period is used as the basis for calculating the load.

[0120] The CPU limit rate is used to determine whether to roll back, which will be described in detail in subsequent embodiments and will not be described in detail in this embodiment.

[0121] In a specific implementation, the CPU limiting rate may not be uploaded to the database for storage.

[0122] Specifically, the CPU usage rates of several cycles in a day are sorted, a preset number of CPU usage rates are selected from large to small, and the average value is calculated to obtain the peak average value of the CPU load of the container.

[0123] The peak-average value of the container's CPU load represents the upper limit of the container's memory demand in a day.

[0124] In a specific implementation, sampling can be performed according to a preset sampling period. In order to reduce the amount of data processing, a larger calculation period can be used to calculate the load of the container, and the load data with the largest sampling value in the calculation period is used as the basis for calculating the load.

[0125] It should be noted that, in the embodiment of the present invention, there is no restriction on the order of calculating the CPU usage rate and the limiting rate. The two can be performed in any order or simultaneously.

[0126] It should be noted that, in the embodiment of the present invention, there is no restriction on the order of obtaining the memory load data and obtaining the CPU load data of the container, and the two can be performed in any order or simultaneously.

[0127] It should be noted that the historical load data in the database is obtained from the peak-average load values ​​stored in the database by obtaining the load data of the day using the above process every day and uploading the peak-average load values ​​to the server.

[0128] Figure 4 A flow chart of the cloud platform container downgrading method provided in Example 2 of the present invention is shown, referring to Figure 4 , the process may include:

[0129] Step S10: Obtain historical load data and current load data of at least one container;

[0130] Step S20: Based on the historical load data and the current load data of any container, analyzing whether to downgrade the configuration of the container;

[0131] Step S30: Based on the determination that the configuration of the container is to be downgraded, adjusting the preset parameters of the container from the first quota to the second quota to achieve the downgrade of the container;

[0132] Among them, step S10-30 is consistent with the corresponding step in Example 1 and is not described in detail in this embodiment.

[0133] Step S401: based on the fact that the growth value of the CPU limit rate within a preset time period exceeds a preset threshold, it is determined that a preset abnormal condition is met, and the preset parameters of the container are rolled back from the second quota to the first quota.

[0134] Among them, the calculation method of the CPU limitation rate can refer to steps S1017-1018.

[0135] Specifically, the node agent obtains the number of restrictions and sampling times and uploads them to the cloud platform. After the cloud platform calculates the CPU restriction rate, it compares it with the restriction rate of the previous calculation cycle. If the CPU restriction rate growth value exceeds the preset threshold, it indicates that the current downgrade has caused the container to run abnormally. Therefore, the container needs to be rolled back to resolve the exception.

[0136] For example, two CPU limit rates are compared and if it is determined that the CPU limit rate has increased by more than 50%, the quota of the container is controlled to be rolled back.

[0137] Among them, the preset time period represents the validity period of the judgment, such as 2 days, 7 days, 30 hours, etc., which can be set according to actual conditions. Within the preset time period, as long as the CPU limitation rate growth value exceeds the preset threshold, it is determined that the preset abnormal condition is met.

[0138] The step of rolling back the preset parameters of the container from the second quota to the first quota specifically includes: determining the first quota required for rollback based on the time point when the preset parameters of the container are adjusted from the first quota to the second quota; and adjusting the preset parameters of the container based on the first quota.

[0139] Specifically, when downgrading a container, the time point of the downgrade is recorded. Once an abnormal restriction rate occurs within the preset time period of the downgrade (the restriction rate growth value exceeds the preset threshold), the first quota corresponding to the downgrade time point is immediately determined, and the preset parameters of the container are adjusted based on the first quota to achieve rollback.

[0140] Figure 5 Another flow chart of the cloud platform container downsizing method provided in Embodiment 2 of the present invention is shown, referring to Figure 5 , the process may include:

[0141] Step S10: Obtain historical load data and current load data of at least one container;

[0142] Step S20: Based on the historical load data and the current load data of any container, analyzing whether to downgrade the configuration of the container;

[0143] Step S30: Based on the determination that the configuration of the container is to be downgraded, adjusting the preset parameters of the container from the first quota to the second quota to achieve the downgrade of the container;

[0144] Among them, step S10-30 is consistent with the corresponding step in Example 1 and is not described in detail in this embodiment.

[0145] Step S402: Based on the occurrence of an OMM event in which a memory leak occurs in the container and causes abnormal program operation, it is determined that a preset abnormal condition is met, and the preset parameters of the container are rolled back from the second quota to the first quota.

[0146] When an OOM occurs in a container, a log is written to the log file. The log contains the time, container name, and memory usage of the container at that time.

[0147] Specifically, after the quota of the container is downgraded, the node agent reads the log file to scan whether there is an OOM (out of memory, memory leak causing program operation abnormality) event in any container, and when an OOM event occurs, the abnormal content is parsed based on the log of the OOM event and reported to the cloud platform, so that the quota of the container can be rolled back based on the OOM event.

[0148] In a specific implementation, the log is stored in the / var / log / message file, which is a rolling log file used by the Linux kernel to record various events.

[0149] Among them, rolling back the preset parameters of the container from the second quota to the first quota specifically includes: determining the time point and container name of the downgrade based on information parsed from the log of the OOM event (such as time, container name, and memory usage of the container at that time), and then determining the first quota required for rolling back the container based on the time point; adjusting the preset parameters of the container based on the first quota.

[0150] It should be noted that, in a specific implementation, after downgrading the container, if any of the two preset abnormal conditions mentioned above occurs, rollback is performed.

[0151] In summary, in a method for downgrading a cloud platform container provided by an embodiment of the present invention, determining whether a preset abnormal condition is met includes: determining that the preset abnormal condition is met based on the CPU restriction rate growth value exceeding a preset threshold within a preset time period; and / or determining that the preset abnormal condition is met based on the occurrence of an OMM event due to a memory leak in the container causing an abnormal program operation. In this solution, a specific method for rolling back the downgrade of the container is provided, which ensures the reliability of the downgrade and thereby improves the resource utilization efficiency of the container.

[0152] The following is an introduction to a cloud platform container downsizing device provided in an embodiment of the present invention. The cloud platform container downsizing device described below can be referenced to the cloud platform container downsizing method described above.

[0153] Figure 6A structural block diagram of a cloud platform container downgrading device provided in an embodiment of the present invention, wherein the cloud platform container downgrading device may include: an acquisition module 601, an analysis module 602, a downgrading module 603, and a rollback module 604;

[0154] The acquisition module 601 is used to acquire historical load data and current load data of at least one container;

[0155] The analysis module 602 is used to analyze whether to downgrade the configuration of any container based on the historical load data and the current load data of the container;

[0156] The downgrading module 603 is configured to adjust the preset parameters of the container from the first quota to the second quota based on the determination of downgrading the container, so as to achieve downgrading the container, wherein the value of the second quota is less than the first quota;

[0157] The rollback module 604 is configured to roll back the preset parameters of the container from the second quota to the first quota based on satisfying a preset abnormal condition.

[0158] In the specific implementation, the specific functions of each module refer to the embodiment of the cloud platform container downgrading method, which will not be described in detail in this embodiment.

[0159] Figure 7 The diagram shown is a schematic diagram of a software architecture for implementing a cloud platform container downsizing system provided by an embodiment of the present invention, including a host machine 10 and a processor 20;

[0160] The host machine 10 includes a container 101 and a management agent unit 102 ; the processor 20 includes a load statistics aggregation service unit 201 , a load analysis service unit 202 , a database 203 and a scheduling decision service unit 204 .

[0161] The database, in short, can be seen as an electronic filing cabinet - a place to store electronic files, where users can add, query, update, delete, etc. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application.

[0162] Combination Figure 7 The software architecture of the cloud platform container downsizing system shown in the figure, and the application example of the cloud platform container downsizing method provided by the embodiment of the present invention can be as follows:

[0163] Step S01: The management agent unit obtains the real-time load data of each container on the host machine to which it belongs in real time, and reports it to the load statistics summary service unit;

[0164] Step S02: the load analysis service unit exports all the load data of the container from the load statistics summary service unit every day, and calculates the peak and average values ​​of the load of the container;

[0165] Step S03: The peak-average value of the container load is saved in the database;

[0166] Step S04: The scheduling decision service unit pulls the historical load peak-average value and the current load peak-average value of the container from the database, and analyzes and determines whether downgrading is required;

[0167] Step S05: If downgrading is required, the scheduling judgment service unit controls the container quota downgrading;

[0168] Subsequently, steps S06 and S08 may be performed simultaneously.

[0169] Step S06: the scheduling decision service unit directly calls the management agent unit in real time to obtain the current load data of the container and determines whether rollback is required;

[0170] Step S07: If rollback is required, the scheduling decision service unit controls the container to rollback and restore the quota;

[0171] Step S08: The management agent unit detects the occurrence of an OOM event from the log file, parses the OOM event to obtain the time, container name and memory usage details of the container at that time, and reports it to the scheduling decision service unit

[0172] Step S09: The scheduling decision service unit rolls back the container involved in the OOM event and restores the quota.

[0173] The solution of this application is mainly used in container cloud platforms, has no restrictions on the type of hosting services, can be used for automatic downgrading of low-load containers, and has high reliability. This method determines whether the container can be downgraded based on historical load and current real-time load, and restores the quota of abnormal containers after downgrading by collecting the CPU limitation of the container and monitoring the OOM event monitoring of the host machine.

[0174] Optionally, the cloud platform container downsizing device may be a hardware device, and the modules and units described above may be provided as functional modules in the cloud platform container downsizing device. Figure 8 The hardware structure diagram of the cloud platform container downsizing device is shown. Figure 8 , the cloud platform container downsizing device may include: a processor 1, a communication interface 2, a memory 3 and a communication bus 4; wherein the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4; optionally, the communication interface 2 may be an interface of a communication module, such as an interface of a GSM module;

[0175] Processor 1, used for executing a program; memory 3, used for storing a program; the program may include a program code, and the program code includes a computer operation instruction;

[0176] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present invention; the memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.

[0177] Specifically, the program can be used for:

[0178] Obtain historical load data and current load data of at least one container;

[0179] Based on the historical load data and the current load data of any container, analyzing whether to downgrade the configuration of the container;

[0180] Based on the determination of downgrading the container, adjusting a preset parameter of the container from a first quota to a second quota to achieve downgrading the container, wherein the value of the second quota is less than the first quota;

[0181] Based on satisfying a preset abnormal condition, the preset parameters of the container are rolled back from the second quota to the first quota.

[0182] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0183] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0184] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0185] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A cloud platform container downgrading method, characterized in that: A processor used in a cloud platform container downsizing system, the system further comprising a host machine; the host machine is provided with at least one container and a management agent unit; the management agent unit is used to manage containers on the host machine; the method comprises: Obtain historical load data and current load data of at least one container; Based on the comparison result of the peak-average value of the memory load in the historical load data of any container with the quota, combined with the comparison result of the peak-average value of the load on the day with the quota, it is analyzed whether to downgrade the configuration of the container; Based on the determination of downgrading the container, gradually adjusting the preset parameters of the container from the first quota to the second quota according to the preset adjustment rule to achieve downgrading the container, wherein the value of the second quota is less than the first quota; When a preset abnormal condition is met, determining the first quota required for rollback based on a time point when preset parameters of the container are adjusted from the first quota to the second quota; adjusting preset parameters of the container based on the first quota, and rolling back from the second quota to the first quota; The step of obtaining the load data of at least one container on the same day includes: Get the memory load data and central processing unit (CPU) load data of at least one container on that day; When the CPU load data includes a usage rate and a restriction rate, obtaining the CPU load data of the container on that day includes: Based on the preset collection cycle of the day, respectively obtain the time slice value of the CPU; The CPU usage rate of any period is calculated based on the difference of the collected time slice values, the collection period duration, and the current CPU quota of the container; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; Obtain the number of CPU restrictions and sampling times within a preset period; the number of restrictions is the number of times the CPU demand is greater than the CPU quota within the preset period; Based on the ratio of the number of times the CPU is restricted and the number of sampling times, the restriction rate of the CPU in any period is calculated; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; Wherein, when a preset abnormal condition is met, determining the first quota required for rollback based on the time point when the preset parameters of the container are adjusted from the first quota to the second quota includes: When downgrading the container, the time point of the downgrading is recorded. If the CPU restriction rate growth value exceeds a preset threshold value within a preset time period of the downgrading, it is determined that a preset abnormal condition is met, and the first quota corresponding to the time point of the downgrading is determined; and / or, After downgrading the container, the log file is read to scan whether there is a memory leak in the container that causes an abnormal OOM event in program operation; Based on the memory leak in the container causing the program to run abnormally, the OOM event occurs and the preset abnormal conditions are determined; Based on the time, container name, and memory usage of the container at that time parsed from the log file of the OOM event, the time point at which the downgrade occurred and the container name are determined, and the first quota required for container rollback is determined based on the time point of the downgrade.

2. The method according to claim 1, characterized in that Get historical load data for at least one container, including: The peak-average value of the load of the container in the most recent preset days is obtained from a preset database, where the peak-average value is an average value of a preset number of load data items ranked from high to low in any one day.

3. The method according to claim 1, characterized in that Get the memory load data of the container for the day, including: Obtain the memory quota value of the container and the memory usage value of any period; Calculate the memory usage rate of any one cycle based on the ratio of the memory usage value to the memory quota value; Calculates the peak and average values ​​of the container memory load based on the memory usage in each cycle of the day.

4. A cloud platform container downsizing device, characterized in that: A processor used in a cloud platform container downsizing system, the system further comprising a host machine; the host machine is provided with at least one container and a management agent unit; the management agent unit is used to manage the container on the host machine; the device comprises: An acquisition module, used to acquire historical load data of at least one container and acquire memory load data and central processing unit (CPU) load data of at least one container on the current day; An analysis module, configured to analyze whether to downgrade the configuration of any container based on a comparison result of a peak-average value of the memory load in the historical load data of any container with the quota, combined with a comparison result of a peak-average value of the load on the day with the quota; a downgrading module, configured to gradually adjust preset parameters of the container from a first quota to a second quota according to a preset adjustment rule based on determining that the container is downgraded, so as to achieve downgrading of the container, wherein the value of the second quota is less than the first quota; A rollback module, configured to determine the first quota required for rollback based on a time point at which preset parameters of the container are adjusted from the first quota to the second quota when a preset abnormal condition is met; adjusting preset parameters of the container based on the first quota, and rolling back from the second quota to the first quota; When the CPU load data includes a usage rate and a restriction rate, the acquisition module is specifically used to: Based on the preset collection cycle of the day, respectively obtain the time slice value of the CPU; The CPU usage rate of any period is calculated based on the difference of the collected time slice values, the collection period duration, and the current CPU quota of the container; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; Obtain the number of CPU restrictions and sampling times within a preset period; the number of restrictions is the number of times the CPU demand is greater than the CPU quota within the preset period; Based on the ratio of the number of times the CPU is restricted and the number of sampling times, the restriction rate of the CPU in any period is calculated; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; The rollback module is specifically used for: When downgrading the container, the time point of the downgrading is recorded. If the CPU restriction rate growth value exceeds a preset threshold value within a preset time period of the downgrading, it is determined that a preset abnormal condition is met, and the first quota corresponding to the time point of the downgrading is determined; and / or, After downgrading the container, the log file is read to scan whether there is a memory leak in the container that causes an abnormal OOM event in program operation; Based on the memory leak in the container causing the program to run abnormally, the OOM event occurs and the preset abnormal conditions are determined; Based on the time, container name, and memory usage of the container at that time parsed from the log file of the OOM event, the time point at which the downgrade occurred and the container name are determined, and the first quota required for container rollback is determined based on the time point of the downgrade.

5. A cloud platform container downsizing system, characterized in that: include: Host and processor; Wherein, a management agent unit and at least one container are provided on the host machine; the management agent unit is used to manage the container on the host machine; The processor includes: a load statistics summary service unit, a load analysis unit, a database and a scheduling decision service unit; The management agent unit is used to obtain real-time load data of each container on the host machine to which it belongs, and report it to the load statistics summary service unit; The load statistics summary service unit is used to calculate the load data of the container according to a preset calculation period to obtain the current day load data of the container, and store it in a database; the current day load data includes memory load data and central processing unit CPU load data; The scheduling decision service unit is used to analyze whether to downgrade the container based on the comparison result of the load peak-average value of the memory load in the historical load data in the database and the quota, combined with the comparison result of the load peak-average value of the day and the quota, and when determining to downgrade the container, gradually adjust the preset parameters of the container from the first quota to the second quota according to the preset adjustment rules to achieve downgrading of the container, and the value of the second quota is less than the first quota; when the preset abnormal condition is met, based on the time point when the preset parameters of the container are adjusted from the first quota to the second quota, determine the first quota required for rollback; adjusting preset parameters of the container based on the first quota, and rolling back from the second quota to the first quota; Wherein, when the CPU load data includes a usage rate and a restriction rate, the process of obtaining the CPU load data includes: Based on the preset collection cycle of the day, respectively obtain the time slice value of the CPU; The CPU usage rate of any period is calculated based on the difference of the collected time slice values, the collection period duration, and the current CPU quota of the container; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; Obtain the number of CPU restrictions and sampling times within a preset period; the number of restrictions is the number of times the CPU demand is greater than the CPU quota within the preset period; Based on the ratio of the number of times the CPU is restricted and the number of sampling times, the restriction rate of the CPU in any period is calculated; Calculate the peak and average values ​​of the container CPU load based on the CPU usage in each cycle of the day; The scheduling decision service unit is specifically used for: When downgrading the container, the time point of the downgrading is recorded. If the CPU restriction rate growth value exceeds a preset threshold value within a preset time period of the downgrading, it is determined that a preset abnormal condition is met, and the first quota corresponding to the time point of the downgrading is determined; and / or, After downgrading the container, the log file is read to scan whether there is a memory leak in the container that causes an abnormal OOM event in program operation; Based on the memory leak in the container causing the program to run abnormally, the OOM event occurs and the preset abnormal conditions are determined; Based on the time, container name, and memory usage of the container at that time parsed from the log file of the OOM event, the time point at which the downgrade occurred and the container name are determined, and the first quota required for container rollback is determined based on the time point of the downgrade.

6. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on a computer device, the computer device is caused to execute the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Service resource control method and device, equipment and storage medium

    CN110196767A