Latency Analysis of Consortium Blockchained Federated Learning
Abstract
A decentralized federated learning architecture is proposed to apply to the Businesses-to-Businesses scenarios by introducing the consortium blockchain in this paper. We introduce a model verification mechanism to ensure the quality of local models trained by participators. To analyze the latency of the system, a latency model is constructed by considering the work flow of the architecture. Finally the experiment results show that our latency model does well in quantifying the actual delays.
Index Terms:
Federated learning, consortium blockchain, model verification, latency.I Introduction
Quantities of data have been generated continuously and become the new type of fuel that promotes the development of production. But the data security has to be considered during training a model cooperatively among different participators. In this regard, federated learning (FL) architecture was proposed [1].
The original FL system needs a central sever to collect and distribute the model weights and gradient parameters (called the local model update). This centralized architecture may introduce some problems. Firstly, the global model that all participators receive depends on the single central server. If a failure happens on the server, each participator would get an inaccurate global model. Secondly, because all the model updates are stored in the sever. Once the server is attacked, the whole system would be collapsed.
In order to avoid the negative effects brought by the centralized architecture, the decentralized architecture was proposed by exploiting the blockchain instead of the server [5].
FL based on the blockchain has been used on Internet of Things (IoT) [2], Internet of Vehicular (IoV) [3], Mobile Edge Computing (MEC) [4] and so on. It supports not only these Devices-to-Devices (D2D) applications but also Businesses-to-Businesses (B2B) scenarios. Enterprises that own mass of data, such as banks, securities and hospitals, would like to discover the intrinsic value hidden in the data collaborating with others. In this paper, we present a FL based on blockchain for these B2B scenarios.
Considering the efficiency of the architecture, consortium blockchain should be used for the decentralized federated learning [6, 7]. Because only authorized peers can join the network and have access to the data stored in the distributed ledger on the consortium blockchain. The consensus protocol of the consortium blockchain is usually not PoW (Proof of Work), but consensus algorithms such as PBFT (Practical Byzantine Fault Tolerance) [8] and Raft [9], which are more efficient and suitable for the multi-center network.
The verification mechanism of the blockchain is often used to authenticate identities of peers. But the quality of models is especially important in the FL. Thus we introduce a model verification mechanism in order to ensure the quality of local model updates trained by participators.
The efficiency of the blockchained federated learning system is a key issue for practical application. Therefore, it is important to analyse the latency of the system. Most of the existing works explained the system delay by the ways of numerical simulation. These empirical analyses are too costly to obtain accurate results. Furthermore, the underlying networks for deploying permissioned blockchains have a great impact on analysis results, thus these results are not comparable and lack versatility [10]. It is imperative to analyse theoretical latency to provide a quantitative model. The main contributions of this paper are as follows:
-
•
A decentralized federated learning based on consortium blockchain called CBFL is proposed to train a classification model by logistic regression with a horizontally partitioned dataset in B2B scenarios.
-
•
We introduce a model verification mechanism for CBFL to validate the availability of the local model updates trained by participators.
-
•
The theoretic latency model for CBFL system is divided into three parts. Each part involves several subdivisions for fine-grained analysis.
-
•
Through the latency model, we get an optimal throughput configuration for PBFT so as to improve the efficiency in practical application.
II CBFL Architecture and Operation
Let be a set of enterprises collaborating with each other in CBFL. The enterprises manage two types of nodes: compute nodes and communication peers . The compute nodes have enough computing power to train the models. And communication nodes are responsible for maintaining the blockchain.
The CBFL architecture is organized as two layers: the model update layer and the blockchain layer as shown in Fig. 1. In the model update layer, compute nodes train the local models using its own raw data samples locally and upload the local model updates to the corresponding communication peers in the blockchain layer. Each peer verifies all the local model updates gathered from other peers and operates the consensus algorithm to generate a new block. Finally, the local model updates recorded in the newest block are aggregated locally by each compute node. So all the participators achieve data collaboration without leaking the raw data.

II-A Model Update Layer
Suppose that the -th enterprise owns a set of data which includes features and samples, where . Let be the entire dataset of all enterprises in CBFL, where .
Our CBFL architecture focuses on the classification problem by using the logistic regression with the horizontally partitioned data [11]. Let be the -th data sample, where and . The goal of logistic regression is to train a linear model for classification by solving the following optimization problem [12]:
(1) |
where is the model parameter vector and
In order to solve the optimization problem (1), the model is locally trained with the stochastic variance reduced gradient(SVRG) [1]:
(2) |
where is the local weight at the -th iteration of the -th cycle and is the step size. Let be the local weight after the last local iteration of the -th cycle. So gets the local model update . Then aggregates all the s to get the global model by
(3) |
where is the global model weight of the -th cycle.
II-B Blockchain Layer with Model Verification Mechanism
In the blockchain layer, the size of each block is set as , where is the block header size, is the single size and is the maximum number of s within a block. It is more efficient to get the consensus by using a consortium blockchain instead of a public blockchain. Besides, peers in a consortium blockchain are authorized, data stored in the block are more secure.
The consensus protocol is the core component of a blockchain. In this paper, PBFT is adopted to get the consensus for the consortium blockchain network. It can get the consensus among peers with faulty peers, where .
PBFT includes three phases as shown in Fig. 2. A leader was chosen among all peers beforehand to create a candidate block in which s are sorted by timestamp. Then disseminates the candidate block to all other peers in a pre-prepare message at the pre-prepare stage. If a peer receives and accepts the message, it stores the message and enters the prepare phase broadcasting prepare messages. Then peers wait for a quorum of prepare messages, i.e., at least prepare messages which match the stored pre-prepare message. In the third phase peers broadcast commit messages to all others. Then, if a peer collects another quorum of commit messages which match the previously collected prepare messages, it will commit the state transition and reply to the compute node [8].

Replying on the blockchain network, we can build a secure data sharing platform where enterprises can exchange model updates to achieve secure data collaboration. Compute nodes can get all the local updates from the newest block and aggregate locally instead of downloading the global model update from the central server, which is more robust than the centralized FL. In the B2B application scenario, the number of peers is not too many. So PBFT can achieve the consensus efficiently. Furthermore, PBFT needs fewer computing resources than PoW and can avoid forking [13].
In a normal blockchain, peers verify the validity of a transaction with the digital signature technology. But with the federal learning protection privacy mechanism, some unreal or even malicious participants[14] will provide mendacious local model updates with some made-up data, which causes trouble for the global model. In our CBFL, the communication peers verify the s not only by checking the digital signatures but also by verifying the quality of models.
We leverage the classification accuracy to quantify the performance of the local model updates. More specifically, the accuracy is denoted by the proportion of correctly classified samples. Denote that each owns testing instances for quantifying the accuracy of the local model updates. The classification accuracy of the -th received local model update can be given by , where is the number of the correctly classified samples. When the communication peer receives local model updates from other peers, it would admit the -th local model update whose classification accuracy satisfies , where is the threshold predetermined.
With the model verification mechanism, only the models trained by truthful data can be recorded in the distributed ledger of the blockchain. In this way, unnecessary oscillations can be avoided in the process of training the global model, which improves the efficiency of the whole system by reducing the training rounds.
II-C One-Cycle CBFL Operation
As depicted in Fig. 1, the CBFL operation can be described by the following six steps:
-
Step 1
Local model update: Each computes (2) with its own data to get the local model update .
-
Step 2
Local model upload: uploads the to its corresponding .
-
Step 3
Cross-verification: broadcasts the obtained from . At the same time, verifies the s received from other peers with our model verification mechanism.
-
Step 4
Consensus: The verified s are recorded in the candidate block by the leader . The candidate block doesn’t generate until reaching the block size or maximum waiting time . The leader multicasts the candidate block to all peers to start the three-phase PBFT to get the consensus among all peers.
-
Step 5
Global model download: When a peer receives commit messages, it sends the newest block which stores all participators’ s to the corresponding as the reply.
-
Step 6
Global model update: Every computes the global model update by using (3) with all s recorded in the block.
Step1 to Step6 is the one-cycle process of CBFL. This operation process doesn’t stop until .
III One-Cycle Operation Latency Analysis
We aim to build a latency analysis model to quantify the time consumption of the CBFL. Before building the latency model, some reasonable assumptions are made as follows:
-
•
The compute nodes and communication peers have stable and enough computing resources for model training and verification.
-
•
The communication peers have certain communication and storage capabilities to ensure s sharing. And peers are defined to dispose the received messages on a FIFO basis, while the processing time at each peer follows the exponential distribution with the mean .
-
•
The arrival of new s follows the Poisson Process with the arrival rate .
Let be the total time during -th cycle process at a fixed enterprise and
where , and are model update, consensus and communication delays respectively.
1) Model update latency: The model update delays are generated by Step 1 and Step 6. Let be a single data sample size and be the clock speed. So the local model update latency in Step 1 is evaluated as [5]. And the global model update latency in Step 6 can be given as [5], where is the size of a local model update .The model update latency can be calculated by
(4) |
2) Consensus latency: The consensus delays are brought by Step 3 and Step 4. And the latency of the PBFT consensus is fully considered according to its three-phase work flow.
Let be the number of arrived s within the max waiting time . So the leader sends the pre-prepare message to other peers when the number of arrived s reaches according to the conditions above-mentioned in Step3, where . The collection, verification and batch processes of s at can be modeled by the queue. According to the Little’s law, The average waiting time of each can be formulated as . Thus, the total latency of the pre-prepare phase can be given as
For an arbitrary fixed , its process of receiving prepare messages is the Poisson process with the intensity . Thus, the time lag between two adjacent prepare messages follows the exponential distribution with mean . The average waiting time of can be denoted as
The total processing time in this phase is calculated as
so the latency of prepare phase is
The latency of the commit phase is similar to the prepare delay.
The total latency of consensus phase is
(5) |

3) Communication latency: The communication delays are contributed by Step 2 and Step 5. The local model upload latency in Step 2 is computed as
where is the bandwidth between and , is the signal-to-noise ratio [5]. Similarly, global model download delay in Step 5 is calculated as
So the latency of communication can be calculated as
(6) |
Theorem 1
If the algorithms for training local model updates and global model updates are confirmed, and are constants. and are also constants when the underlying network is determined. Thus, the total latency of CBFL can be modeled as
(7) |
Proof:
According to the work flow of CBFL in Section II, is the sum of , and . Let . And
(8) |
∎
Theorem 2
With the case where the leader starts the PBFT when the maximum size of a block is satisfied, i.e. , the optimal for PBFT can be given by
(9) |
Proof:
According to (8), we can get the first derivative and the second derivative of with respect to as follows
Thus the is convex for . The optimum is directly derived. ∎
IV Numerical Results and Conclusion


The time consumption data was fitted with Exponential, Weibull, Gamma, Hypoexponential, LogNormal and Pareto distributions using MLE (Maximum Likelihood Estimation) technique in [14]. The best-fit model of is Weibull distribution (, ). For another, is the sum of independent identically exponential distributed random variables given in Section III. Thus it follows Gamma distribution. While the Gamma distribution is a special kind of Weibull distribution, our latency analyses of and are suitable.
As the number of peers increases, the probability of failure peers occurrence will also increase. In Fig. 3 [14], the mean latency to consensus increases with the augment of the number of peers. This is similar to what our model (7) shows.
Fig. 4 shows the impact of the transactions arrival rate on the blockchain average completion latency. The relationship between the latency and is a approximate inverse proportional function as shown in Fig. 4-a, which is consistent with our latency model. In Fig. 4-b, we compare the latency results from the simulation [10] and the latency model. In order to ensure comparability, the same configurations in [10] are adopted. Let , and the transactions arrival rate starts from 50tps to 250tps in this experiment. The model predicts the experimental measurements with an error lower than 3.1%.
In the B2B scenarios, each enterprise can enhance the computing and communication equipment to improve model update and communication efficiency. So it is crucial to optimize CBFL with respect to latency, computing and storage requirements by improving the underlying networks, which can reduce the consistent delays according to our latency analysis model.
In conclusion, the consensus latency is a bottleneck of the whole system, especially the latency of waiting for ordering. According to (7), the latency of the system is proportional to the number of faulty nodes and inversely proportional to the system TPS. The throughput can be adjusted to reduce latency according to actual situation. In addition, faulty nodes can be reduced by establishing a reward system and a node selection mechanism.
V Acknowledgement
The authors thank professors Debiao He of Wuhan University and Xiaohong Huang of Beijing University of Posts and telecommunications for their valuable suggestions to improve the the innovation of this paper.
References
- [1] J. Konečný, H. B. McMahan, D. Ramage and P. Richtárik, “Federated optimization: distributed machine learning for on-device intelligence,” [Online]. Available: https://arxiv.org/abs/1610.02527.
- [2] Y. Lu, X. Huang, Y. Dai, S. Maharjan and Y. Zhang, ”Blockchain and federated learning for privacy-preserved data sharing in industrial IoT,” IEEE Transactions on Industrial Informatics, vol. 16, no. 6, pp. 4177-4186, June 2020, doi: 10.1109/TII.2019.2942190.
- [3] Y. Lu, X. Huang, K. Zhang, S. Maharjan and Y. Zhang, “Blockchain empowered asynchronous federated learning for secure data sharing in internet of vehicles,” IEEE Transactions on Vehicular Technology, vol. 69, no. 4, pp. 4298-4311, 2020.
- [4] Y. Zhao, J. Zhao, L. Jiang, R. Tan, D. Niyato, Z. Li, L. Lyu and Y. Liuet, “Mobile edge computing, blockchain and reputation based crowdsourcing federated learning: a secure, decentralized and privacy-preserving system,” [Online]. Available: https://arxiv.org/abs/1906.108932020.
- [5] H. Kim, J. Park, M. Bennis and S. Kim, “Blockchained on-Device federated learning,” IEEE Communications Letters, vol. 24, no. 6, pp. 1279-1283, 2020.
- [6] M. Shen, J. Zhang, L. Zhu, K. Xu and X. Tang, “Secure SVM training over vertically-partitioned datasets using consortium blockchain for vehicular social networks,” IEEE Transactions on Vehicular Technology, vol. 69, no. 6, pp. 5773-5783, 2020.
- [7] I. Martinez, S. Francis and A. Scnhaji Hafid, “Record and reward federated learning contributions with nlockchain,” International Conference on Cyber-Enabled Distributed Computing and Knowledge Discovery (CyberC), Guilin, China, pp. 50-57, 2019.
- [8] M. Castro and B. Liskov, “Practical byzantine fault tolerance and proactive recovery,” ACM Transactions on Computer Systems, vol. 20, no. 4, pp. 398-461, 2002.
- [9] D. Ongaro and J. Ousterhout, “In search of an understandable consensus algorithm,” USENIX Annual Technical Conference, Philadelphia, pp. 305-319, 2014.
- [10] X. Xu, G. Sun, L. Luo, H. Cao , H. Yu and A. V. Vasilakos, “Latency performance modeling and analysis for hyperledger fabric blockchain network,” Information Processing and Management, vol 58, no. 1, 2021.
- [11] S. Hardy, W. Henecka, H. Ivey-Law, R. Nock, G. Patrini, G. Smith and B. Thorne, “Private federated learning on vertically partitioned data via entity resolution and additively homomorphic encryption,” [Online]. Available: https://arxiv.org/abs/1711.10677.
- [12] B. McMahan, E. Moore, D. Ramage, S. Hampson and B. A. y Arcas, “Communication-efficient learning of deep networks from decentralized Data,” 20th International Conference on Artificial Intelligence and Statistics, vol. 54, pp. 1273-1282, 2017.
- [13] Y. Hao, Y. Li, X. Dong, L. Fang and P. Chen, “Performance analysis of consensus algorithm in private blockchain,” IEEE Intelligent Vehicles Symposium, Changshu, pp. 280-285, 2018.
- [14] A. N. Bhagoji, S. Chakraborty, P. Mittal, and S. Calo, “Analyzing federated learning through an adversarial lens,” 36th International Conference on Machine Learning, pp. 634-643, 2019.
- [15] H. Sukhwani, J. M. Martínez, X. Chang, K. S. Trivedi and A. Rindos, “Performance modeling of PBFT consensus process for permissioned blockchain network (Hyperledger Fabric),” IEEE 36th Symposium on Reliable Distributed Systems, Hong Kong, pp. 253-255, 2017.