# ML-Empowered Microservice Workload Prediction by Dual-Regularized Matrix Factorization
## 3 Methodology
### Framework Overview  
We propose the framework of Temporality-Dependency Dual-Regularized Matrix Factorization (TDDRMF) to address the challenges of workload prediction in dynamic microservice environments. TDDRMF leverages matrix factorization to jointly model temporal workload dynamics and inter-microservice dependencies. It employs temporal regularization to capture multi-scale temporal patterns and nuclear norm constraints to enforce the low-rank structure of microservice dependencies. Furthermore, a dynamic detection and update mechanism is introduced to adapt to environmental changes effectively. _(a) Matrix Factorization Modeling:_ The workload matrix \(Y\) is factorized into the product of a microservice matrix \(W\) and a temporal feature matrix \(X\)[21]:  
\[Y\approx WX, \tag{1}\]  
where we have the following:* \(W\in\mathbb{R}^{n\times r}\): Represents the dependency relationships among \(n\) microservices, where the rows are \(n\) microservices and the columns are \(r\) latent patterns. \(W\) encodes each service's weights across those patterns, capturing both inter-service dependencies and their collaborative workload. * \(X\in\mathbb{R}^{r\times T}\): Represents the temporal dynamics of \(r\) latent features over \(T\) time steps, where the rows are \(r\) latent patterns and the columns are \(T\) time steps. \(X\) records how each pattern varies over time. _(b) Temporal Dynamics Capturing:_ The temporal feature matrix \(X\) is further decomposed into a trend component and a periodic component [23]: \[X_{T}\approx X_{T}^{\text{trend}}+X_{T}^{\text{period}},\] (2) where we have the following:
* \(X_{T}^{\text{trend}}\): Captures short-term fluctuations using autoregressive modeling;
* \(X_{T}^{\text{period}}\): Extracts periodic patterns, representing recurring behaviors over time. The temporal regularization term is defined as \[R_{\text{AR}}(X)=\frac{1}{2}\sum_{t=d+1}^{T}\|X_{t}-X_{t}^{\text{trend}}-X_{t} ^{\text{period}}\|_{F}^{2}+\frac{\eta}{2}\|X\|_{F}^{2}\] (3) ensuring accurate temporal representation and low complexity. _(c) Low-Rank Dependency Capturing:_ The microservice matrix \(W\) is regularized using the nuclear norm [33] to enforce its low-rank structure: \[N(W)=\|W\|_{*},\] (4) where \(\|\|_{*}\) is the nuclear norm, i.e., the sum of matrix singular values. Nuclear norm regularization can capture tightly knit inter-service dependencies and enhancing model generalization. _(d) Dynamic Detection and Update Mechanism:_ To adapt to changing environments, TDDRMF introduces a dynamic detection mechanism that monitors prediction errors: \[E_{t}=\|Y_{t}-WX_{t}\|_{F}^{2}.\] (5)  
When \(E_{t}\) exceeds a predefined threshold, the microservice matrix \(W\) and temporal feature matrix \(X\) are incrementally updated to maintain prediction accuracy and robustness. _(e) Objective Function:_ The overall optimization objective of TDDRMF is defined as  
\[\mathcal{L}=\frac{1}{2}min\|Y-WX\|_{F}^{2}+\lambda_{1}R_{\text{AR}}(X)+\lambda _{2}N(W), \tag{6}\]  
where we have the following:  
* \(\|Y-WX\|_{F}^{2}\): Measures the prediction error;
* \(R_{\text{AR}}(X)\): Temporal regularization term to capture multi-scale temporal dynamics;
* \(N(W)\): Nuclear norm regularization to enforce low-rank dependencies;
* \(\lambda_{1},\lambda_{2}\): Hyperparameters balancing the contributions of regularization terms. The TDDRMF framework combines temporal dynamics modeling and low-rank dependency capturing, offering accurate workload predictions and robust handling of evolving microservice environments. Figure 1 presents a block diagram of the TDDRMF architecture, depicting the core modules and their interactions from workload decomposition to the prediction of future workloads whose functions are outlined as follows:* (A) Feature Matrix Computation: Compute temporal feature matrix \(X\) from workload matrix \(Y\) that satisfies the periodic and tendency constraints \(A\) and \(B\) obtained by autoregression to fit \(r\) latent workload patterns over time, applying the Adam optimizer.