Full text
Explainable AI for Resource-Efficient Microservice Management in Cloud-Native Networks Lazaros Liatsas Nearby Computing S.L. Barcelona, Spain [email protected] Godfrey M. Kibalya Nearby Computing S.L. Barcelona, Spain godfrey[email protected] Angelos Antonopoulos Nearby Computing S.L. Barcelona, Spain [email protected] Abstract—As the evolution from monolithic service deployments to microservices architectures extends to edge locations with constrained resources, efficient resource management becomes of paramount importance. While AI-driven solutions enable proactive decision-making to satisfy Quality of Service (QoS) requirements, their inherent black-box nature is a limitation that can often lead to overprovisioning and inefficiencies. To address this challenge, we propose a novel framework that leverages eXplainable AI (XAI), specifically counterfactual explanations, to provide insights into the correlation between resources utilization of specific microservices and potential QoS violations. By identifying the microservices most likely to cause issues, our framework enables precise and informed resource allocation decisions. Through extensive simulations, we compare our approach with benchmark schemes, demonstrating that our method achieves more efficient resource utilization while maintaining QoS requirements. Index Terms—XAI, autoscaling, cloud-native, counterfactual explanations, explainable artificial intelligence, microservices, resource allocation, 6G. I. INTRODUCTION Deployment of services in the cloud-edge continuum, related either to network functions or user applications, has experienced a shift from the monolithic system model to microservice-based architectures. Cloud-native Network Functions (CNFs) are a prime example of the application of this architecture’s principles in cloud-native, next generation networks [1]. In the context of 5G and beyond networks, where ultra-low latency, massive connectivity, and high reliability are essential requirements, microservices can provide high levels of modularity and scalability towards more dynamic and robust service lifecycle management. However, compute resources become increasingly limited and costly as we move closer to the edge, making efficient resource management essential to meet the aforementioned requirements. The complex task of allocating compute resources (e.g. CPU and memory) to microservices includes three major challenges: i) the varying levels of dependency between microservices, ii) the microservice sharing between different service chains (SCs), and iii) the highly fluctuating workloads. Static resource allocation during the deployment phase cannot guarantee the Quality of Service (QoS) requirements in the case of under-provisioning, and can easily lead to overprovisioning when resource demands are overestimated. These challenges have motivated the design of dynamic autoscaling mechanisms, where compute resources can dynamically be adjusted according to the microservice’s needs [2]. Horizontal autoscaling methods adjust resources by changing the number of instances (replicas) deployed for each microservice, while vertical autoscaling adjusts the resource limits for already deployed instances. There are also various autoscaling solutions that adopt hybrid solutions by employing both methods [3]. In addition, autoscaling methods can be also categorized as reactive or proactive, based on their capability to forecast future traffic and resource demands. Reactive autoscaling methods scale resources once a resource utilization threshold is reached. However, the time needed by the system to react to a burst of incoming traffic can be critical to service continuity and the required QoS. To tackle this limitation, proactive autoscaling methods leverage workload and resource utilization forecasting to predict future resource demands and allocate the resources in advance. Most of the recent works in this field exploit Artificial Intelligence (AI) for workload prediction, as Deep Learning (DL) models have proven to provide efficient solutions in the field of time-series forecasting. The horizontal autoscaling method proposed in [4] utilizes a Long Short-Term Memory (LSTM) model to predict future workload for each microservice and adjusts the number of replicas according to the predicted requirements. The method uses a predefined threshold of desired utilization to determine the number of required replicas. However, such an approach limits the generalization capability of the model, while determining the scaling threshold requires expert knowledge. The authors in [5] propose a scheme where a Decision Tree Regressor learns to predict the resource demands of each microservice based on their forecasted future workload and a specific response time QoS requirement. However, the method is limited to horizontal autoscaling and microservice dependencies are not regarded. Addressing this limitation, [6] proposes an online scaling and placement schema to jointly take decisions about dependent microservices, based on their forecasted workloads. Furthermore, all the aforementioned methods face challenges that stem from the black-box nature of AI models and their lack of transparency to their decisions. Knowledge on the reasoning behind AI predictions can provide valuable insights towards interpreting their output, hence enhancing its utilization from
the resource management/orchestration system. To address the inherent limitations of AI models, Explainable AI (XAI) has been lately gaining a lot of attention, especially in the network and service management domain. These works, which include resource management [7], zero-touch service management [8] and network slicing [9], focus mainly on generating insights on the inner-workings of AI models to enhance their trustworthiness. In this context, counterfactual explanations is an XAI technique that explores hypothetical “what if" scenarios to clarify model decisions by showing how changes to input data could influence a model’s output [10]. In resource allocation use cases, counterfactual explanations can identify the specific conditions (i.e., CPU and memory allocation) required to guarantee the required QoS. In this paper, we introduce an XAI-driven framework based on counterfactual explanations to provide resource-efficient service management in cloud-native scenarios. Our contribution is threefold: 1) We introduce a proactive autoscaling framework that incorporates workload forecasting, QoS violation prediction and resource allocation optimization based on counterfactual explanations (CFE Autoscaling). 2) We design and implement a customized Genetic Algorithm (GA) towards producing counterfactual explanations as solutions to resource optimization problem. 3) We evaluate our method using a simulator based on realistic microservices profiles from the Alibaba dataset [11], while we identify potential trade-offs compared to baseline reactive and proactive methods. The remainder of the paper is organized as follows: Section II provides our system model. Section III introduces our CFE Autoscaling framework and the GA. In Section IV, we evaluate the proposed scheme, while Section V concludes the paper. II. SYSTEM MODEL In this section, we formalize the problem of autoscaling microservices in cloud-native environments. We consider microservices as part of SCs and consider the possibility of microservices being shared among multiple SCs. An example scenario with 3 SCs that share 5 microservices (where MS1 belongs to all SCs as the entrypoint of the service) can be seen in Figure 1. Our goal is to dynamically allocate resources across microservices to ensure QoS constraints are met, while maximizing resource efficiency. A. Microservice-based cloud-native services As illustrated in Figure 2, our system model considers a cloud-native architecture where the service can be broken down to a set of microservices M={mi:i∈ {1. . . N}}, where Nis the number of microservices. These microservices are being invoked sequentially from a set of predefined SCs S={sj:j∈ {1. . . K}}, where Kis the number of SCs. Hence, every service chain sjis an ordered sequence of microservices, i.e., sj= (m1 sj, m2 sj, . . . , mLj sj),(1) MS-1 MS-5MS-3 MS-4MS-2 SC-1 SC-3 SC-2 Fig. 1. Toy example of cloud-native SCs where Ljis the number of microservices in service chain sj with |Lj| ≥ 1and mk sj∈Mfor all k∈ {1,2, . . . , Lj}. These SCs are associated with different user requests and can be processed in parallel. Since all requests arrive at the same application entrypoint, m1is the starting microservice of all SCs, i.e., m1 sj=m1∀sj∈S, (2) while a service chain cannot contain a specific microservice more than one time, i.e., mk sj=ml sj,∀k=l, ∀sj∈S. (3) The system of microservices can be treated as an open queuing network with predefined routes, the SCs. The entrypoint m1 receives incoming requests with arrival rate λ. Each incoming request will invoke its associated service chain, and we define a set of probabilities P={psj|sj∈Sfor each service chain to be invoked. Hence, we can estimate the arrival rate for each service chain as λsj=λpsj,∀sj∈S. (4) Considering that a microservice can be part of multiple SCs, arrival rates at each microservice can be calculated by summing the arrival rates of the SCs they belong, i.e., λmi=X S λsjqmi,sj,(5) qmi,sj=(1if mi∈sj, 0otherwise .(6) Each microservice has a base service rate ˆµmi, that represents its processing capacity under normal conditions. However, its actual service rate µmiis heavily affected by the CPU and memory utilization of the microservice, described as µmi= ˆµmig(umi),(7) where umi= (ucpu mi, umem mi)are the CPU and memory utilization pairs of the microservice, and gis an unknown function based on several factors, such as the type of the service and the underlying infrastructure. Consequently, it is not possible to derive the service rates analytically, and this limitation extends to the calculation of the total system latency.
MicroservicesService Chains Fig. 2. System Model B. QoS-driven microservice autoscaling Historical data can be employed to train machine learning models to predict latency QoS violations. The task of QoS violation prediction can be divided into two steps: (a) resource utilization forecasting, and (b) QoS violation detection. For resource utilization forecasting, a forecasting model hmi is trained on historical data for each of the microservices with the task of predicting their resource utilization in the next timestep t+1. Hence, future resource utilization of each microservice mican be calculated as umi,t+1 =hmi(umi,t−w:t),(8) where wis the look-back window of the forecasting model. Given the system state xt={umi,t :mi∈M}, a binary classifier model fcan be trained to detect QoS violatiing states. Consequently a QoS violation in the next timestep can be predicted as yt+1 =f(xt+1)=1if xt+1 leads to violation, 0otherwise ,(9) where the next system state xt+1 is predicted through hmi forecasters. C. Problem Definition In cloud-native scanraios, the QoS violation can be solved by adjusting the amount of resources allocated to the microservices. If we treat xas the current state of resource utilization, the adjustment involves a transition to a new state xby changing the allocated memory and CPU resources. However, such a change has to occur with minimal resource overheads. Therefore, our goal in this paper is to efficiently allocate the minimal necessary resources for each microservice while ensuring compliance with QoS latency requirements. This optimization problem Pcan be formulated as P:min xC(x, x), s.t. c1:f(x)=0, c2:0≤ucpu mi≤1,∀ucpu mi∈x, c3:0≤umem mi≤1,∀ucpu mi∈x (10) where C(x, x)is the cost associated with the transition from state xto x. In practice, this cost could relate to the cost of extra resources assigned or other measures (e.g., energy consumption) associated with this transition. Constraint c1 ensures the QoS compliance, while constraints c2and c3are related to the feasibility of the solution. III. CFE AUTOSCALING FRAMEWORK FOR CLOUD-NATIVE SERVICES The proposed autoscaling framework based on counterfactuals is illustrated in Figure 3. A Virtual Infrastructure Management system is responsible for monitoring resource utilizations, as well as materializing scaling decisions. Resource Utilization Forecasting utilizes AI to predict the next state xt+1 from historical data. Finally, a QoS Violation Detector is tasked with classifying future states. When a violation is predicted, a custom CFE Genetic Algorithm is employed to efficiently generate counterfactual explanations that solve the resource allocation problem P, which is the main scope of this work. Hence, in this section we will provide you with the details of the GA. Resource Utilization Forecasting QoS Violation Detector CFE Genetic Algorithm Virtual Infrastructure Management Fig. 3. CFE Autoscaling framework architecture The GA is inspired by the process of natural selection, employing a population of candidate solutions that evolve over successive generations. At each generation, the population is updated through a sequence of operations: selection,crossover, and mutation. The full genetic algorithm is described in Algorithm 1. A. Initialization The algorithm initializes by generating an initial candidate population Pinit of size n. Taking into account that our goal is to converge to a solution with minimal change from original state x, we follow the methodology in [12] and, instead of randomly sampling each value of x∗for the initial candidates, we generate the initial population by applying the mutation operation on the original state x. The mutation operation is one of the GA main operations and is described below. B. Selection of fittest candidates The top-qsolution candidates x∗are selected at each generation to form the basis of the next generation based on a fitness function F. It accounts for QoS satisfaction and the transition cost C(x, x∗)from current state xand, since a cost function is used, selection is based on the descending order
of fitness scores. To penalize configurations that violate QoS constraints, the fitness function is defined as F(x∗) = (C(x, x∗) + η, if f(x∗)=1, C(x, x∗),otherwise,(11) where ηis a large penalty term applied to configurations that lead to QoS violations. The cost function C(x, x′)is defined as the distance between xand x∗combining the L1-norm and the L0-norm, as a penalty for multiple allocations, i.e., C(x, x∗) = α∥x−x∗∥1+β∥x−x∗∥0,(12) where ∥x−x∗∥1=X i |xi−x∗ i|,(13) ∥x−x∗∥0=|{i∈ {1,2, . . . , 2N}:xi=x∗ i}| ,(14) while α,βare weighting factors that balance the contributions of the L1-norm and L0-norm to the total cost. C. Candidate mutation Mutation introduces randomness into the population to maintain diversity and explore new areas of the solution space. The pairs of resource utiliziations umiform Nfeature subsets of the solution candidates, one for each microservice. The mutation operation modifies each candidate solution by replacing one subset umiwith feasible alternatives, randomly sampled from the possible combinations for ucpu miand umem mi. At each generation the mutation operation is applied to all solution candidates in the population, producing nmut mutations for each feature subset umi. Since the space of feasible values for each resource utilization is continuous in the range of [0,1], we use a discrete step to limit the sampling space from which the mutation operation draws replacements for the utilization pairs. Algorithm 1 CFE Genetic Algorithm 1: Input: Original state x, population size n, number of mutations nmut, number of generations G, model f 2: Output: Optimal resource allocation x∗ 3: P0←initialize(x, n) 4: for it = 0 to Gdo 5: fit_scores ←F(Pit, x, , f) 6: Pselect ←selection(Pit,fit_scores) 7: Pcross ←crossover(Pselect) 8: Pmut ←mutations(Pcross, nmut) 9: Pit+1 ←Pselect ∪Pcross ∪Pmut 10: end for 11: final_scores ←F(PG, x, , f) 12: x′←selection(PG,final_scores)[0] 13: Return: Fittest candidate x′ MS-1 MS-3 MS-2 MS-4 SC-1 SC-2 SC-3 SC-4 Fig. 4. Simulation Setup D. Offspring generation through crossover The crossover operation produces an offspring solution from a pair of solution candidates in the population, by combining the mutated feature subsets of the parent solutions. For example, if solution candidate x∗ adiffers from xfor subsets um1 and um2and solution candidate x∗ bdiffers from xfor subset um4, their offspring solution will incorporate the mutations for all 3 subsets. At each generation the crossover operation is applied to all solution candidate pairs in the population. IV. PERFORMANCE EVALUATION The performance of our proposed method has been evaluated through simulation experiments. A simulator that leverages the AliBaba micrsoervice dataset and its analysis in the published work [11] was implemented in Python to simulate different microservice profiles (i.e., different dependencies on CPU and memory resources) and model their behavior under varying workload and resource utilization. A. Experimental Setup We consider a scenario of N= 4 microservices shared among K= 4 SCs, as shown in Figure 4. As our focus is to evaluate the effects of counterfactuals on resource efficiency and QoS compliance, we assume a highly accurate model for resource utilization forecasting with negligible prediction error for all proactive methods. We implement the QoS violation detector employing the XGBoost classifier model [13]. The classifier is trained on a synthetic dataset that was generated using the simulator, consisting of resource utilization of the microservices and the target system latency, and achieves 98% accuracy in predicting QoS violations. For the evaluation experiment, each microservice is assigned initial resources of 100 mcores (CPU) and 100 MB (memory). Assuming a popular worldwide service, we consider an initial arrival rate λ=4000 calls/min that increases at a step of 50 calls/min every minute up to reach eventually 10000 calls/min. Each request is randomly associated to one SC. As defined in the system model, the entrypoint microservice m1is the starting point of all SCs, hence all requests go through it. Taking into account the real-time requirements of autoscaling techniques in cloud environments, we tune GA parameters towards balancing the computational efficiency and the quality
0 100 200 300 400 CPU (mcores) MS-1 CPU Usage CFE Allocations PRSA Allocations RA Allocations MS-2 MS-3 MS-4 0 20 40 60 80 100 120 140 0 100 200 300 400 Memory (MB) Memory Usage CFE Allocations PRSA Allocations RA Allocations 0 20 40 60 80 100 120 140 0 20 40 60 80 100 120 140 0 20 40 60 80 100 120 140 CPU and Memory Allocations Over Time for Each Microservice Fig. 5. Comparison of CPU (up) and memory (down) allocation per microservice 0 20 40 60 80 100 120 140 Timesteps 200 400 600 800 1000 Latency (ms) Latency Over Time for all autoscalers (CFE, PV, RV) CFE PRSA RA QoS Threshold Fig. 6. Latency and QoS violations of the produced counterfactual solutions. A summary of the configurations of the experiment setup is presented in Table I. B. Benchmark Autoscalers We have designed two benchmark autoscaling mechanisms to evaluate and compare with the performance of our proposed method (CFE in the plots) under the exact same simulation scenario: •Proactive Resource-Specific Autoscaler (PRSA) also utilizes the QoS violation predictions to proactively make resource-specific scaling decisions. When a violation is predicted, PRSA doubles the current allocated resources (CPU and/or memory) of the microservices that have a utilization rate over a threshold τPRSA. •Reactive Autoscaler (RA) is inspired from common autoscaling practices in Virtual Infrastructure Managers, such as Kubernetes. It monitors the resource utilization of each microservice. When either CPU or memory utilization surpasses a specific threshold τPRSA, the whole microservice is scaled up by doubling the current allocation of both CPU and memory. In our experiments, both τPRSA and τRA have been set to 0.9. TABLE I EXPERIMENT CONFIGURATIONS Method Parameter Value Simulation N: number of microservices 4 K: number of SCs 4 Initial CPU (∀mi) (mcores) 100 Initial memory (∀mi) (MB) 100 λ: arrival rate (calls/min) [4k,10k] Genetic Algorithm G: generations 100 n: population size 20 q: selection size 20 nmut: number of mutations 10 α:L1-norm factor 1.0 β:L0-norm factor 0.2 η: QoS violation penalty 100 C. Experimental Results Figure 5 shows the CPU and memory usage of the 4 microservices over time, along with the resource allocation of the three autoscaling methods. Both CFE and PRSA allocate only the type of resource that is over-utilized in each scaling decision, unlike RA which allocates both memory and CPU. It is evident that our CFE solution is able to quantify the amount of resources needed to avoid violations and scale efficiently. Throughout the simulation, CFE saves 29.77% CPU and 7.26% memory resources for the whole service (i.e., aggregated gains for all microservices) compared to PRSA, and 29.77% CPU and 53.63% memory compared to RA. It is also worth noting that the specific simulation scenario with the continuous arrival rate increase favors PRSA and RA, which make higher resource allocation by doubling the resources (either specific or for the whole service), while, in scenarios with smoother arrival request changes, CFE would have even higher benefits thanks to its informed and precise resource allocation. Figure 7 shows that CFE allocations result in a higher average resource utilization for all microservices, when compared to RA, and the majority of microservices, compared to PRSA. High resource utilization leads to resource efficiency, as long as it does not reach extreme levels that can lead to performance degradation. High resource utilization comes with the trade-off
MS-1 MS-2 MS-3 MS-4 Microservices 0 20 40 60 80 100 CPU Utilization (%) 83.2 48.0 38.9 33.3 69.5 42.3 34.8 30.8 67.0 42.6 35.5 25.0 Average CPU Utilization Method CFE PRSA RA (a) MS-1 MS-2 MS-3 MS-4 Microservices 0 20 40 60 80 100 Memory Utilization (%) 67.9 48.4 34.9 65.7 67.9 48.4 34.9 64.3 41.4 39.2 22.9 57.3 Average Memory Utilization Method CFE PRSA RA (b) Fig. 7. Comparison of average resource utilization for each microservice. of higher latency. However, Figure 6 shows that this limited to 76 ms higher than PRSA and 150 ms higher than RA on average. Most importantly, CFE avoids any latency violations, fully complying with the QoS requirement, while RA fails in 3 cases due to its reactive nature. In practice, CFE exploits the QoS margin to optimize the resource utilization, while ensuring QoS requirements. V. CONCLUSION This paper has presented a novel approach to efficiently allocate resources for autoscaling cloud-native microservices, leveraging counterfactual explanations. By incorporating a Genetic Algorithm to generate counterfactuals, our method minimizes resource allocation during each scaling action, while ensuring compliance with QoS requirements. Our simulation experiments, based on real microservice profiles, demonstrate the advantages of our approach compared to benchmark proactive and reactive autoscalers, achieving significant resource savings in both CPU (up to 30%) and memory (up to 54%) usage. Our work has showcased how XAI can be employed as part of closed-loop service orchestration and management frameworks, through actionable explanations with impact on the system performance. ACKNOWLEDGMENT This work has been supported by the research projects ELIXIRION (101120135) under the Horizon Europe programme and AVANZANDO-5G-GEMELOS DIGITALES (TSI-063000-2021-112/113/114) under the UNICO5G-RPTR programme. REFERENCES [1] S. Deng, H. Zhao, B. Huang, C. Zhang, F. Chen, Y. Deng, J. Yin, S. Dustdar, and A. Y. Zomaya, “Cloud-native computing: A survey from the perspective of services,” Proceedings of the IEEE, vol. 112, no. 1, pp. 12–46, 2024. [2] L. M. Al Qassem, T. Stouraitis, E. Damiani, and I. M. Elfadel, “Containerized microservices: A survey of resource management frameworks,” IEEE Transactions on Network and Service Management, vol. 21, no. 4, pp. 3775–3796, 2024. [3] D.-D. Vu, M.-N. Tran, and Y. Kim, “Predictive hybrid autoscaling for containerized applications,” IEEE Access, vol. 10, pp. 109 768–109 778, 2022. [4] N. Marie-Magdelaine and T. Ahmed, “Proactive autoscaling for cloudnative applications using machine learning,” in GLOBECOM 2020 - 2020 IEEE Global Communications Conference, 2020, pp. 1–7. [5] M. Abdullah, W. Iqbal, J. L. Berral, J. Polo, and D. Carrera, “Burstaware predictive autoscaling for containerized microservices,” IEEE Transactions on Services Computing, vol. 15, no. 3, pp. 1448–1460, 2022. [6] K. Cheng, S. Zhang, C. Tu, X. Shi, Z. Yin, S. Lu, Y. Liang, and Q. Gu, “Proscale: Proactive autoscaling for microservice with timevarying workload at the edge,” IEEE Transactions on Parallel and Distributed Systems, vol. 34, no. 4, pp. 1294–1312, 2023. [7] P. Barnard, I. Macaluso, N. Marchetti, and L. A. DaSilva, “Resource reservation in sliced networks: An explainable artificial intelligence (xai) approach,” in ICC 2022 - IEEE International Conference on Communications, May 2022, pp. 1530–1535. [8] M. S. Munir, K. T. Kim, A. Adhikary, W. Saad, S. Shetty, S.-B. Park, and C. S. Hong, “Neuro-symbolic explainable artificial intelligence twin for zero-touch ioe in wireless network,” IEEE Internet of Things Journal, vol. 10, no. 24, pp. 22 451–22 468, Dec. 2023. [9] F. Rezazadeh, H. Chergui, and J. Mangues-Bafalluy, “Explanationguided deep reinforcement learning for trustworthy 6g ran slicing,” in 2023 IEEE International Conference on Communications Workshops (ICC Workshops). Rome, Italy: IEEE, May 2023, pp. 1026–1031. [10] E. AlJalaud and M. Hosny, “Counterfactual explanation of ai models using an adaptive genetic algorithm with embedded feature weights,” IEEE Access, vol. 12, pp. 74 993–75 009, 2024. [11] S. Luo, H. Xu, K. Ye, G. Xu, L. Zhang, G. Yang, and C. Xu, “The power of prediction: microservice auto scaling via workload learning,” in Proceedings of the 13th Symposium on Cloud Computing, ser. SoCC ’22. New York, NY, USA: Association for Computing Machinery, 2022, p. 355–369. [12] M. Schleich, Z. Geng, Y. Zhang, and D. Suciu, “Geco: quality counterfactual explanations in real time,” Proc. VLDB Endow., vol. 14, no. 9, p. 1681–1693, May 2021. [13] T. Chen and C. Guestrin, “Xgboost: A scalable tree boosting system,” in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, ser. KDD ’16. New York, NY, USA: Association for Computing Machinery, 2016, p. 785–794.