A Kubernetes-based load prediction elastic scaling system and method
By constructing the Prophet-LSTM model and using covariance matrix analysis, the problems of load judgment lag and single resource prediction in Kubernetes' built-in strategies are solved, realizing comprehensive load prediction and dynamic scaling for multiple resources, and improving Kubernetes' load prediction elastic scaling capabilities.
Patent Information
- Application Number
- CN202310617633.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2043-05-29
AI Technical Summary
Kubernetes' built-in elastic scaling strategy suffers from load assessment lag due to reactive scaling methods. The ARIMA model has high requirements for the stability of time-series data and predicts only a single resource. The method proposed by Yang Mao et al. does not fully consider other types of resources on the node.
A Prophet-LSTM load forecasting model combined with covariance matrix analysis is used to obtain various resource load data through the Prometheus monitoring service, establish a comprehensive load rate (CLR), and use the Prophet and LSTM combined model for prediction to generate dynamic scaling strategies.
It improves the accuracy and adaptability of load forecasting, overcomes the limitations of the ARIMA model, provides more reliable forecast results, ensures service quality, and optimizes resource utilization.
Smart Images

Figure CN116610416B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing technology, and in particular to a load prediction elastic scaling system and method based on Kubernetes. Background Technology
[0002] Kubernetes is a Docker container orchestration system that provides resource scheduling, automated deployment, service discovery, elastic scaling, and resource monitoring services for containerized applications. Kubernetes' built-in elastic scaling strategy is HPA, which works by collecting the CPU utilization of Pods and comparing the current value with a predefined expected value to perform scaling up or down operations. However, HPA uses a reactive scaling approach, which lags in assessing the actual load on Pods, leading to inaccuracies in the final calculation results.
[0003] To address the lag issue of HPA strategies, Xie Wenzhou et al. proposed an elastic scaling method based on the ARIMA model to predict resource load. The ARIMA model is trained based on historical resource load characteristics of CPU and memory, providing an important reference for Kubernetes in current resource allocation, reducing the number of times applications on nodes are forcibly shut down due to resource usage exceeding thresholds, and improving resource utilization. Yang Mao et al. proposed a scaling technique combining exponential smoothing and grey prediction, aiming to improve the predictive ability of system load and thus more accurately grasp the timing of scaling up and down.
[0004] The ARIMA-based load forecasting model proposed by Xie Wenzhou et al. has a drawback: the ARIMA model requires the stability of the input time-series data, making it unsuitable for situations where the time-series data exhibits a stable increase or is easily affected by external factors. The scaling technique combining exponential smoothing and grey prediction proposed by Yang Mao et al. has a drawback: this method only considers CPU as a forecasting indicator and does not adequately consider other types of node resources, resulting in a relatively singular judgment dimension. Summary of the Invention
[0005] To address the shortcomings of the prior art, this invention provides a load prediction elastic scaling system and method based on Kubernetes.
[0006] A load prediction-based elastic scaling system based on Kubernetes includes the following modules:
[0007] Load monitoring module: Uses Prometheus monitoring service to achieve comprehensive monitoring of Kubernetes cluster, including obtaining load data of Pod node CPU utilization, memory utilization, disk I / O and network I / O, and calculating the overall load rate;
[0008] Load prediction module: Establishes a Prophet-LSTM load prediction model, uses the Prophet-LSTM load prediction model to analyze and predict the load data of each node in the cluster, and sends the prediction data to the elastic scaling module.
[0009] Load data storage module: Uses InfluxDB open-source time series database to store load data for each node and container;
[0010] Elastic scaling module: Based on the node load predicted by the load prediction module for the next time moment, it performs interval comparison and then notifies the Kubemetes scheduler to increase or decrease the number of service container replicas.
[0011] A load prediction-based elastic scaling method based on Kubernetes, implemented based on the aforementioned load prediction-based elastic scaling system based on Kubernetes, specifically includes the following steps:
[0012] Step 1: Collect load data for all Pod nodes in the Kubernetes cluster;
[0013] Step 2: Calculate the Comprehensive Load Rate (CLR) using the collected load data to obtain the comprehensive load rate at each time point;
[0014] Step 3: Use the Prophet-LSTM combined model to analyze the overall load rate, construct a load prediction model for the overall load rate, obtain the pattern of the overall load rate, and obtain the predicted overall load rate;
[0015] Step 4: Based on the predicted overall load rate and the current overall load rate, generate a dynamic scaling strategy to obtain the dynamic scaling quantity. The Kubernetes scheduler then configures scaling up or down in advance based on the dynamic scaling quantity.
[0016] Furthermore, step 1 specifically includes the following steps:
[0017] Step 1.1: Use kube-state-metrics and cAdvisor to collect load data of each node and container in real time to obtain the load data of the service;
[0018] Step 1.2: Deploy the Prometheus monitoring service, pull the load data of each node, and store it in the InfluxDB time series database.
[0019] Furthermore, step 2 specifically includes the following steps:
[0020] Step 2.1: Read load data from the time-series database, including CPU utilization, memory usage, disk I / O, and network I / O;
[0021] Step 2.2: Preprocess the load data. If there are missing values at individual times in the original load data, fill them with the average load values of the preceding and following time points. If there is a missing period, discard these missing values. If there are outliers in the original load data, remove them according to the Raida criterion.
[0022] Step 2.3: Define the Overall Load Rate (CLR) of a Pod, using CLR as a metric for Pod scaling. Define the CPU usage at time t as... Memory usage is defined as Disk I / O usage is defined as Network I / O usage is defined as The formula for calculating the overall load factor CLRt at time t is as follows:
[0023]
[0024] ω cpu +ω mem +ω disk +ω net =1
[0025] Where, ω cpn ω mem ω disk ω net The weights of CPU, memory, disk I / O, and network I / O in the overall load rate are respectively determined. Principal component analysis is used to divide the load weights of each resource based on historical load data, calculate the overall load rate CLRt at time t, and store it in the time series database.
[0026] Furthermore, step 3 specifically includes the following steps:
[0027] Step 3.1: Define the input sequence data as the comprehensive load rate at multiple time points; set the input sequence data as the comprehensive load rate of length Q, i.e., Q seconds, set the current time point as T, take Q comprehensive load rates in the range [T-Q+1,T] as input sequence data, divide the input sequence data into training set and validation set according to time order, use the first 80% of the data as training set and the last 20% of the data as validation set;
[0028] Step 3.2: Establish the Prophet model. Prophet is a model for predicting time series data based on an additive model. The model consists of three superimposed components: a trend term (growth), a periodicity term (seasonality), and a holiday term (holidays). The basic form of the predicted value y(t) is expressed as:
[0029] y(t)=g(t)+s(t)+h(t)+ε t
[0030] Among them, e t The term s(t) represents random fluctuations; s(t) is a periodic term, which is approximately expressed using a Fourier series, specifically in the form:
[0031]
[0032] Where p is the period length of the time series; N is the number of periods; a n b n The smoothing parameter is n; n is a natural number.
[0033] h(t) is the holiday term. The impact of each holiday at different times is treated as an independent model, and a dummy variable is set for each independent model. The holiday term h(t) can be expressed as:
[0034] h(t)=Z(t)κ
[0035] Z(t)=[l(t∈D1),...,l(t∈D i )]
[0036] κ∈Normal(0, v 2 )
[0037] Where Z(t) is an exponential function; l is the duration of the holiday or festival; D i Let be the set of past and future times for the i-th holiday, i = 1, 2, ..., L; κ is a parameter set for each holiday; v is the influence of the holiday, the larger v is, the greater the influence of the holiday; Normal is the normal distribution function.
[0038] g(t) is the trend term, and the logistic growth model is used. Its basic form is as follows:
[0039]
[0040]
[0041] Where C(t) is the saturation value that varies with time, i.e., the bearing capacity; k+a(t) T δ represents the growth rate over time; Sj δ represents the inflection point; m is the offset; δ is the change in growth rate at the inflection point; a(t) is the indicator function; a(t) T Let be the transpose of a(t); γ is the vector of s. j Smoothing offset at the location;
[0042] The pre-defined training set is input into the Prophet model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained Prophet model and obtain the corresponding predicted overall load rate.
[0043] Step 3.3: Establish the LSTM model. The Long Short-Term Memory (LSTM) artificial neural network is divided into long-term memory and short-term memory, where long-term memory uses c. t To represent, i.e., unit state, short-term memory is represented by h. t To represent, i.e., output; an LSTM with a peephole connection needs to be based on the input x at time t. t Short-term memory at time t-1 t-1 and the cell state c at time t-1 t--1 To update the cell state c at time t t The update is achieved through a forget gate, an input gate, and an output gate, with the calculation formulas as follows:
[0044] i t =σ(W xi x t +W hi h t-1 +W ci c t-1 +b i )
[0045] f t =σ(W xf x t +W hf h t-1 +W cf c t-1 +b f )
[0046] c t =f t c t--1 +i t tanh(W xc x t +W hc h t-1 +b c )
[0047] o t =σ(W xo xt +W ho h t-1 +W co c t +b o )
[0048] h t =o t tanh(c t )
[0049] Among them, i t For the Gate of Oblivion; f t For input gate; o t This is the output gate; σ and tanh are both activation functions, σ is the sigmoid function; tanh is the hyperbolic tangent activation function; W xi W xf W xo W xc These are the forget gate, input gate, output gate, and cell state with respect to input x. t The weight coefficient matrix; W hi W hf W ho W hc These are the forget gate, input gate, output gate, and cell state with respect to time t-1, h. t-1 The weight coefficient matrix; W ci W cf W co These are the weight coefficient matrices of the forget gate, input gate, and output gate with respect to the cell state, respectively; b i b f b o b c These are the bias vectors for the forget gate, input gate, output gate, and cell state, respectively.
[0050] The pre-defined training set is input into the LSTM model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained LSTM model and obtain the corresponding predicted overall load rate.
[0051] Step 3.4: Establish the Prophet-LSTM load forecasting model. Define the predicted combined load rates of Prophet and LSTM at time t as P1(t) and P2(t), respectively. Let the weight of Prophet be α1 and the weight of LSTM be α2. After linearly weighting the Prophet model and the LSTM model, construct the Prophet-LSTM load forecasting model. Define the final predicted combined load rate at time t obtained by the Prophet-LSTM load forecasting model as P(t):
[0052] P(t) = α1P1(t) + α2P2(t)
[0053] α1+α2=1
[0054] Step 3.5: Determine the weights α1 and α2 using covariance matrix analysis, and express P(t) in vector form as follows:
[0055]
[0056] Let C be the covariance matrix of P1(t) and P2(t). Then C is expressed as:
[0057] C=E[(P1(t)-E[P1(t)])(P2(t)E[P2(t)])]
[0058] Where E[P1(t)] and E[P2(t)] are the expected values of P1(t) and P2(t), respectively;
[0059] The variance var[P(t)] of P(t) can be represented by the covariance matrix as follows:
[0060]
[0061] The weights α1 and α2 are solved using the Lagrange multiplier method, and a Lagrange function is constructed.
[0062]
[0063] Where λ is the Lagrange multiplier;
[0064] Find the solutions where the partial derivatives of the Lagrange function are equal to 0, as shown below:
[0065]
[0066]
[0067]
[0068] Thus, the solutions for weights α1 and α2 are obtained, and the predicted overall load factor is obtained.
[0069] Step 3.6: Store the predicted overall load factor into the time series database.
[0070] Furthermore, step 4 specifically includes the following steps:
[0071] Step 4.1: Obtain the predicted overall load factor and the current overall load factor from the time series database;
[0072] Step 4.2: Define the current overall load factor as Cu(t). The Kubernetes scheduler determines whether scaling up or down is needed based on whether Cu(t) falls within the specified range. Define the predicted overall load factor m seconds later as P(t+m), where m∈[5,10]. This range is represented as:
[0073] P(t+m)-P(t+m)*10%≤Cu(t)≤P(t+m)+P(t+m)*10%
[0074] No expansion or contraction operation is performed when Cu(t) is within the range; otherwise, expansion or contraction operation is performed.
[0075] Step 4.3: Calculate the DR to perform dynamic scaling, and modify the number of container replicas in a timely manner. The formula for calculating the number of Pods is expressed as:
[0076]
[0077] Here, DR stands for Desired Replicas, which refers to the number of replicas required for the final result; Ceil is a rounding function; and CR stands for Current Replicas, which refers to the current number of replicas.
[0078] The beneficial effects of adopting the above technical solution are as follows:
[0079] This invention proposes a load prediction-based elastic scaling system and method based on Kubernetes. It utilizes a load prediction model, Prophet-LSTM, combining Prophet and a Long Short-Term Memory (LSTM) artificial neural network for prediction. The final load prediction model is determined using covariance matrix analysis. It leverages various resource load characteristics of Pods for prediction and establishes a dynamic container scaling strategy, thereby improving service quality. The Prophet-LSTM load prediction model overcomes the limitation of ARIMA models requiring autocorrelation, breaking the limitation of only predicting phenomena and scenarios related to its own past performance. It can adapt to changes in the dataset and the presence of outliers, providing more reliable prediction results in some situations. Finally, based on threshold comparisons, it determines whether to scale up or down.
[0080] This invention addresses the issues of a single metric and response latency in Kubernetes' built-in elastic scaling mechanism by proposing an improved elastic scaling strategy. This strategy improves upon the single metric problem of the built-in elastic scaling mechanism by defining the Comprehensive Load Rate (CLR) as a predictive metric, effectively measuring the overall load level of complex applications. Simultaneously, it uses the Prophet-LSTM load prediction model to predict the application's current CLR, scaling in advance to ensure service quality. This prediction model is more adaptable to handling complex time series data compared to the ARIMA prediction model. Attached Figure Description
[0081] Figure 1 This is a diagram illustrating the overall framework of the Kubernetes-based load prediction elastic scaling method and system in this invention.
[0082] Figure 2 This is a diagram of the Prophet-LSTM load prediction model architecture in this invention. Detailed Implementation
[0083] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0084] In this embodiment, as Figure 1 As shown, a load prediction elastic scaling system based on Kubernetes includes the following modules:
[0085] Load monitoring module: Uses Prometheus monitoring service to achieve comprehensive monitoring of Kubernetes cluster, including obtaining load data of Pod node CPU utilization, memory utilization, disk I / O and network I / O, and calculating the overall load rate;
[0086] Load prediction module: Establishes a Prophet-LSTM load prediction model, uses the Prophet-LSTM load prediction model to analyze and predict the load data of each node in the cluster, and sends the predicted data to the elastic scaling module to provide a basis for the elastic scaling of the cluster.
[0087] Load data storage module: Uses InfluxDB open-source time series database to store load data for each node and container;
[0088] The elastic scaling module compares the node load predicted by the load prediction module for the next moment within a range, and then notifies the Kubernetes scheduler to increase or decrease the number of service container replicas to ensure efficient system operation.
[0089] like Figure 1As shown in this embodiment, a Kubernetes-based load predictive elastic scaling method, implemented based on the aforementioned Kubernetes-based load predictive elastic scaling system, specifically includes the following steps:
[0090] Step 1: Collect load data for all Pod nodes in the Kubernetes cluster;
[0091] Step 1.1: Use kube-state-metrics and cAdvisor to collect load data of each node and container in real time to obtain the load data of the service;
[0092] Step 1.2: Deploy the Prometheus monitoring service, pull the load data of each node, and store it in the InfluxDB time series database.
[0093] Step 2: Calculate the Comprehensive Load Rate (CLR) using the collected load data to obtain the comprehensive load rate at each time point;
[0094] Step 2.1: Read load data from the time-series database, including CPU utilization, memory usage, disk I / O, and network I / O;
[0095] Step 2.2: Preprocess the load data. If there are missing values at individual times in the original load data, fill them with the average load values of the preceding and following time points. If there is a missing period, discard these missing values. If there are outliers in the original load data, remove them according to the Raida criterion.
[0096] Step 2.3: Define the Overall Load Rate (CLR) of a Pod, using CLR as a metric for Pod scaling. Define the CPU usage at time t as... Memory usage is defined as Disk I / O usage is defined as Network I / O usage is defined as The formula for calculating the overall load factor CLRt at time t is as follows:
[0097]
[0098] ω cpu +ω mem +ω disk +ω net =1
[0099] Where, ω cpn ω mem ω disk ω netThe weights of CPU, memory, disk I / O, and network I / O in the overall load rate are defined, respectively. Principal component analysis is used to assign load weights to each resource based on historical load data, and the overall load rate (CLR) at time t is calculated. t And store it in a time series database.
[0100] Step 3: Analyze the overall load factor using the Prophet-LSTM combined model, construct a load prediction model for the overall load factor, obtain the pattern of the overall load factor, and obtain the predicted overall load factor. In this embodiment, as shown... Figure 2 As shown;
[0101] Step 3.1: Define the input sequence data as the comprehensive load rate at multiple time points; set the input sequence data as the comprehensive load rate of length Q, i.e., Q seconds, set the current time point as T, and take Q comprehensive load rates in the range [T-Q+1,T] as the input sequence data. In this embodiment, Q is 180. Divide the input sequence data into training set and validation set according to time order, using the first 80% of the data as the training set and the last 20% of the data as the validation set.
[0102] Step 3.2: Establish the Prophet model. Prophet is a model for predicting time series data based on an additive model. The model consists of three superimposed components: a trend term (growth), a periodicity term (seasonality), and a holiday term (holidays). The basic form of the predicted value y(t) is expressed as:
[0103] y(t)=g(t)+s(t)+h(t)+ε t
[0104] Where, ε t The term s(t) represents random fluctuations; s(t) is a periodic term, which is approximately expressed using a Fourier series, specifically in the form:
[0105]
[0106] Where p is the period length of the time series; N is the number of periods; a n b n The smoothing parameter is n; n is a natural number.
[0107] h(t) is the holiday term. The impact of each holiday at different times is treated as an independent model, and a dummy variable is set for each independent model. The holiday term h(t) can be expressed as:
[0108] h(t)=Z(t)κ
[0109] Z(t)=[l(t∈D1),...,l(t∈D i )]
[0110] κ∈Normal(0, v 2 )
[0111] Where Z(t) is an exponential function; l is the duration of the holiday or festival; D i Let be the set of past and future times for the i-th holiday, i = 1, 2, ..., L; κ is a parameter set for each holiday; v is the influence of the holiday, the larger v is, the greater the influence of the holiday; Normal is the normal distribution function.
[0112] g(t) is the trend term, and the logistic growth model is used. Its basic form is as follows:
[0113]
[0114]
[0115] Where C(t) is the saturation value that varies with time, i.e., the bearing capacity; k+a(t) T δ represents the growth rate over time; s j δ represents the inflection point; m is the offset; δ is the change in growth rate at the inflection point; a(t) is the indicator function; a(t) T Let be the transpose of a(t); γ is the vector of s. j Smoothing offset at the location;
[0116] The pre-defined training set is input into the Prophet model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained Prophet model and obtain the corresponding predicted overall load rate.
[0117] Step 3.3: Establish the LSTM model. The Long Short-Term Memory (LSTM) artificial neural network is divided into long-term memory and short-term memory, where long-term memory uses c. t To represent, i.e., unit state, short-term memory is represented by h. t To represent, i.e., output; an LSTM with a peephole connection needs to be based on the input x at time t. t Short-term memory at time t-1 t-1 and the cell state c at time t-1 t--1 To update the cell state c at time t t The update is achieved through a forget gate, an input gate, and an output gate, with the calculation formulas as follows:
[0118] i t =σ(W xi x t +W hi h t-1 +Wci c t-1 +b i )
[0119] f t =σ(W xf x t +W hf h t-1 +W cf c t-1 +b f )
[0120] c t =f t c t--1 +i t tanh(W xc x t +W hc h t-1 +b c )
[0121] o t =σ(W xo x t +W ho h t-1 +W co c t +b o )
[0122] h t =o t tanh(c t )
[0123] Among them, i t For the Gate of Oblivion; f t For input gate; o t This is the output gate; σ and tanh are both activation functions, σ is the sigmoid function; tanh is the hyperbolic tangent activation function; W xi W xf W xo W xc These are the forget gate, input gate, output gate, and cell state with respect to input x. t The weight coefficient matrix; W hi W hf W ho W hc These are the forget gate, input gate, output gate, and cell state with respect to time t-1, h. t-1 The weight coefficient matrix; W ci W cf W co These are the weight coefficient matrices of the forget gate, input gate, and output gate with respect to the cell state, respectively; b i bf b o b c These are the bias vectors for the forget gate, input gate, output gate, and cell state, respectively.
[0124] The pre-defined training set is input into the LSTM model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained LSTM model and obtain the corresponding predicted overall load rate.
[0125] Step 3.4: Establish the Prophet-LSTM load forecasting model. Define the predicted combined load rates of Prophet and LSTM at time t as P1(t) and P2(t), respectively. Let the weight of Prophet be α1 and the weight of LSTM be α2. After linearly weighting the Prophet model and the LSTM model, construct the Prophet-LSTM load forecasting model. Define the final predicted combined load rate at time t obtained by the Prophet-LSTM load forecasting model as P(t):
[0126] P(t) = α1P1(t) + α2P2(t)
[0127] α1+α2=1
[0128] Step 3.5: Determine the weights α1 and α2 using covariance matrix analysis, and express P(t) in vector form as follows:
[0129]
[0130] Let C be the covariance matrix of P1(t) and P2(t). Then C is expressed as:
[0131] C=E[(P1(t)E[P1(t)])(P2(t)E[P2(t)])]
[0132] Where E[P1(t)] and E[P2(t)] are the expected values of P1(t) and P2(t), respectively;
[0133] The variance var[P(t)] of P(t) can be represented by the covariance matrix as follows:
[0134]
[0135] The weights α1 and α2 are solved using the Lagrange multiplier method, and a Lagrange function is constructed.
[0136]
[0137] Where λ is the Lagrange multiplier;
[0138] Find the solutions where the partial derivatives of the Lagrange function are equal to 0, as shown below:
[0139]
[0140]
[0141]
[0142] Thus, the solutions for weights α1 and α2 are obtained, and the predicted overall load factor is obtained.
[0143] Step 3.6: Store the predicted overall load factor into the time series database.
[0144] Step 4: Based on the predicted overall load rate and the current overall load rate, generate a dynamic scaling strategy to obtain the dynamic scaling quantity. The Kubernetes scheduler then configures scaling up or down in advance based on the dynamic scaling quantity.
[0145] Step 4.1: Obtain the predicted overall load factor and the current overall load factor from the time series database;
[0146] Step 4.2: Define the current overall load factor as Cu(t). The Kubernetes scheduler determines whether scaling up or down is needed based on whether Cu(t) falls within the specified range. Define the predicted overall load factor m seconds later as P(t+m), where m∈[5,10]. This range is represented as:
[0147] P(t+m)-P(t+m)*10%≤Cu(t)≤P(t+m)+P(t+m)*10%
[0148] No expansion or contraction operation is performed when Cu(t) is within the range; otherwise, expansion or contraction operation is performed.
[0149] In this embodiment, m is set to 5, meaning the predicted overall load rate after 5 seconds is P(t+5), and this interval is represented as...
[0150] P(t+5)-P(t+5)*10%≤Cu(t)≤P(t+5)+P(t+5)*10%
[0151] No expansion or contraction operation is performed when Cu(t) is within the range; otherwise, expansion or contraction operation is performed.
[0152] Step 4.3: Calculate the DR to perform dynamic scaling, and modify the number of container replicas in a timely manner. The formula for calculating the number of Pods is expressed as:
[0153]
[0154] Here, DR stands for Desired Replicas, which refers to the number of replicas required for the final result; Ceil is a rounding function; and CR stands for Current Replicas, which refers to the current number of replicas.
[0155] In summary, this embodiment mainly implements a load prediction elastic scaling system and method based on Kubernetes. Specifically, it constructs a combined prediction model, Prophet-LSTM, which combines Prophet and Long Short-Term Memory (LSTM) artificial neural networks for prediction. The final prediction model is determined using covariance matrix analysis. The Prophet-LSTM combined model overcomes the limitation of ARIMA models requiring autocorrelation of data, breaking the limitation of only predicting phenomena and scenarios related to its own past performance. It can adapt to changes in the dataset and the existence of outliers, providing more reliable prediction results in some cases. Finally, based on threshold comparison, it determines whether to scale up or down.
[0156] This embodiment addresses the issues of single metrics and response latency in Kubernetes' built-in elastic scaling mechanism by proposing an improved elastic scaling strategy. This strategy effectively measures the overall load level of complex applications by defining a comprehensive load assessment metric, CLR. Simultaneously, it uses a Prophet-LSTM prediction model to predict the application's current CLR, scaling in advance to ensure service quality. This prediction model is better suited to handling complex time series data compared to the ARIMA prediction model.
[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A load prediction-based elastic scaling method based on Kubernetes, characterized by: The process includes the following: Step 1: Collect load data for all Pod nodes in the Kubernetes cluster; Step 2: Calculate the Comprehensive Load Rate (CLR) using the collected load data to obtain the comprehensive load rate at each time point; Step 2.1: Read load data from the time-series database, including CPU utilization, memory usage, disk I / O, and network I / O; Step 2.2: Preprocess the load data. If there are missing values at individual times in the original load data, fill them with the average load values of the preceding and following time points. If there is a missing period, discard these missing values. If there are outliers in the original load data, remove them according to the Raida criterion. Step 2.3: Define the overall load factor (CLR) of a Pod, and use the CLR as a metric for Pod scaling. Calculate the overall load factor at time t. And store it in a time series database; In step 2.3, the overall load rate at time t is calculated. The method is to define the CPU usage at time t as... Memory usage is defined as Disk I / O usage is defined as Network I / O usage is defined as Then the overall load rate at time t The calculation formula is expressed as: ; ; in, The weights of CPU, memory, disk I / O, and network I / O in the overall load rate are determined, and principal component analysis is used to assign load weights to each resource based on historical load data. Step 3: Use the Prophet-LSTM combined model to analyze the overall load rate, construct a load prediction model for the overall load rate, obtain the pattern of the overall load rate, and obtain the predicted overall load rate; Step 3.1: Define the input sequence data as the combined load rate at multiple time points; set the input sequence data to have a length of... ,Right now The overall load rate in seconds, with the current time point set to... ,Pick common The overall load factor is the input sequence data. The input sequence data is divided into training set and validation set according to time order. The first 80% of the data is used as the training set and the last 20% of the data is used as the validation set. Step 3.2: Build the Prophet model. Prophet is a predictive model for time series data based on an additive model. The model consists of three superimposed components: a trend term (growth), a periodicity term (seasonality), and a holiday term (holidays). The predicted values are... The basic form is expressed as: ; in, It is a random fluctuation term; It is a periodic term, and the periodic component is approximated using a Fourier series, specifically in the form of: ; in, The period length of the time series; The number of cycles; , For smoothing parameters; It is a natural number; The holiday term treats the impact of each holiday at different times as an independent model, assigning a dummy variable to each independent model. Represented as: ; ; ; in, It is an exponential function; The duration of a holiday or festival; For the first A collection of past and future holiday dates. ; A parameter set for each holiday; Due to the influence of holidays, The larger the size, the greater the influence of the holiday. It is a normal distribution function; It is a trend term, using the logistic growth model, and its basic form is as follows: ; ; in, This is the saturation value that changes over time, i.e., the load-bearing capacity; The growth rate over time; This marks a turning point; This is the offset; This represents the change in the growth rate at the inflection point. For indicator functions; for The transpose of ; for Smoothing offset at the location; The pre-defined training set is input into the Prophet model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained Prophet model and obtain the corresponding predicted overall load rate. Step 3.3: Establish the LSTM model. The Long Short-Term Memory (LSTM) artificial neural network is divided into long-term memory and short-term memory, with long-term memory using... To represent, i.e., unit state, short-term memory uses To represent, i.e., output; LSTMs with peephole connections need to be based on t Input of time , Short-term memory of moments and Unit state at time Update t Unit state at time The update is achieved through a forget gate, an input gate, and an output gate, with the calculation formulas as follows: ; ; ; ; ; in, Forgotten Gate; For input gates; For output gate; and They are all activation functions. It is the sigmoid function; It is the hyperbolic tangent activation function; , , , These are the forget gate, input gate, output gate, and cell state with respect to the input. The weight coefficient matrix; , , , These are the forget gate, input gate, output gate, and cell state related to... time The weight coefficient matrix; , , These are the weight coefficient matrices of the forget gate, input gate, and output gate with respect to the cell state, respectively. , , , These are the bias vectors for the forget gate, input gate, output gate, and cell state, respectively. The pre-defined training set is input into the LSTM model for training. After determining the initial model, the pre-defined validation set is used to evaluate and adjust the model parameters to build the trained LSTM model and obtain the corresponding predicted overall load rate. Step 3.4: Establish the Prophet-LSTM load forecasting model, defining the predicted combined load factor of Prophet and LSTM at time t as follows: and Let the weight of Prophet be The weights of LSTM are A Prophet-LSTM load forecasting model is constructed by linearly weighting the Prophet model and the LSTM model. The final predicted overall load rate at time t obtained by the Prophet-LSTM load forecasting model is defined as... : ; ; Step 3.5: Determine the weights using covariance matrix analysis. , ,Will In vector form: ; definition and The covariance matrix is ,but Represented as: ; in, and They are respectively and Expected value; variance Represented by the covariance matrix: ; The weights are determined using the Lagrange multiplier method. and Construct a Lagrange function : ; in, It is a Lagrange multiplier; Find the solutions where the partial derivatives of the Lagrange function are equal to 0, as shown below: ; ; ; Thus, the weights are obtained. , The solution is then used to obtain the predicted overall load factor; Step 3.6: Store the predicted overall load factor into the time series database; Step 4: Based on the predicted overall load rate and the current overall load rate, generate a dynamic scaling strategy to obtain the dynamic scaling quantity. The Kubernetes scheduler then configures scaling up or down in advance based on the dynamic scaling quantity.
2. The load prediction elastic scaling method based on Kubernetes according to claim 1, characterized in that: Step 1 specifically also includes: Step 1.1: Use kube-state-metrics and cAdvisor to collect load data of each node and container in real time to obtain the load data of the service; Step 1.2: Deploy the Prometheus monitoring service, pull the load data of each node, and store it in the InfluxDB time series database.
3. The load prediction elastic scaling method based on Kubernetes according to claim 2, characterized in that: Step 4 specifically also includes: Step 4.1: Obtain the predicted overall load factor and the current overall load factor from the time series database; Step 4.2: Define the current overall load factor. The Kubernetes scheduler is based on Whether to perform expansion or contraction operations within the specified range is defined. The predicted overall load rate after seconds is ,in The interval is represented as: ; when Do not perform expansion or contraction operations when the range is within the specified range; otherwise, perform expansion or contraction operations. Step 4.3: Calculation Dynamic scaling is implemented, and the number of container replicas is modified in a timely manner. The formula for calculating the number of Pods is as follows: ; in, Desired Replicas refers to the number of replicas required for the final result; It is an integer function; Current Replicas refers to the current number of replicas.
4. A Kubernetes-based load predictive elastic scaling system, used to implement the Kubernetes-based load predictive elastic scaling method as described in any one of claims 1-3, characterized in that: Includes the following modules: Load monitoring module: Uses Prometheus monitoring service to achieve comprehensive monitoring of Kubernetes cluster, including obtaining load data of Pod node CPU utilization, memory utilization, disk I / O and network I / O, and calculating the overall load rate; Load prediction module: Establishes a Prophet-LSTM load prediction model, uses the Prophet-LSTM load prediction model to analyze and predict the load data of each node in the cluster, and sends the prediction data to the elastic scaling module. Load data storage module: Uses InfluxDB open-source time series database to store load data for each node and container; The elastic scaling module compares the node load predicted by the load prediction module for the next moment and then notifies the Kubernetes scheduler to increase or decrease the number of service container replicas.
