## 2 Fuzzy-Based Horizontal Scaling Proposal  
Figure 1 describes the architecture of the FHS, in which a fuzzy system, also known in the literature as a fuzzy control system (FCS), is used for horizontal scaling control of a given application in a Kubernetes cluster (K8s). At each \(n\)-th point in time, the FCS takes as input the variables \(x^{\text{cpu}}(n)\), \(x^{\text{TP}}(n)\), and \(m^{\text{P}}(n)\), respectively representing the CPU load in millicores, the rate of received packets per minute (rpm), and the number of replicas of a given application, with the first two terms normalized by the number of application replicas. The variables \(x^{\text{cpu}}(n)\) and \(x^{\text{TP}}(n)\) are generated by a module which we call the Normalization and Saturation Module (NSM), which captures the application metrics through a Monitoring Service (MS) associated with the K8s cluster. The MS is responsible for capturing metrics related to the CPU load of all the application replicas \(m^{\text{cpu}}(n)\), the rate of packets received by all the application replicas in rpm \(m^{\text{TP}}(n)\), and the number of application replicas \(m^{\text{P}}(n)\). At every \(n\)-th moment, the FCS outputs the variable \(d(n)\), which represents a possible increment to the number of application replicas. The increment value \(d(n)\) is added to the current number of replicas \(m^{\text{P}}(n)\) to generate the next number of replicas to be achieved by K8s. The value associated with the next number of instances, previously rounded to an integer, is then saturated using a module called the Round and Saturation Module (RSM) to produce the value \(m^{\text{P}}(n+1)\), which is sent to the K8s cluster. Adjustments to the number of instances are made directly by the K8s API. The variable \(x^{\text{cpu}}(n)\) can be expressed as follows:  
\[x^{\text{cpu}}(n)= \begin{cases}\frac{m^{\text{rPu}}(n)}{m^{\text{P}}(n)\times m _{\text{max}}^{\text{rpu}}}&\text{se}\ \frac{m^{\text{cpu}}(n)}{m^{\text{P}}(n)}<m_{\text{max}}^{\text{cpu}},\\ 1&\text{se}\ \frac{m^{\text{cpu}}(n)}{m^{\text{P}}(n)}\geq m_{\text{max}}^{\text{cpu}}, \end{cases}  \tag{1}\]  
Figure 1: Architecture of the proposed fuzzy control for horizontal scaling of applications in a Kubernetes cluster. where \(m^{\text{CPU}}_{\text{max}}\) is the maximum expected load per application replica. Meanwhile, the variable \(x^{\text{rp}}(n)\) can be expressed as  
\[x^{\text{rp}}(n)= \begin{cases}\frac{m^{\text{rp}}(n)}{m^{\text{rp}}(n)\times m^{ \text{rp}}_{\text{max}}}&\text{se}\ \frac{m^{\text{rp}}(n)}{m^{\text{rp}}(n)}<m^{\text{rp}}_{\text{max}},\\ 1&\text{se}\ \frac{m^{\text{rp}}(n)}{m^{\text{rp}}(n)}\geq m^{\text{rp}}_{\text{max}}, \end{cases}  \tag{2}\]  
where \(m^{\text{cpu}}_{\text{max}}\) is the maximum number of packets received per application replica in rpm. Finally, the variable \(m^{\text{rp}}(n+1)\) can be expressed as follows:  
\[m^{\text{rp}}(n+1)= \begin{cases}\lfloor m^{\text{rp}}(n)+d(n)\rceil&\text{se} \ m^{\text{p}}(n)<m^{\text{rp}}_{\text{max}},\\ m^{\text{rp}}_{\text{max}}&\text{se}\ m^{\text{p}}(n)\geq m^{\text{rp}}_{ \text{max}},\end{cases}  \tag{3}\]  
where \(m^{\text{rp}}\text{max}\) is the maximum number of instances associated with the application. The variable \(m^{\text{rp}}(n+1)\) has an integer value between 1 and \(m^{\text{rp}}\text{max}\). Based on Figure 1, Equations (1) and (2) are implemented by the NSM and Equation (3) is implemented by the SM. As noted by Equations (1) and (2), the values of \(x^{\text{cpu}}(n)\) and \(x^{\text{rp}}(n)\) are normalized between 0 and 1; meanwhile, the values of \(d(n)\) are limited between \(-K\) and \(+K\), where \(K\) is the maximum number of increments that can be performed at each \(n\)-th moment. The fuzzy inference system adopted in this work is of the Mandani type, which is widely used in fuzzy control problems [20; 22]. For the representation of the inputs to the fuzzy system, membership functions are defined that capture the relationship between the input values and their pertinence in each fuzzy set [20].