Pod capacity expansion and contraction prediction model training method and device, equipment and medium

By decomposing the historical resource usage data of Kubernetes pods STL algorithm and extracting time series feature, the scaling prediction model is trained, which solves the problem of inaccurate scaling prediction of pods in the existing technology, and achieves more efficient and intelligent scaling capabilities.

CN119807735APending Publication Date: 2025-04-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411706811.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art is difficult to accurately predict the scaling requirements of Kubernetes pods, resulting in waste of resources or unavailable applications.

Method used

By obtaining the historical resource usage data of the pod, the data is decomposed using the STL algorithm to obtain resource occupation trends and periodic information, the time series features are extracted, and the scaling prediction model is trained.

Benefits of technology

It improves the accuracy of pod expansion and capacity prediction, provides more efficient, intelligent and reliable expansion and capacity capabilities, and improves the performance and user experience of containerized applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807735A_ABST
    Figure CN119807735A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a training method and device of a pod capacity expansion and contraction prediction model, equipment and a medium. The method comprises the following steps: acquiring historical resource use data of a pod; decomposing the historical resource usage data based on an STL algorithm to obtain resource occupation trend information and resource occupation period information of the pod; extracting pod time sequence features in the resource occupation trend information and the resource occupation period information; and training based on the pod time sequence features to obtain the pod capacity expansion and contraction prediction model. According to the embodiment of the invention, the accuracy of pod capacity expansion and contraction prediction can be improved, and more efficient, intelligent and reliable capacity expansion and contraction capability can be provided, so that the performance of containerized applications and the use experience of users are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing container technology, and in particular to a training method, device, equipment and medium for a pod expansion and contraction prediction model. Background Art

[0002] Under the background of the rapid development of container technology and its large-scale application in the cloud computing industry, Kubernetes (called K8s) has gradually emerged as the mainstream technology platform for the deployment and management of containerized applications. Kubernetes provides users with comprehensive resource management services and has powerful automatic expansion capabilities. It automatically adjusts the number of instance copies of pods (logical units used to encapsulate one or more containers in Kubernetes) or resource quotas such as CPU (Central Processing Unit) and memory according to changes in application load to achieve pod expansion and contraction, meet the actual needs of the business, maximize resource utilization, and reduce resource waste.

[0003] Predicting the expansion and contraction of pods is the key to achieving automated expansion and contraction. Accurate prediction methods can help users optimize resource allocation rates and ensure application reliability and performance. If the prediction method is inaccurate, over-scaling may occur. Over-scaling may lead to insufficient resources required by the application, affecting actual business and application availability. Although over-scaling can maintain business operations, it will cause loss and waste of resources. Summary of the invention

[0004] The technical problem to be solved by the embodiments of the present application is to provide a training method, device, equipment and medium for a pod expansion and contraction prediction model to provide more efficient, intelligent and reliable expansion and contraction capabilities, thereby improving the performance of containerized applications and the user experience.

[0005] In a first aspect, an embodiment of the present application provides a method for training a pod expansion and contraction prediction model, the method comprising:

[0006] Get the historical resource usage data of the pod;

[0007] Decomposing the historical resource usage data based on the STL algorithm to obtain resource occupancy trend information and resource occupancy cycle information of the pod;

[0008] Extracting pod time series features from the resource occupancy trend information and the resource occupancy cycle information;

[0009] The pod expansion and contraction prediction model is obtained by training based on the pod time series features.

[0010] In a second aspect, an embodiment of the present application provides a training device for a pod expansion and contraction prediction model, the device comprising:

[0011] The historical resource data acquisition module is used to obtain the historical resource usage data of the pod;

[0012] A trend cycle information acquisition module, used to decompose the historical resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod;

[0013] A time series feature extraction module, used to extract pod time series features from the resource occupancy trend information and the resource occupancy cycle information;

[0014] The expansion and contraction prediction model acquisition module is used to obtain the pod expansion and contraction prediction model based on the pod time series feature training.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0016] A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the training method of the pod scaling prediction model described in any one of the above items is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the pod expansion and contraction prediction model described in any one of the above items.

[0018] Compared with the prior art, the embodiments of the present application have the following advantages:

[0019] In an embodiment of the present application, historical resource usage data of the pod is obtained. The historical resource usage data is decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod. The pod time series features in the resource occupancy trend information and the resource occupancy cycle information are extracted. A pod scaling prediction model is obtained based on pod time series feature training. In an embodiment of the present application, the STL time series decomposition and the scaling prediction model are combined to train the scaling prediction model. This method can better capture the trend and seasonality of pod resource demand, and based on the prediction of pod scaling, the accuracy of pod scaling prediction can be improved, and more efficient, intelligent, and reliable scaling capabilities can be provided, thereby improving the performance of containerized applications and the user experience.

[0020] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flowchart of the steps of a training method for a pod expansion and contraction prediction model provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of a scaling model training framework provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of a deep learning prediction algorithm process provided in an embodiment of the present application;

[0024] Figure 4 A schematic diagram of a pod expansion and contraction process provided in an embodiment of the present application;

[0025] Figure 5 A schematic diagram of the structure of a training device for a pod expansion and contraction prediction model provided in an embodiment of the present application;

[0026] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0028] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0029] Reference Figure 1 , shows a flowchart of the steps of a training method for a pod expansion and contraction prediction model provided in an embodiment of the present application. Figure 1 As shown, the training method of the pod expansion and contraction prediction model may include: step 101, step 102, step 103 and step 104.

[0030] Step 101: Get the historical resource usage data of the pod.

[0031] The embodiments of the present application can be applied to a scenario in which the STL time series decomposition and the expansion and contraction prediction model are combined to train a prediction model for pod expansion and contraction.

[0032] Kubernetes (K8s) is an open source container orchestration platform for automating the deployment, scaling, and management of containerized applications.

[0033] A pod is a combination of one or more containers that share the same network namespace, storage volume and other resources. A pod is the smallest deployment unit in Kubernetes, and containers run in pods. Kubernetes and pods are key components for container orchestration and management. Kubernetes provides a powerful and flexible container orchestration system, and pods are the smallest deployable and manageable computing units in Kubernetes. By using Kubernetes and pods properly, developers can deploy and manage containerized applications more efficiently.

[0034] When training the pod scaling prediction model, you can obtain the historical resource usage data of the pod.

[0035] In the specific implementation, a historical pod resource quota database can be built to collect and store the historical resource usage data of the pod. The content stored in this database can include indicators such as the CPU (Central Processing Unit) utilization, memory usage, or network traffic of the pod, and it is necessary to ensure that the data has a sufficient historical time range and continuity.

[0036] When collecting historical resource usage data of pods for the pod scaling prediction model, the historical resource usage data of pods (such as indicator data such as CPU utilization, memory utilization, network traffic, etc. of pods) can be obtained from the above-constructed database.

[0037] After the historical resource usage data of the pod is obtained, step 102 is executed.

[0038] Step 102: Decompose the historical resource usage data based on the STL algorithm to obtain resource occupancy trend information and resource occupancy cycle information of the pod.

[0039] STL (Seasonal-Trend decomposition procedure based on Loess) is a method for decomposing time series data. The STL algorithm consists of two loops: the inner loop and the outer loop. The inner loop mainly calculates the trend and periodic components, re-estimates the period and trend at each time point in each iteration, and adapts to the nonlinearity and non-stationarity of the data through local weighted regression (LOESS). It is to fit the data more accurately by continuously adjusting the estimated values ​​of the periodic component and the trend component. In each iteration, it adjusts the periodicity and trend according to the residuals of the previous iteration to minimize the newly generated residuals; the outer loop is another iterative process in the STL algorithm, which is used to calculate the robust value of each sample point in the update sequence, process and adjust the weights of several regression steps in the inner loop, reduce the impact of outliers in the data sequence, and improve the accuracy of the decomposition results.

[0040] Resource usage trend information reflects the long-term trend of pod resource usage. For example, it shows that as the workload increases, the CPU and memory usage of the pod also gradually increases.

[0041] Resource usage cycle information reflects the periodic fluctuations in pod resource usage. For example, it shows that the CPU usage of a pod increases during working hours every day and decreases during non-working hours. In addition, seasonal components may also reveal longer-term periodic changes such as weekly, monthly, or annual.

[0042] After obtaining the historical resource usage data of the pod, the historical resource usage data can be decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod. Specifically, after obtaining the historical resource usage data of the pod, the historical resource usage data of the pod can be preprocessed to obtain the time-continuous pod resource usage data. Then, the time-continuous pod resource usage data can be decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod.

[0043] In this embodiment, data preprocessing is the first step of data analysis, which ensures the accuracy, consistency and integrity of the data and lays the foundation for subsequent algorithm application. For the historical resource usage data of the pod, preprocessing can include at least one of the following methods:

[0044] 1. Data cleaning: Remove or correct errors, anomalies or missing values ​​in the data. Identify and process duplicates in the data.

[0045] 2. Data transformation: Convert data into a format suitable for STL algorithm processing, such as time series data. Standardize or normalize the data to improve the performance and accuracy of the algorithm.

[0046] 3. Data interpolation: For missing time points, use interpolation methods (such as linear interpolation, spline interpolation, etc.) to estimate their resource usage. Ensure that the data is continuous in time to facilitate subsequent trend analysis and cycle detection.

[0047] 4. Time series smoothing: Apply smoothing techniques (such as moving average, exponential smoothing, etc.) to reduce noise and fluctuations in the data. Make the data easier to analyze and reveal underlying trends and periodicities.

[0048] The STL algorithm uses the addition principle to decompose time series data, decomposing the data Yv at a certain moment into the seasonal component, the trend component and the remainder component. The equation is as follows:

[0049] Yv=Tv+Sv+Rv v=1,...,N (1)

[0050] In the above formula, T(k)v and S(k)v (representing Tv and Sv of the kth cycle respectively) are the trend component and period component at the end of the k-1th cycle in the inner cycle. Initially, Tv(k)=0. The sample points at the same position in each cycle form a subsequence, and there will be a total of n(p) subsequences.

[0051] The inner loop of the STL algorithm consists of the following 6 steps:

[0052] 1. Detrending: Subtract the trend component of the previous round of results from the data at a certain moment, that is, Yv-T(k)v.

[0053] 2. To smooth the periodic subsequences, LOESS (q = n(s), d = 1) (where n(s) is the LOESS smoothing parameter) can be used to regress each subsequence, extending it forward and backward by one period, and the smoothed results form a temporary seasonal series, denoted as C(k+1)v.

[0054] 3. Low-throughput filtering of periodic subsequences. For the result sequence C(k+1)v of the previous step, perform moving averages of lengths n(p), n(p), and 3 in turn (n(p) is the total number of samples in one period), and then perform LOESS (q=n(l), d=1) (where n(l) is the LOESS smoothing parameter, usually greater than) regression to obtain the result sequence L(k+1)v, v=1,□,N, which is equivalent to the low-throughput L(k+1)v of the periodic subsequence.

[0055] 4. Remove the low flux of the smooth periodic subsequence to obtain the seasonal term: S(k+1)v=C(k+1)v - L(k+1)v.

[0056] 5. Deseasonalizing: subtract the seasonal component, Yv-S(k+1)v.

[0057] 6. Trend Smoothing: Perform LOESS (q=n(t), d=1) regression on the sequence after removing the period in the de-periodization step to obtain the trend component T(k+1)v (where n(t) is the LOESS smoothing parameter, usually the smallest odd number in the range of n(p) to 2*n(p)).

[0058] The outer loop calculates the robust weight ρv value of the sample point (that is, the robust weight of the sample point v). In the second and sixth steps of the corresponding inner loop, when using LOESS for regression, the neighborhood weight is multiplied by ρv, where ρv = B(|Rv| / h), h = 6*median(|Rv|). It can be seen that the larger Rv (the remainder of the sample point v), the smaller the corresponding weight ρv. This method can be used to adjust the robust weight and reduce the weight and influence of outliers with large remainders.

[0059] After the historical resource usage data is decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod, step 103 is executed.

[0060] Step 103: extracting pod time series features from the resource occupancy trend information and the resource occupancy cycle information.

[0061] After decomposing the historical resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod, the pod time series features in the resource occupancy trend information and resource occupancy cycle information can be extracted. The implementation process can be described in detail in combination with the following specific implementation methods.

[0062] In a specific implementation of the present application, the above step 103 may include:

[0063] Sub-step A1: Obtain the mean, variance and slope corresponding to the resource occupancy trend information, and the amplitude information and phase information corresponding to the resource occupancy period information.

[0064] In this embodiment, after obtaining the resource occupancy trend information and the resource occupancy period information, the mean, variance and slope corresponding to the resource occupancy trend information and the amplitude information and phase information corresponding to the resource occupancy period information may be obtained.

[0065] The mean refers to the average value of resource usage trend data, which reflects the overall level of resource usage.

[0066] Variance is a statistic that measures the degree of data dispersion and reflects the fluctuation of resource usage trend data.

[0067] The slope reflects the rate of change of the resource usage trend, that is, how fast the resource usage changes over time. In a specific implementation, a linear regression line or trend line of the resource usage trend can be drawn and its slope can be calculated.

[0068] The amplitude information reflects the maximum amplitude of the resource usage cycle fluctuation, that is, the difference between the maximum and minimum values ​​of resource usage in the cycle. In the specific implementation, the maximum and minimum values ​​in each cycle can be determined by observing the waveform of the resource usage cycle data, and their difference can be calculated.

[0069] Phase information reflects the starting point of the resource occupancy cycle fluctuation or the position of a specific moment in the cycle. In signal processing or periodic analysis, phase is often used together with frequency and period to describe the periodic characteristics of a signal.

[0070] After obtaining the mean, variance and slope corresponding to the resource occupancy trend information, and the amplitude information and phase information corresponding to the resource occupancy period information, sub-step A2 is performed.

[0071] Sub-step A2: obtaining the pod time series feature according to the mean, the variance, the slope, the amplitude information and the phase information, and the corresponding timestamp information.

[0072] After obtaining the mean, variance, and slope corresponding to the resource occupancy trend information, as well as the amplitude and phase information corresponding to the resource occupancy period information, the pod time series characteristics can be obtained based on the mean, variance, slope, amplitude and phase information, as well as the corresponding timestamp information. In this example, the STL time series decomposition method is applied to perform seasonal or periodic decomposition on the time series formed by the collected historical resource usage data. The time series is decomposed into components such as trend components, seasonal (periodic) components, and residuals. The trend and seasonal (periodic) information of the pod's resource occupancy can be obtained from the results obtained after the decomposition.

[0073] After extracting the pod time series features in the resource occupancy trend information and the resource occupancy cycle information, step 104 is performed.

[0074] Step 104: The pod expansion and contraction prediction model is obtained by training based on the pod time series features.

[0075] After extracting the pod time series features from the resource occupancy trend information and the resource occupancy cycle information, the pod time series features can be used to train a pod expansion and contraction prediction model. The model training process can be described in detail in conjunction with the following specific implementation method.

[0076] In a specific implementation of the present application, the above step 104 may include:

[0077] Sub-step B1: inputting the pod time series features into the pod scaling prediction model to be trained, wherein the pod scaling prediction model to be trained includes: an embedding layer, a position encoding layer, an encoder and a decoder.

[0078] In this example, the pod scaling prediction model to be trained can be a Transformer architecture model. Transformer is a deep learning model based on the self-attention mechanism, which has shown powerful capabilities in sequence modeling tasks. The Transformer model consists of two parts (Encoder-Decoder). The encoder is responsible for mapping the input sequence to a hidden representation, while the decoder generates an output sequence based on the encoder's hidden representation. Both the encoder and the decoder are composed of multiple layers of self-attention mechanism layers and feedforward neural network layers.

[0079] Among them, the self-attention mechanism is the core of Transformer, which is used to calculate the importance weights of elements at different positions in the input sequence, and obtain the hidden representations of the encoder and decoder by taking weighted average of the elements at different positions in the input sequence.

[0080] The calculation process of the self-attention mechanism includes the similarity calculation between the query matrix (Q), the key matrix (K) and the value matrix (V), and finally converting the similarity into attention weights. Specifically, given an input sequence, firstly, it is linearly transformed to obtain the query matrix Q, the key matrix K and the value matrix V. Then the similarity between the query matrix Q and the key matrix K is calculated. Next, the similarity is divided by a scaling factor and converted into attention weights through the softmax function. Finally, the attention weights are weighted averaged with V to obtain the hidden representations of the encoder and decoder.

[0081] In addition to the self-attention mechanism, the Transformer model also includes a feedforward neural network. The feedforward neural network is a fully connected neural network that further processes the hidden representations of the encoder and decoder through multiple layers of linear transformations and nonlinear activation functions.

[0082] Position encoding layer: Since no recurrent neural network or convolutional neural network is used, the Transformer architecture lacks the ability to model the position information in the entire sequence. To solve this problem, the Transformer model introduces position encoding. Position encoding is a technique that embeds the position information in the input sequence into the model. Position encoding usually uses sine encoding and cosine encoding to implement its function. After the position encoding is generated, it is added to the element embedding of the input sequence to combine the position information and the element. In this way, the Transformer model can distinguish elements at different positions in the input sequence and understand the order of the input sequence, improving the performance of the Transformer in sequence modeling.

[0083] In this embodiment, after obtaining the pod time series features, the pod time series features may be input into a pod scaling prediction model to be trained. The pod scaling prediction model to be trained may include: an embedding layer, a position encoding layer, an encoder, and a decoder.

[0084] After the pod time series features are input into the pod scaling prediction model to be trained, sub-step B2 is performed.

[0085] Sub-step B2: calling the embedding layer to encode the pod time series features to obtain a sequence vector representation corresponding to the pod time series features.

[0086] After the pod time series features are input into the pod scaling prediction model to be trained, the embedding layer can be called to encode the pod time series features to obtain the sequence vector representation corresponding to the pod time series features.

[0087] In this example, the input of the embedding layer is the pod time series feature, which can encode the pod time series feature to obtain a sequence vector representation.

[0088] After calling the embedding layer to encode the pod time series features to obtain the sequence vector representation corresponding to the pod time series features, sub-step B3 is executed.

[0089] Sub-step B3: calling the position coding layer to perform position coding on the pod time series features by using sine coding and cosine coding to obtain position coding information.

[0090] After calling the embedding layer to encode the pod time series features to obtain the sequence vector representation corresponding to the pod time series features, the position encoding layer can be called to positionally encode the pod time series features using sine encoding and cosine encoding to obtain position encoding information. Since time series data has temporal order, the position encoding layer is used to capture this order information, position encoding information, which will be added to the sequence vector representation to help the model understand the temporal order of the data.

[0091] After calling the position coding layer to perform position coding on the pod time series features using sine coding and cosine coding to obtain position coding information, sub-step B4 is executed.

[0092] Sub-step B4: calling the encoder to process the sequence vector representation and the position encoding information to obtain a hidden representation corresponding to the pod time series feature.

[0093] After calling the position encoding layer to position encode the pod time series features using sine encoding and cosine encoding to obtain the position encoding information, the encoder can be called to process the sequence vector representation and position encoding information to obtain the hidden representation corresponding to the pod time series features. The hidden representation is the model's internal representation of the input data, which contains all the information required for prediction. The encoder's processing of the sequence vector representation and position encoding information can be described in detail in combination with the following specific implementation method.

[0094] In another specific implementation of the present application, the above sub-step B4 may include:

[0095] Sub-step C1: calling the self-attention mechanism layer to process the sequence vector representation according to the position encoding information to obtain the importance weights of elements at different positions, and performing weighted averaging processing on the sequence vector representation according to the importance weights to obtain an initial hidden representation.

[0096] In this embodiment, the encoder may include: a self-attention mechanism layer and a feedforward neural network layer. After obtaining the position encoding information and the sequence vector representation, the self-attention mechanism layer may be called to process the sequence vector representation according to the position encoding information to obtain the importance weights of elements at different positions, and perform weighted averaging on the sequence vector representation according to the importance weights to obtain the initial hidden representation.

[0097] Specifically, the self-attention mechanism layer first receives the sequence vector representation and position encoding information as input. The position encoding information is crucial for sequence data, which can help the model understand the relative position relationship between elements. Next, the self-attention mechanism layer calculates an importance weight (also called "attention weight" or "attention score") for each element (or "token") in the sequence vector representation based on the position encoding information. This weight reflects the relative importance of each element to the final decision in the current task (such as predicting the resource occupancy of a pod). Weighted average processing: Once the importance weights of all elements are calculated, the self-attention mechanism layer uses these weights to perform weighted averaging on the sequence vector representation. The result of this weighted average is a new vector that combines the information of all elements in the sequence, but the influence of each element is determined by its importance weight. The weighted averaged vector is output as the initial hidden representation, which contains the important information of all elements in the sequence and has been weighted according to their importance.

[0098] After obtaining the initial hidden representation, sub-step C2 is performed.

[0099] Sub-step C2: calling the feedforward neural network layer to perform linear transformation and nonlinear activation processing on the initial hidden representation to obtain the hidden representation.

[0100] After the initial hidden representation is obtained, the feedforward neural network layer can be called to perform linear transformation and nonlinear activation processing on the initial hidden representation to obtain the hidden representation.

[0101] In a feedforward neural network layer, the initial hidden representation is first linearly transformed, usually via a weight matrix and bias term.

[0102] After the linear transformation, a nonlinear activation function (such as ReLU, tanh, or sigmoid) is usually applied to increase the nonlinear ability of the model. Nonlinear activation functions allow the model to learn complex nonlinear relationships, which is crucial to improving the performance of the model.

[0103] Output hidden representation: After linear transformation and nonlinear activation, the feedforward neural network layer outputs the final hidden representation. This hidden representation contains richer information and has been nonlinearly transformed, making it more suitable for subsequent decoding steps or other tasks.

[0104] The self-attention mechanism layer processes the sequence vector representations by calculating importance weights and applying weighted averages, while the feedforward neural network layer further processes these representations through linear transformations and nonlinear activations to generate the final hidden representations. Together, these two steps form a key component in the model for extracting and processing useful information from sequence data.

[0105] Sub-step B5: calling the decoder to decode the hidden representation to obtain the predicted resource occupancy information of the pod.

[0106] After obtaining the hidden representation, the decoder can be called to decode the hidden representation to obtain the predicted resource usage information of the pod. The predicted resource usage information may include the predicted CPU usage, memory usage, and other information.

[0107] In this example, the model structure of the decoder is the same as that of the encoder. The decoder's self-attention mechanism layer first processes the hidden representation of the input. Similar to the self-attention mechanism layer in the encoder, the self-attention mechanism here is also used to calculate the importance weights of elements at different positions in the sequence. However, in the decoder, the self-attention mechanism layer usually also applies a "mask" to ensure that when generating a prediction for the current position, only information before the current position can be accessed (or the so-called "autoregressive" property). This is to prevent the model from "seeing" future information when generating predictions. The self-attention mechanism layer outputs processed representations, which now contain information about the relative importance between elements within the sequence and have been adjusted according to the mask.

[0108] The processed representations are then passed to the feedforward neural network layer of the decoder. In the feedforward neural network layer, these representations are processed by linear transformations and non-linear activation functions to generate the final predicted output. Linear transformations are usually implemented through a weight matrix and bias terms, while non-linear activation functions are used to increase the non-linear capabilities of the model.

[0109] After being processed by the feedforward neural network layer, the decoder outputs the predicted resource occupancy information of the Pod.

[0110] Sub-step B6: Calculate the loss value of the pod scaling prediction model to be trained based on the predicted resource occupancy information and the annotated resource occupancy information of the pod.

[0111] After obtaining the predicted resource occupancy information, the loss value of the pod scaling prediction model to be trained can be calculated based on the predicted resource occupancy information and the annotated resource occupancy information of the pod. The loss value is an indicator that measures the difference between the model prediction value and the actual value.

[0112] After the loss value of the pod scaling prediction model to be trained is calculated based on the predicted resource occupancy information and the annotated resource occupancy information of the pod, sub-step B7 is executed.

[0113] Sub-step B7: when the loss value is within a preset range, obtaining the final pod expansion and contraction prediction model.

[0114] After calculating the loss value of the pod scaling prediction model to be trained based on the predicted resource occupancy information and the annotated resource occupancy information of the pod, it can be determined whether the loss value is within a preset range.

[0115] If the loss value is not within the preset range, it means that the pod scaling prediction model to be trained has not converged. At this time, the pod scaling prediction model to be trained can be further trained with more model training samples until the model converges.

[0116] If the loss value is within the preset range, it means that the pod scaling prediction model to be trained has converged. At this time, the trained pod scaling prediction model to be trained can be used as the final pod scaling prediction model.

[0117] The embodiment of the present application combines STL time series decomposition with the scaling prediction model to train the scaling prediction model. This method can better capture the trend and seasonality of pod resource demand, and based on the prediction of pod scaling, it can improve the accuracy of pod scaling prediction, and can provide more efficient, intelligent and reliable scaling capabilities, thereby improving the performance of containerized applications and user experience.

[0118] After the pod expansion and contraction prediction model is trained, the pod expansion and contraction prediction model can be used to predict the expansion and contraction of the pod. The implementation process can be described in detail in conjunction with the following specific implementation method.

[0119] In a specific implementation of the present application, after the above step 104, the following may also be included:

[0120] Step D1: Obtain target resource usage data of a target pod to be predicted in a preset time period, where the preset time period is a time period from a specified time to the current time.

[0121] In this embodiment, when predicting the expansion and contraction of the target pod to be predicted at a certain time in the future, the target resource usage data of the target pod to be predicted in a preset time period can be obtained, wherein the preset time period is a time period from a specified time to the current time. In this example, the prediction time period can be a time period of 10 minutes, 30 minutes, 1 day, etc. from the current time, and this embodiment does not limit the specific length of the preset time period.

[0122] After obtaining the target resource usage data of the target pod to be predicted in the preset time period, step D2 is executed.

[0123] Step D2: Decomposing the target resource usage data based on the STL algorithm to obtain trend information and cycle information of the target pod.

[0124] After obtaining the target resource usage data of the target pod to be predicted in the preset time period, the target resource usage data can be decomposed based on the STL algorithm to obtain the trend information and cycle information of the target pod.

[0125] After the target resource usage data is decomposed based on the STL algorithm to obtain the trend information and cycle information of the target pod, step D3 is executed.

[0126] Step D3: extracting time series features corresponding to the target pod from the trend information and the period information.

[0127] After the target resource usage data is decomposed based on the STL algorithm to obtain the trend information and cycle information of the target pod, the time series features corresponding to the target pod can be extracted from the trend information and cycle information.

[0128] Step D4: calling the pod expansion and contraction prediction model to process the time series features to obtain the predicted resource occupancy information of the target pod at the target time in the future.

[0129] After obtaining the time series features corresponding to the target pod, the pod scaling prediction model can be called to process the time series features to obtain the predicted resource occupancy information of the target pod at the target time in the future.

[0130] Step D5: scaling the target pod at the target time in the future based on the predicted resource occupancy information.

[0131] After obtaining the predicted resource occupancy information of the target pod at the future target time, the target pod can be scaled up or down based on the predicted resource occupancy information. Specifically, the actual resource occupancy information of the target pod at the current time can be obtained, and the actual resource occupancy information is compared with the predicted resource occupancy information.

[0132] When the actual resource occupancy information is greater than the predicted resource occupancy information, the target pod can be scaled down when the target time is reached.

[0133] When the actual resource occupancy information is less than the predicted resource occupancy information, the target pod can be expanded when the target time is reached.

[0134] In order to train a scaling prediction model of the Transformer structure, the present application embodiment provides a scaling model training architecture, such as Figure 2 As shown, the architecture may include:

[0135] Database, which stores pod historical resource usage indicators for use by other components.

[0136] Monitoring components usually consider using the monitoring components that Kubernetes has already adapted to query the resource usage of Pods, which mainly include data and indicators such as CPU usage, memory usage, and traffic size. In addition to basic data, custom data indicators can also be collected through other components. The collected data will be directly imported into the Transformer prediction model and passed to the database.

[0137] Cache component: used to store data information cache between components.

[0138] Transformer scaling prediction model: Combining the STL algorithm and the Transformer model, it receives various monitoring indicators transmitted by the monitoring component, obtains historical indicators from the database, integrates them into time series, decomposes them, imports them for calculation, and then outputs the obtained prediction results to the scaling controller.

[0139] Scaling controller: obtains the pod information of the object that needs to be scaled up or down, and then compares the predicted resource quota predicted by Transformer scaling with the current resource quota of the object pod item by item to calculate which resource items should be scaled up or down according to the scaling strategy.

[0140] Pod controller: obtains specific scaling policies and items from the scaling controller, triggers one or more corresponding resource item quota controllers, and accurately scales the resource configuration items that need to be scaled.

[0141] Next, combine Figure 3 The training process of the Transformer model is described in detail. Figure 3 As shown, the training process may include:

[0142] 1. Build a historical resource quota database. The database can store indicators such as pod CPU utilization, memory usage, or network traffic.

[0143] 2. Generate historical resource quota time series. Extract resource data from the database and ensure that the data has sufficient historical time range and continuity.

[0144] 3. STL time series decomposition. Apply the STL time series decomposition method to seasonal or periodic decomposition of the time series formed by the collected historical resource usage data. Decompose the time series into trend components, seasonal (periodic) components, and residual components. The results obtained after decomposition can provide information on the trend and seasonal (periodic) information of pod resource usage.

[0145] 4. Extract the required feature items. Extract features from the trend and seasonal information obtained by STL decomposition of historical resource usage data. This can include the mean, variance, slope, etc. of the trend, as well as the amplitude and phase of seasonality (periodicity). Use these features as input features for training and prediction of the Transformer model.

[0146] 5. Transformer model training. Use the feature data prepared in the previous step to build and train the Transformer model. The input sequence of the model is the time point and the corresponding feature vector. The Transformer model can learn the contextual information and long-term dependencies in the time series through the multi-head self-attention mechanism and feedforward neural network, thereby generating an accurate and reliable prediction model.

[0147] Next, combine Figure 4 The expansion and contraction process is described in detail. Figure 4 As shown, the process may include:

[0148] 1. Compare predicted and actual resources. The prediction (i.e. predicted resources) is the resource usage information of the pod at a certain point in the future predicted by the Transformer model. You can compare the predicted resources with the actual resources currently used by the pod.

[0149] 2. Determine whether there is a difference, that is, determine whether there is a difference between the predicted resources and the actual resources.

[0150] 3. If there is no difference between the predicted resources and the actual resources, there is no need to scale the pod, and the process ends.

[0151] 4. If there is a difference between the predicted resources and the actual resources, the difference values ​​of each indicator can be calculated.

[0152] 5. Trigger the corresponding resource controller to scale up or down based on the difference in values ​​of the various indicators calculated in step 4. For example, after the training is completed, the Transformer model obtained after the training is used to predict the future resource requirements of the required pods, and based on the prediction results, corresponding scaling decisions can be made at the corresponding time points. For example, if the actual resource usage of the pod is less than the resource usage at the corresponding time point of the prediction result, an expansion operation can be triggered to increase the allocation of the resource, such as CPU, memory, etc. On the contrary, if the actual resources occupied by the pod are more than the resources at the corresponding time point of the prediction result, a scaling operation is triggered to reduce the allocation of the corresponding resource items. In this way, the actual scaling timing diagram is as consistent as possible with the predicted scaling timing diagram.

[0153] The training method of the pod scaling prediction model provided in the embodiment of the present application obtains the historical resource usage data of the pod. The historical resource usage data is decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod. The pod time series features in the resource occupancy trend information and the resource occupancy cycle information are extracted. The pod scaling prediction model is obtained based on the pod time series feature training. The embodiment of the present application combines the STL time series decomposition and the scaling prediction model to train the scaling prediction model. This method can better capture the trend and seasonality of the pod resource demand, and based on the prediction of pod scaling, it can improve the accuracy of pod scaling prediction, and can provide more efficient, intelligent and reliable scaling capabilities, thereby improving the performance of containerized applications and the user experience.

[0154] Reference Figure 5 , shows a schematic diagram of the structure of a training device for a pod expansion and contraction prediction model provided in an embodiment of the present application. Figure 5 As shown, the training device 500 of the pod expansion and contraction prediction model may include the following modules:

[0155] A historical resource data acquisition module 510 is used to acquire historical resource usage data of the pod;

[0156] A trend cycle information acquisition module 520 is used to decompose the historical resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod;

[0157] A time series feature extraction module 530 is used to extract pod time series features from the resource occupancy trend information and the resource occupancy cycle information;

[0158] The expansion and contraction prediction model acquisition module 540 is used to obtain the pod expansion and contraction prediction model based on the pod time series feature training.

[0159] Optionally, the trend period information acquisition module includes:

[0160] A pod resource data acquisition unit, used to perform data preprocessing on the historical resource usage data to obtain time-continuous pod resource usage data;

[0161] The trend cycle information acquisition unit is used to decompose the time-continuous pod resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod.

[0162] Optionally, the time series feature extraction module includes:

[0163] A resource information acquisition unit, used to acquire the mean, variance and slope corresponding to the resource occupancy trend information, and the amplitude information and phase information corresponding to the resource occupancy period information;

[0164] A time series feature acquisition unit is used to obtain the pod time series feature according to the mean, the variance, the slope, the amplitude information and the phase information, and the corresponding timestamp information.

[0165] Optionally, the expansion and contraction prediction model acquisition module includes:

[0166] A time series feature input unit, used to input the pod time series feature into a pod expansion and contraction prediction model to be trained, wherein the pod expansion and contraction prediction model to be trained includes: an embedding layer, a position encoding layer, an encoder, and a decoder;

[0167] A sequence vector representation acquisition unit, used to call the embedding layer to encode the pod time series feature to obtain a sequence vector representation corresponding to the pod time series feature;

[0168] A position coding information acquisition unit, used for calling the position coding layer to perform position coding on the pod time series features by using sine coding and cosine coding to obtain position coding information;

[0169] A hidden representation acquisition unit, used to call the encoder to process the sequence vector representation and the position encoding information to obtain a hidden representation corresponding to the pod time series feature;

[0170] A predicted resource information acquisition unit, configured to call the decoder to decode the hidden representation to obtain predicted resource occupancy information of the pod;

[0171] A loss value calculation unit, configured to calculate a loss value of the pod expansion and contraction prediction model to be trained according to the predicted resource occupancy information and the annotated resource occupancy information of the pod;

[0172] The expansion and contraction prediction model acquisition unit is used to obtain the final pod expansion and contraction prediction model when the loss value is within a preset range.

[0173] Optionally, the encoder comprises: a self-attention mechanism layer and a feedforward neural network layer,

[0174] The hidden representation acquisition unit comprises:

[0175] An initial hidden representation acquisition subunit is used to call the self-attention mechanism layer to process the sequence vector representation according to the position encoding information to obtain the importance weights of elements at different positions, and perform weighted average processing on the sequence vector representation according to the importance weights to obtain the initial hidden representation;

[0176] The hidden representation acquisition subunit is used to call the feedforward neural network layer to perform linear transformation and nonlinear activation processing on the initial hidden representation to obtain the hidden representation.

[0177] Optionally, the device further comprises:

[0178] A target resource data acquisition module is used to acquire target resource usage data of a target pod to be predicted in a preset period, where the preset period is a period from a specified time to the current time;

[0179] A target resource data decomposition module, used to decompose the target resource usage data based on the STL algorithm to obtain trend information and cycle information of the target pod;

[0180] A time series feature extraction module, used to extract the time series features corresponding to the target pod from the trend information and the period information;

[0181] A predicted resource information acquisition module, used to call the pod expansion and contraction prediction model to process the time series features to obtain the predicted resource occupancy information of the target pod at a future target time;

[0182] The expansion and contraction processing module is used to perform expansion and contraction processing on the target pod at the target time in the future based on the predicted resource occupancy information.

[0183] Optionally, the expansion and contraction processing module includes:

[0184] An actual resource information acquisition unit, used to acquire actual resource occupancy information of the target pod at the current time;

[0185] A capacity reduction processing unit, configured to reduce the capacity of the target pod when the target time is reached if the actual resource occupancy information is greater than the predicted resource occupancy information;

[0186] The capacity expansion processing unit is used to expand the capacity of the target pod when the target time is reached if the actual resource occupancy information is less than the predicted resource occupancy information.

[0187] The training device of the pod expansion and contraction prediction model provided in the embodiment of the present application obtains the historical resource usage data of the pod. The historical resource usage data is decomposed based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod. The pod time series features in the resource occupancy trend information and the resource occupancy cycle information are extracted. The pod expansion and contraction prediction model is obtained based on the pod time series feature training. The embodiment of the present application combines the STL time series decomposition and the expansion and contraction prediction model to train the expansion and contraction prediction model. This method can better capture the trend and seasonality of the pod resource demand, and based on the prediction of the pod expansion and contraction, it can improve the accuracy of the pod expansion and contraction prediction, and can provide more efficient, intelligent and reliable expansion and contraction capabilities, thereby improving the performance of containerized applications and the user experience.

[0188] An embodiment of the present application also provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the training method of the above-mentioned pod expansion and contraction prediction model when executed by the processor.

[0189] Figure 6 FIG. 6 is a schematic diagram showing the structure of an electronic device 600 according to an embodiment of the present invention. Figure 6 As shown, the electronic device 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 602 or computer program instructions loaded from a storage unit 608 into a random access memory (RAM) 603. In RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. CPU 601, ROM 602 and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0190] Multiple components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, a microphone, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0191] The various processes and processing described above may be performed by the processing unit 601. For example, the method of any of the above embodiments may be implemented as a computer software program, which is tangibly contained in a computer-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the CPU 601, one or more actions in the method described above may be performed.

[0192] In addition, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the training method of the above-mentioned pod expansion and contraction prediction model is implemented.

[0193] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0194] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or terminal including the elements.

[0195] The training method, device, equipment and medium of a pod expansion and contraction prediction model provided by the present application are introduced in detail above. The principle and implementation mode of the present application are explained by using specific examples in this article. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present application.

Claims

1. A training method for a pod expansion and contraction prediction model, characterized in that: The method comprises: Get the historical resource usage data of the pod; Decomposing the historical resource usage data based on the STL algorithm to obtain resource occupancy trend information and resource occupancy cycle information of the pod; Extracting pod time series features from the resource occupancy trend information and the resource occupancy cycle information; The pod expansion and contraction prediction model is obtained by training based on the pod time series features.

2. The method according to claim 1, characterized in that Decomposing the historical resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod includes: Performing data preprocessing on the historical resource usage data to obtain time-continuous pod resource usage data; The time-continuous pod resource usage data is decomposed based on the STL algorithm to obtain resource occupancy trend information and resource occupancy cycle information of the pod.

3. The method according to claim 1, characterized in that The extracting of pod time series features from the resource occupancy trend information and the resource occupancy cycle information includes: Obtaining a mean, a variance, and a slope corresponding to the resource occupancy trend information, and amplitude information and phase information corresponding to the resource occupancy period information; The pod time series feature is obtained according to the mean, the variance, the slope, the amplitude information, the phase information, and the corresponding timestamp information.

4. The method according to claim 1, characterized in that: The pod expansion and contraction prediction model is obtained by training based on the pod time series features, including: Inputting the pod time series features into a pod scaling prediction model to be trained, wherein the pod scaling prediction model to be trained includes: an embedding layer, a position encoding layer, an encoder, and a decoder; Calling the embedding layer to encode the pod time series features to obtain a sequence vector representation corresponding to the pod time series features; Calling the position coding layer to perform position coding on the pod time series features by using sine coding and cosine coding to obtain position coding information; Calling the encoder to process the sequence vector representation and the position encoding information to obtain a hidden representation corresponding to the pod time series feature; Calling the decoder to decode the hidden representation to obtain predicted resource occupancy information of the pod; Calculate the loss value of the pod expansion and contraction prediction model to be trained according to the predicted resource occupancy information and the annotated resource occupancy information of the pod; When the loss value is within a preset range, the final pod expansion and contraction prediction model is obtained.

5. The method according to claim 4, characterized in that The encoder includes: a self-attention mechanism layer and a feedforward neural network layer, The calling of the encoder to process the sequence vector representation and the position encoding information to obtain a hidden representation corresponding to the pod time series feature includes: Calling the self-attention mechanism layer to process the sequence vector representation according to the position encoding information to obtain the importance weights of elements at different positions, and performing weighted average processing on the sequence vector representation according to the importance weights to obtain an initial hidden representation; The feedforward neural network layer is called to perform linear transformation and nonlinear activation processing on the initial hidden representation to obtain the hidden representation.

6. The method according to claim 1, characterized in that After the pod expansion and contraction prediction model is obtained through training based on the pod time series features, the method further includes: Obtain target resource usage data of the target pod to be predicted in a preset time period, where the preset time period is a period from a specified time to the current time; Decomposing the target resource usage data based on the STL algorithm to obtain trend information and cycle information of the target pod; Extracting a time series feature corresponding to the target pod from the trend information and the period information; The pod expansion and contraction prediction model is called to process the time series features to obtain predicted resource occupancy information of the target pod at a future target time. The target pod is scaled up or down based on the predicted resource occupancy information at the target time in the future.

7. The method according to claim 6, characterized in that The scaling of the target pod at the target time in the future based on the predicted resource occupancy information includes: Obtain the actual resource usage information of the target pod at the current time; When the actual resource occupancy information is greater than the predicted resource occupancy information, the target pod is scaled down when the target time is reached; When the actual resource occupancy information is less than the predicted resource occupancy information, the target pod is expanded when the target time is reached.

8. A training device for a pod expansion and contraction prediction model, characterized in that: The device comprises: The historical resource data acquisition module is used to obtain the historical resource usage data of the pod; A trend cycle information acquisition module, used to decompose the historical resource usage data based on the STL algorithm to obtain the resource occupancy trend information and resource occupancy cycle information of the pod; A time series feature extraction module, used to extract pod time series features from the resource occupancy trend information and the resource occupancy cycle information; The expansion and contraction prediction model acquisition module is used to obtain the pod expansion and contraction prediction model based on the pod time series feature training.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the training method of the pod expansion and contraction prediction model described in any one of claims 1 to 7 when executing the program.

10. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the pod expansion and contraction prediction model described in any one of claims 1 to 7.