Capacity expansion and contraction method and device, computer equipment and storage medium
By identifying the relationship between monitoring indicators and load pressure and container quantity and adjusting the container quantity, the resource bottleneck problem caused by horizontal expansion container dependence on a single resource indicator is solved, and effective response to complex application scenarios and system stability is improved.
Patent Information
- Application Number
- CN202411776776.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Horizontal expansion containers rely on a single resource indicator as a trigger condition for container expansion and scaling, which is difficult to fully reflect the system resource bottleneck, and cannot effectively deal with complex application scenarios such as message accumulation and resource exhaustion of numerical library connection pools, resulting in business interruption.
By obtaining the monitoring indicators corresponding to the application name, identifying the relationship between the monitoring indicator value and load pressure and container quantity, setting a scaling threshold, performing emergency capacity expansion or conventional capacity expansion decisions, and adjusting the container quantity to cope with load changes.
It realizes more effective response to complex application scenarios, reduces the lag of expansion and scaling, improves system stability, and avoids business interruptions.
Smart Images

Figure CN119557056A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer device and storage medium for scaling capacity. Background Art
[0002] With the development of cloud-native technology, Kubernetes has become a mainstream container orchestration tool. However, its horizontal pod autoscaling (HPA) function only supports triggering pod (container) scaling operations based on a single dimension of CPU or memory usage. Modern business applications usually have complex architectures, integrating multiple services such as message queues and numerical libraries. Traditional threshold-based scaling fails to combine the load change rules in historical values, and lacks the ability to respond to sudden loads and complex indicators. HPA relies on a single resource indicator as a trigger condition for container scaling. A single CPU or memory indicator is difficult to fully reflect the system resource bottleneck. The existing HPA function only considers a single dimension of CPU or memory usage to trigger container scaling operations, and cannot effectively deal with complex application scenarios such as message accumulation and exhaustion of numerical library connection pool resources, which may lead to business interruption. Summary of the invention
[0003] Based on this, a scaling method, apparatus, computer equipment and storage medium are provided to solve the technical problem that a horizontal scaling container relies on a single resource indicator as a trigger condition for container scaling, which is difficult to fully reflect the system resource bottleneck and cannot effectively deal with complex application scenarios such as message accumulation and exhaustion of numerical library connection pool resources.
[0004] On the one hand, a method for scaling up and down is provided, the method comprising:
[0005] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0006] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0007] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0008] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0009] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0010] In one embodiment, obtaining the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0011] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0012] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0013] In one embodiment, the emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value, including:
[0014] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0015] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0016] In one embodiment, obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0017] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0018] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0019] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0020] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0021] In one embodiment, if all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then comparing and obtaining the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0022] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0023] In one embodiment, the setting of the conventional expansion decision is to preset the number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and to obtain the target container number in combination with the preset maximum container number and the preset minimum container number, including:
[0024] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0025] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0026] In one embodiment, the scaling method further includes:
[0027] Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set;
[0028] The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training;
[0029] The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
[0030] On the other hand, a device for expansion and contraction is provided, the device comprising:
[0031] An association recognition module is used to obtain application names, obtain at least two monitoring indicators of load pressure affected by the number of containers for each application name, and identify the association between the monitoring indicator values and the load pressure and the number of containers;
[0032] A decision selection mode setting module is used to collect the monitoring indicator values of the target application, set the expansion threshold and the reduction threshold of the target application according to the monitoring indicator values of the target application, and execute the emergency expansion decision when the monitoring indicator value of the target application exceeds the expansion threshold or is lower than the reduction threshold, otherwise execute the conventional expansion decision;
[0033] An emergency capacity expansion decision setting module is used to set the emergency capacity expansion decision so that the ideal number of containers for the target application is equal to the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0034] A conventional expansion decision setting module, used to set the conventional expansion decision to the number of containers corresponding to all monitoring indicator values preset based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and to obtain the target container number in combination with the preset maximum container number and the preset minimum container number;
[0035] The container quantity adjustment module is used to monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, the emergency expansion decision is executed to adjust the container quantity. Otherwise, the conventional expansion decision is executed to adjust the container quantity.
[0036] In another aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0037] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0038] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0039] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0040] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0041] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0042] In another aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0043] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0044] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0045] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0046] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0047] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0048] The above-mentioned expansion and contraction methods, devices, computer equipment and storage media can predict future load trends, adjust resource allocation in advance, reduce the lag of expansion and contraction, and achieve more intelligent expansion and contraction decisions by monitoring multi-dimensional monitoring indicators and identifying the correlation between the monitoring indicator values and the load pressure and the number of containers based on the multi-dimensional monitoring indicators. At the same time, a two-layer decision-making mechanism is used to flexibly respond to normal and abnormal load scenarios, and real-time monitoring is performed to see whether the monitoring indicator values of the target application exceed the expansion threshold or are lower than the contraction threshold. If so, the emergency expansion decision is executed to adjust the number of containers. Otherwise, the conventional expansion decision is executed to adjust the number of containers. The emergency expansion decision is used as a backup plan for sudden increases or too low indicator values, thereby improving system stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 This is a flow chart of a method for scaling capacity in one embodiment of the present application;
[0051] Figure 2 A logic diagram of a method for scaling capacity in one embodiment of the present application;
[0052] Figure 3 This is a structural block diagram of a capacity expansion and contraction device in one embodiment of the present application;
[0053] Figure 4This is a diagram of the internal structure of a computer device in one embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0055] In one embodiment, Figure 1 , Figure 2 As shown, a method for scaling up and down is provided, comprising the following steps:
[0056] Step S1, obtaining an application name, obtaining at least two monitoring indicators of load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0057] Step S2, collecting the monitoring indicator values of the target application, setting the expansion threshold and the reduction threshold of the target application according to the monitoring indicator values of the target application, and executing the emergency expansion decision when the monitoring indicator value of the target application exceeds the expansion threshold or is lower than the reduction threshold, otherwise executing the conventional expansion decision;
[0058] Step S3, setting the emergency capacity expansion decision to the ideal number of containers for the target application equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator equals the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0059] Step S4, setting the conventional capacity expansion decision to the preset number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and obtaining the target container number in combination with the preset maximum container number and the preset minimum container number;
[0060] Step S5, monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0061] Among them, by monitoring multi-dimensional monitoring indicators and identifying the correlation between the monitoring indicator values and the load pressure and the number of containers based on the multi-dimensional monitoring indicators, it is possible to predict future load trends, adjust resource allocation in advance, reduce the lag of expansion and contraction, and achieve more intelligent expansion and contraction decisions. At the same time, a two-layer decision-making mechanism is used to flexibly respond to normal and abnormal load scenarios, and real-time monitoring is performed to see whether the monitoring indicator values of the target application exceed the expansion threshold or are lower than the contraction threshold. If so, the emergency expansion decision is executed to adjust the number of containers. Otherwise, the conventional expansion decision is executed to adjust the number of containers. The emergency expansion decision is triggered by a sudden increase or too low indicator value as a backup plan, which improves system stability.
[0062] In this embodiment, the obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0063] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0064] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0065] Specifically, when the system's CPU usage, memory usage, number of MySQL connections, or number of Kafka delay accumulations exceed the safety waterline, it may affect the normal operation of the business, or even cause interruptions. Therefore, in the case of a sudden increase in indicator values, it is necessary to quickly relieve the load pressure by increasing the number of containers (Pods) to ensure business stability. By monitoring multi-dimensional load indicators (such as CPU usage, memory usage, number of Kafka consumer accumulations, and number of MySQL connections), the system's comprehensive perception of load status is enhanced. Based on multi-dimensional indicator selection and dynamic feature modeling, it provides a high-quality data foundation for scaling decisions.
[0066] The correlation between the number of Pods and CPU usage, memory usage, number of MySQL connections, and number of Kafka consumer stacks is shown in Table 1.
[0067] Table 1 Association table
[0068] Number of Pods↑ Number of Pods↓ CPU usage ↓ ↑ Memory usage ↓ ↑ Number of MySQL connections ↓ ↑ Kafka delay accumulation number ↓ ↑
[0069] Increasing the number of Pods: This will share the system load, causing CPU usage, memory usage, MySQL connections, or Kafka consumer backlogs to gradually fall below the safety level to avoid service interruptions.
[0070] Reducing the number of Pods: When the load decreases, the number of Pods will be reduced, and the above indicators will increase accordingly, but they must still be controlled within the safety waterline. This will improve resource utilization and avoid resource waste.
[0071] The goal of this embodiment is to achieve intelligent expansion and contraction of Pods based on multi-dimensional monitoring data, thereby achieving a balance between efficient resource utilization and business stability. The core logic of this implementation is:
[0072] Conventional scaling decisions: Based on the XGBoost model, the load variation patterns are learned through historical indicator data, and the number of Pods is predicted and adjusted dynamically according to the real-time changes of various indicators.
[0073] Emergency scaling decisions: Considering the possibility of unexpected scenarios that may not be covered by historical data, real-time threshold monitoring is added based on the prediction of the XGBoost model to trigger emergency scaling decisions when indicators are abnormal (such as a sudden surge in the number of Kafka delay accumulation).
[0074] In this embodiment, the emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value, including:
[0075] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0076] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0077] During implementation, it is necessary to preset the default values of emergency expansion and contraction decisions for various applications. The default values of emergency expansion and contraction decisions are shown in Table 2.
[0078] Table 2 Preset values for emergency expansion and contraction decisions
[0079]
[0080] In this embodiment, obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0081] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0082] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0083] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0084] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0085] In this embodiment, if all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, including:
[0086] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0087] In this embodiment, the conventional capacity expansion decision is set to preset the number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number, including:
[0088] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0089] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0090] Specifically, if the data of an application indicator does not exceed the expansion threshold or is lower than the reduction threshold, the regular expansion and reduction decision process will be entered.
[0091] The input parameters are: X=[App_name,CPU_usage,Memory_usage,MySQL_connections,Kafka_lag].
[0092] The output parameter is: Y = predicted_pods. Predicted_pods indicates the number of adapted containers.
[0093] The target number of pods is calculated by combining the preset maximum number of containers and the preset minimum number of containers corresponding to the application: target_pods = min(max(min_pods, predicted_pods), max_pods).
[0094] like Figure 2 As shown, in this embodiment, the expansion and contraction method further includes:
[0095] Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set;
[0096] The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training;
[0097] The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
[0098] Among them, the number of pods is adjusted according to the calculated target number of pods, and the current application CPU, MEM, number of MySQL connections, number of Kafka stacks, and target number of Pods are added to the historical data set to continue to optimize and train the XGboost model, which can gradually improve the accuracy of the model.
[0099] In the above-mentioned expansion and contraction method, by monitoring multi-dimensional monitoring indicators and identifying the correlation between the monitoring indicator values and the load pressure and the number of containers based on the multi-dimensional monitoring indicators, it is possible to predict future load trends, adjust resource allocation in advance, reduce the lag of expansion and contraction, and achieve more intelligent expansion and contraction decisions. At the same time, a two-layer decision-making mechanism is used to flexibly respond to normal and abnormal load scenarios, and to monitor in real time whether the monitoring indicator values of the target application exceed the expansion threshold or are lower than the contraction threshold. If so, the emergency expansion decision is executed to adjust the number of containers. Otherwise, the conventional expansion decision is executed to adjust the number of containers. The emergency expansion decision is triggered by a sudden increase or too low indicator value as a backup plan, which improves system stability.
[0100] In one embodiment, Figure 3 As shown, a capacity expansion and contraction device 10 is provided, including: an association relationship identification module 1, a decision selection method setting module 2, an emergency capacity expansion decision setting module 3, a conventional capacity expansion decision setting module 4, and a container quantity adjustment module 5.
[0101] The association relationship identification module 1 is used to obtain application names, obtain at least two monitoring indicators of load pressure affected by the number of containers for each application name, and identify the association relationship between the monitoring indicator values and the load pressure and the number of containers.
[0102] The decision selection method setting module 2 is used to collect the monitoring indicator values of the target application, and set the expansion threshold and reduction threshold of the target application according to the monitoring indicator values of the target application. When the monitoring indicator value of the target application exceeds the expansion threshold or is lower than the reduction threshold, an emergency expansion decision is executed, otherwise a regular expansion decision is executed.
[0103] The emergency capacity expansion decision setting module 3 is used to set the emergency capacity expansion decision so that the ideal number of containers for the target application is equal to the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value.
[0104] The conventional expansion decision setting module 4 is used to set the conventional expansion decision to the number of containers corresponding to all monitoring indicator values preset based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and to obtain the target container number in combination with the preset maximum container number and the preset minimum container number.
[0105] The module 5 for adjusting the number of containers is used to monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, the emergency expansion decision is executed to adjust the number of containers; otherwise, the conventional expansion decision is executed to adjust the number of containers.
[0106] In this embodiment, the obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0107] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0108] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0109] In this embodiment, the emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value, including:
[0110] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0111] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0112] In this embodiment, obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0113] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0114] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0115] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0116] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0117] In this embodiment, if all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, including:
[0118] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0119] In this embodiment, the conventional capacity expansion decision is set to preset the number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number, including:
[0120] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0121] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0122] like Figure 3 As shown, the capacity expansion and contraction device 10 further includes: a model updating module 6.
[0123] In this embodiment, the model update module 6 is used to: collect the adjusted container quantity of the target application corresponding to the emergency expansion decision or the conventional expansion decision, obtain the current monitoring indicator value, and add the current monitoring indicator value and the container quantity to the historical data set; form the historical data set into preprocessed data, and input it into the XGBoost model for optimization training; the optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the container quantity, and sets the conventional expansion decision to control the container quantity based on the optimized XGBoost model.
[0124] In the above-mentioned expansion and contraction device, by monitoring multi-dimensional monitoring indicators and identifying the correlation between the monitoring indicator values and the load pressure and the number of containers based on the multi-dimensional monitoring indicators, it is possible to predict future load trends, adjust resource allocation in advance, reduce the lag of expansion and contraction, and achieve more intelligent expansion and contraction decisions. At the same time, a two-layer decision-making mechanism is used to flexibly respond to normal and abnormal load scenarios, and to monitor in real time whether the monitoring indicator values of the target application exceed the expansion threshold or are lower than the contraction threshold. If so, the emergency expansion decision is executed to adjust the number of containers. Otherwise, the conventional expansion decision is executed to adjust the number of containers. The emergency expansion decision is used as a backup plan for sudden increases or too low indicator values, thereby improving system stability.
[0125] For the specific definition of the expansion and contraction device, please refer to the definition of the expansion and contraction method above, which will not be repeated here. Each module in the above expansion and contraction device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0126] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0127] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0128] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0129] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0130] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0131] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0132] In one embodiment, the computer program further implements the following steps when executed by a processor:
[0133] The obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0134] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0135] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0136] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0137] The step of setting the emergency capacity expansion decision such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value includes:
[0138] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0139] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0140] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0141] The step of obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0142] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0143] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0144] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0145] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0146] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0147] If all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application obtained by comparison includes:
[0148] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0149] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0150] The setting of the conventional expansion decision to the preset number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target number of containers obtained by combining the preset maximum number of containers and the preset minimum number of containers includes:
[0151] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0152] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0153] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0154] Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set;
[0155] The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training;
[0156] The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
[0157] For specific limitations on the steps implemented when the computer program is executed by the processor, please refer to the limitations on the scaling method above, which will not be repeated here.
[0158] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a numerical library connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a numerical library. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The numerical library of the computer device is used to store expansion and contraction values. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for expansion and contraction is implemented.
[0159] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0160] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0161] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0162] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0163] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0164] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0165] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0166] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0167] The obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0168] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0169] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0170] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0171] The step of setting the emergency capacity expansion decision such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value includes:
[0172] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0173] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0174] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0175] The step of obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0176] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0177] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0178] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0179] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0180] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0181] If all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application obtained by comparison includes:
[0182] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0183] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0184] The setting of the conventional expansion decision to the preset number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target number of containers obtained by combining the preset maximum number of containers and the preset minimum number of containers includes:
[0185] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0186] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0187] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0188] Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set;
[0189] The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training;
[0190] The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
[0191] For specific limitations on the steps implemented when the processor executes a computer program, please refer to the limitations on the scaling method above, which will not be repeated here.
[0192] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0193] Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers;
[0194] Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions;
[0195] The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value;
[0196] The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number;
[0197] Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
[0198] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0199] The obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include:
[0200] The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations;
[0201] The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases.
[0202] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0203] The step of setting the emergency capacity expansion decision such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value includes:
[0204] When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods.
[0205] The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
[0206] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0207] The step of obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes:
[0208] When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods.
[0209] When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods.
[0210] When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods.
[0211] When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
[0212] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0213] If all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application obtained by comparison includes:
[0214] The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
[0215] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0216] The setting of the conventional expansion decision to the preset number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target number of containers obtained by combining the preset maximum number of containers and the preset minimum number of containers includes:
[0217] Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model;
[0218] The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
[0219] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0220] Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set;
[0221] The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training;
[0222] The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
[0223] For specific limitations on the steps implemented when the computer program is executed by the processor, please refer to the limitations on the scaling method above, which will not be repeated here.
[0224] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, numerical library or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double value rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0225] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0226] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for scaling up and down, characterized in that: include: Obtain an application name, obtain at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identify the correlation between the monitoring indicator value and the load pressure and the number of containers; Collect monitoring indicator values of the target application, set expansion thresholds and reduction thresholds of the target application according to the monitoring indicator values of the target application, and execute emergency expansion decisions when the monitoring indicator values of the target application exceed the expansion threshold or are lower than the reduction threshold, otherwise execute conventional expansion decisions; The emergency capacity expansion decision is set such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value; The conventional capacity expansion decision is set to be the number of containers corresponding to all monitoring indicator values preset based on the correlation relationship between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target container number is obtained by combining the preset maximum container number and the preset minimum container number; Monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, execute the emergency expansion decision to adjust the number of containers; otherwise, execute the regular expansion decision to adjust the number of containers.
2. The method for capacity expansion and contraction according to claim 1, characterized in that: The obtaining of the application name, obtaining at least two monitoring indicators of the load pressure affected by the number of containers for each application name, and identifying the correlation between the monitoring indicator value and the load pressure and the number of containers include: The monitoring indicators are set to include at least two of the following: CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations; The historical monitoring indicator values of the target application and the corresponding load pressure and number of containers are collected to form a historical data set, and the historical data set is input into the XGBoost model for training. The load pressure change law is learned through the historical monitoring indicator data, and the correlation between the monitoring indicator value and the load pressure and the number of containers is identified. When the number of containers increases, the monitoring indicator value decreases, and when the number of containers decreases, the monitoring indicator value increases.
3. The method for capacity expansion and contraction according to claim 1, characterized in that: The step of setting the emergency capacity expansion decision such that the ideal number of containers for the target application is equal to the maximum number of ideal containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value includes: When the monitoring indicator is a target indicator, the maximum threshold of the target indicator value is set to max_target, the minimum threshold of the target indicator value is set to min_target, the ideal value of the target indicator value is set to ideal_target, where min_target≤ideal_target≤max_target, the current number of containers is set to current_pods, the current value of the target indicator is set to Target_indicator, and the ideal number of containers corresponding to the target indicator value is set to ideal_target_pods. The ideal number of containers corresponding to all monitoring indicators of the target application is obtained, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is obtained by comparison, and the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application is used as the ideal number of containers for the target application.
4. The method for capacity expansion and contraction according to claim 3, characterized in that: The step of obtaining the ideal number of containers corresponding to all monitoring indicators of the target application includes: When the monitoring indicator is CPU usage, set the maximum CPU usage threshold to max_cpu_usage, set the minimum CPU usage threshold to min_cpu_usage, set the ideal CPU usage value to ideal_cpu_usage, set the current number of containers to current_pods, set the current value of CPU usage to CPU_usage, and set the ideal number of containers corresponding to the CPU usage to ideal_cpu_pods. When the monitoring indicator is memory usage, set the maximum threshold of memory usage to max_mem_usage, set the minimum threshold of memory usage to min_mem_usage, set the ideal value of memory usage to ideal_mem_usage, set the current number of containers to current_pods, set the current value of memory usage to Memory_usage, and set the ideal number of containers corresponding to the memory usage to ideal_mem_pods. When the monitoring indicator is the number of MySQL connections, the maximum threshold of the number of MySQL connections is set to max_mysql_connections, the minimum threshold of the number of MySQL connections is set to min_mysql_connections, the ideal value of the number of MySQL connections is set to ideal_mysql_connections, the current number of containers is set to current_pods, the current value of the number of MySQL connections is set to MySQL_connections, and the ideal number of containers corresponding to the number of MySQL connections is set to ideal_mysql_pods. When the monitoring indicator is the number of Kafka delay accumulations, the maximum threshold of the Kafka delay accumulation is set to max_kafka_lag, the minimum threshold of the Kafka delay accumulation is set to min_kafka_lag, the ideal value of the Kafka delay accumulation is set to ideal_kafka_lag, the current number of containers is set to current_pods, the current value of the Kafka delay accumulation is set to Kafka_lag, and the ideal number of containers corresponding to the Kafka delay accumulation is set to ideal_kafka_pods.
5. The method for capacity expansion and contraction according to claim 4, characterized in that: If all monitoring indicators of the target application are CPU usage, memory usage, number of MySQL connections, and number of Kafka delay accumulations, then the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application obtained by comparison includes: The ideal number of containers for the target application is set to ideal_pods, then ideal_pods = max(ideal_cpu_pods, ideal_mem_pods, ideal_mysql_pods, ideal_kafka_pods).
6. The method for capacity expansion and contraction according to claim 2, characterized in that: The setting of the conventional expansion decision to the preset number of containers corresponding to all monitoring indicator values based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and the target number of containers obtained by combining the preset maximum number of containers and the preset minimum number of containers includes: Input the collected monitoring indicator values of the target application into the XGBoost model, and identify the number of adapted containers using the correlation relationship between the monitoring indicator values corresponding to the target application and the load pressure and the number of containers in the XGBoost model; The number of adapted containers is set to predicted_pods, the preset maximum number of containers is set to max_pods, the preset minimum number of containers is set to min_pods, and the target number of containers corresponding to the target application is set to target_pods, then target_pods=min(max(min_pods, predicted_pods), max_pods).
7. The method for capacity expansion and contraction according to claim 2, characterized in that: The method further comprises: Collecting the number of adjusted containers corresponding to the target application based on the emergency capacity expansion decision or the conventional capacity expansion decision, obtaining the current monitoring indicator value, and adding the current monitoring indicator value and the number of containers to the historical data set; The historical data set is formed into preprocessed data, and input into the XGBoost model for optimization training; The optimized XGBoost model updates the correlation between the monitoring indicator value and the load pressure and the number of containers, and sets the conventional expansion decision to control the number of containers based on the optimized XGBoost model.
8. A capacity expansion and contraction device, characterized in that: The device comprises: An association recognition module is used to obtain application names, obtain at least two monitoring indicators of load pressure affected by the number of containers for each application name, and identify the association between the monitoring indicator values and the load pressure and the number of containers; A decision selection mode setting module is used to collect the monitoring indicator values of the target application, set the expansion threshold and the reduction threshold of the target application according to the monitoring indicator values of the target application, and execute the emergency expansion decision when the monitoring indicator value of the target application exceeds the expansion threshold or is lower than the reduction threshold, otherwise execute the conventional expansion decision; An emergency capacity expansion decision setting module is used to set the emergency capacity expansion decision so that the ideal number of containers for the target application is equal to the maximum value of the ideal number of containers corresponding to all monitoring indicators of the target application, and the ideal number of containers corresponding to each monitoring indicator is equal to the current number of containers multiplied by the current monitoring indicator value divided by the ideal monitoring indicator value; A conventional expansion decision setting module, used to set the conventional expansion decision to the number of containers corresponding to all monitoring indicator values preset based on the correlation between the monitoring indicator value of the target application and the load pressure and the number of containers, and to obtain the target container number in combination with the preset maximum container number and the preset minimum container number; The container quantity adjustment module is used to monitor the monitoring indicator value of each application, and determine whether the monitoring indicator value of each application exceeds the expansion threshold or is lower than the reduction threshold. If so, the emergency expansion decision is executed to adjust the container quantity. Otherwise, the conventional expansion decision is executed to adjust the container quantity.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Automatic intelligent capacity expansion and contraction method and system for server
CN113032157A
Application capacity expansion and contraction processing method and device, computer equipment and storage medium
CN117076243A
LSTM (Long Short Term Memory)-based PaaS (Platform as Service) platform capacity expansion and shrinkage method and device
CN117435336A
Load prediction method and system based on improved Transform
CN118295888A
Reactive capacity expansion and contraction scheduling method based on cost effectiveness under multi-resource constraint
CN118964002A