# Micro-FL: A Fault-Tolerant Scalable Microservice-Based Platform for Federated Learning
## 2 Background
### Federated Learning  
Federated learning, introduced by Google [5], is a distributed machine learning strategy focused on data privacy. It brings together numerous clients, such as edge devices and organizations, to collaboratively train a shared statistical model, known as a global model. The process, facilitated by a central server, occurs across remote client devices without directly sharing data.  
Federated learning is characterized by two main features: (1) It involves a multi-party collaboration, with at least two entities, to construct a machine learning model. Each participant holds unique data that contributes to model training. (2) During the training process, each party's data are kept localized and are not transferred elsewhere.  
Federated learning can be formulated as follows: Consider a scenario with \(N\) clients, denoted as \(\{F\}_{i}^{N}\), each possessing unique datasets \(\{D_{i}\}_{i}^{N}\). In traditional machine learning, these datasets \(\{D_{i}\}_{i}^{N}\) would be sent to a central server to train the unified model \(M_{\text{SUM}}\). However, this process requires each client \(F_{i}\) to disclose its dataset \(D_{i}\) to the central server, which poses potential data leakage risks.  
On the other hand, in federated learning, clients work together to train a model \(M_{\text{FED}}\) without having to share their respective datasets \(\{D_{i}\}_{i}^{N}\). Suppose \(V_{\text{SUM}}\) and \(V_{\text{FED}}\) represent the performance metrics (such as accuracy, recall, or F1-score) of the traditional machine learning model \(M_{\text{SUM}}\) and the federated model \(M_{\text{FED}}\), respectively. Assuming that \(\delta\) is a non-negative real number, the federated learning model \(M_{\text{FED}}\) is said to experience \(\delta\)-performance loss if:  
\[|V_{\text{SUM}}-V_{\text{FED}}|<\delta. \tag{1}\]  
Equation (1) implies that while federated learning builds a machine learning model using decentralized data sources, the model performance on unseen data closely matches that of a model built on centrally collected data [4].  
The federated learning training process can be broadly classified into three steps, as defined by [PERSON] et al. (2018). The model trained at each client's end is termed the local model, whereas the model synthesized by the federated learning server is denoted the global model. Figure 1 provides a visual representation of the federated learning architecture and its training process.  
1. Initialization: The server defines the machine learning task, data prerequisites, and training hyperparameters. It then broadcasts the initial global model parameters \(w_{G}^{0}\) to selected clients ([PERSON] et al., 2018; [PERSON] et al., 2019; [PERSON] et al., 2019).
2. Local model training and update: Each client \(i\) downloads the broadcast model parameters \(w_{G}^{t}\) from the server, for the iteration number \(t\). They train the model on their local data to obtain updated model parameters, \(w_{i}^{t}\), which minimize a specific loss function, \(L(w_{i}^{t})\). These updated model parameters are then sent back to the server.
3. Global model aggregation and update: The server aggregates the local models generated by the clients and prepares the model parameters for the subsequent training iteration, \(w_{G}^{t+1}\), with the aim of minimizing the global loss function, \(L(w_{G}^{t})\). Steps 2 and 3 are repeated until the global loss function converges or a targeted training accuracy is achieved.  
Federated averaging (FedAvg) is a straightforward and commonly used method for aggregating local models in federated learning, proposed by [PERSON] et al. (2016). This algorithm averages the updated weights from each client's local model to create a new global model.