# Efficient Data Delivery Scheme for Large-Scale Microservices in Distributed Cloud Environment
## 3 Communication Model for Microservices-Based IoT Applications
### Processes for Edge Broker Clustering and Topic Channel Routing  
In this subsection, the main parts of the scheme for providing data delivery for microservices-based IoT applications are described. In addition, this subsection reveals how the coordinator clusters edge brokers into proper groups, as shown in Figure 2, and coordinates all pub/sub brokers in the system to perform end-to-end event notifications for the related microservices. Consider that at time \(T\) the system needs to enhance the performance of event notifications by clustering pub/sub brokers of the edge to proper groups. First, the coordinator entails the topic subscription information of the edge brokers in the system so as to exclude the isolated edge brokers from the clustering process. This is accomplished by applying the HDBSCAN algorithm [27] on the coordinates (latitude, longitude) of the edge brokers to find and exclude the isolated points. These brokers, called sporadic brokers, use the routing service provided by relay cloud brokers for data delivery with other brokers. Second, the model recommends top similar neighbor brokers for each member of the above-selected brokers based on their event channel similarities by applying the implicit feedback collaborative filtering (CF) techniques presented in [28]. Assume that the pub/sub system has a list of \(m\) pub/sub brokers and a set of \(n\) event channels. The amount of microservice clients of a broker \(b\) subscribed to an event channel \(e\) is represented by the element \(s_{be}\) of the event channel subscription matrix, denoted by \(\mathbf{S}\in\mathbb{R}^{m\times n}\), where \(s_{be}\) is zero if no microservice client of \(b\) broker subscribes to the event channel \(e\). Each broker \(b\) is linked to a broker-factors vector \(\mathbf{x}_{b}\in\mathbb{R}^{f}\), and each event channel \(e\) is linked to an event-factors vector \(\mathbf{y}_{e}\in\mathbb{R}^{f}\). This is done to approximate the matrix \(\mathbf{S}\) into two latent factor matrices, \(\mathbf{B}^{m\times f}\) (a broker factors matrix) and \(\mathbf{E}^{n\times f}\) (an event channel factors matrix), as closely as possible, with the following form: \(\mathbf{S}\approx\mathbf{B}\mathbf{E}^{T}\), where the  
Figure 2: Process for edge brokers clustering. approximate value of \(s_{be}\) is computed via an inner product, i.e., \(\widehat{s_{be}}=\mathbf{x}_{b}^{T}\mathbf{y}_{e}\). The variable \(p_{be}\) with the formula \(c_{be}=1+\alpha p_{be}\) is introduced to signify the likelihood of microservice clients of \(b\) broker subscribing to event channel \(e\) with confidence level \(c_{be}\). These techniques are adapted from the implicit feedback CF methods provided elsewhere [28]. The following expressions are used to calculate the \(p_{be}\) values for a given \(s_{be}\):  
\[p_{be}= \begin{cases}1,&\text{if }s_{be}>1,\\ 0,&\text{if }s_{be}=0.\end{cases}  \tag{1}\]  
The broker and event channel factors are then computed by minimizing the following loss function:  
\[\min_{\mathbf{x},\mathbf{y}_{e}}\sum_{b,e}c_{be}\Big{(}p_{be}-\mathbf{x}_{b}^{T}\mathbf{y}_{e} \Big{)}^{2}+\lambda\Bigg{(}\sum_{b}\|\mathbf{x}_{b}\|^{2}+\sum_{e}\|\mathbf{y}_{e}\|^ {2}\Bigg{)}. \tag{2}\]  
The term \(\lambda\Bigg{(}\sum\limits_{b}\|\mathbf{x}_{b}\|^{2}+\sum\limits_{e}\|\mathbf{y}_{e} \|^{2}\Bigg{)}\) is used to regularize the model to reduce overfitting. An alternating least squares (ALS) method was used to tackle the optimization problem in (2), in which the factors of the broker are first fixed to optimize the factors of the event channel, then the opposite.