Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block...

27
Performance Benchmarking & Optimizing Hyperledger Fabric Blockchain Platform Parth Thakkar, Senthil Nathan N, Balaji Vishwanathan IBM Research, India 1

Transcript of Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block...

Page 1: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Performance Benchmarking & Optimizing Hyperledger Fabric Blockchain Platform

Parth Thakkar, Senthil Nathan N, Balaji VishwanathanIBM Research, India

1

Page 2: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Outline• Background

• Blockchain & Hyperledger Fabric

• Motivation for performance benchmarking

• Experimentation methodology• Performance metrics• Parameters which Impact the Peer Components• Setup and workload

• Results: Impact of various configurable parameters on the performance• Guidelines on parameter configuration & Bottlenecks• Research opportunities

• Optimizations (improved the overall throughput by 16x -- from 140 tps to 2250 tps)1. Cache to minimize crypto operations2. Parallel validation3. Bulk read/write 2

Page 3: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

BackgroundBlockchain & Hyperledger Fabric

3

Page 4: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Blockchain Defined

Blockchain is a design pattern made famous by its use in Bitcoin. But its uses go far beyond.

Blockchain can reimagine theworld's most fundamental business interactions and open the door to invent new styles of digital interactions.

4

Page 5: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

A Business Network Without Blockchain

Without Blockchain: Inefficient, Expensive, Vulnerable, Conflicts

BankOrganization B

Organization C AuditorOrganization D

Organization A

Business-2-Business Transaction

Ledger Ledger Ledger

Ledger Ledger Ledger

5

Page 6: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

With Blockchain: Consensus, Provenance, Immutability

Ledger: Shared, replicated, permissioned

A Business Network With Blockchain

BankOrganization B

Organization C AuditorOrganization D

Organization A

6

Page 7: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Hyperledger Fabric: Permissioned Blockchain Platform

P2

C

P0

P3

Org. B’s ClientApp

(1) Submit the Tx

Smart Contract

Consenters (or)Ordering Service

Endorsing & Committing Peer

Committing Peer

(2) Simulates the Tx

Consenters

P1

CCC

(2) Simulates the Tx

(3) Simulation results & org B digital signature

(3) Simulation results & org A digital signature

Org. A

Org. B Org. C Org. D(4) Tx’s Simulation Results & Endorsers Signature

(6) Delivers the Block

(6) Delivers the Block

(6) Delivers the Block

State DB

(7) Validation as per SC endorsement policy

(8) MVCC Validation & Commit

(7) Validation as per SC endorsement policy

(7) Validation as per SC endorsement policy

(8) MVCC Validation & Commit

(8) MVCC Validation & Commit

(1) Submits the Tx(2) Simulates the Tx(3) Simulation results &

digital signature(4) Submit results &

endorsers signatures to consenter

(5) Consensus(6) Delivers the block(7) Policy validation(8) MVCC & commit(9) Send Tx’s status

(5) Consensus for creating a block with Txs

(9) Tx Status

Org. D’s ClientApp

Org. A’s ClientApp

Steps for Executing a Tx

A block is delivered when (a) the timeout occurs or (b) the block size limit is reached 7

Page 8: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Our Focus: Three Sub-Components in a Peer

1. Endorser• Invoke the chaincode and simulate the transaction to collect read/write set• Sign the transaction response using ESCC (endorser system chaincode code)

2. Validator: On receiving a block• Validator validates all transactions in a block by invoking VSCC (validator system chaincode)• Any two organization endorsement signature

• Or (And(A, B), And(A, C), And(A, D), And(B, C), And(B, D), And(C, D))

3. Committer & Ledger• Committer calls the ledger to commit the received block• Performs MVCC validation on read/write set of each transaction• Commit the block to block storage and valid transactions to state/history DB

8

Page 9: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Motivation for Performance Benchmarking

9

Page 10: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Motivation for Performance Benchmarking

1. To find out bottlenecks and gaps for improvement

2. To propose and implement optimizations to improve the performance• blockchain solutions’ throughput requirement is between 100 tps and 20,000 tps (for RTGS)

3. To provide guidelines on parameters configurations• 100s of questions on parameters configuration on Hyperledger Fabric mailing-list

4. To identify research opportunities • A new research topic and a lot of potential for enhancement• Increase research activities in Blockchain domain

10

Page 11: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Experimental MethodologyPerformance Metrics, Parameters, Setup and Workload

11

Page 12: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Performance Metrics

• Transaction Throughput

• Transaction Latency

Transaction Latency1. Endorsement Latency

Client – Endorser2. Broadcast Latency

Client – Orderer3. Ordering Latency

Orderer – Peer 4. Commit Latency

Peer – Client

Block-Level Latency1. VSCC Validation Latency2. MVCC Validation Latency3. Ledger Update Latency

12

Page 13: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Parameters which Impact Peer Components

Parameters Endorsers Validator Committer & Ledger

(1) Block Size ✓ ✓(2) Endorsement Policy ✓(3) Number of Channels ✓ ✓ ✓(4) Resource Allocation ✓ ✓ ✓(5) State DB Choice (CouchDB vs GolevelDB) ✓ ✓ ✓(6) Transaction Size (number of keys read/write, size of key/value) ✓ ✓

13

Page 14: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Experimental Methodology

• Perform experiments by varying values set to configurable parameters to understand

1. Impact of various load generation rate and block size on the performance.

2. Impact of endorsement policy on the performance.

3. Impact of number of channels & resource allocation on the performance.

4. Impact of transaction size and state DB choice on the performance.

14

Page 15: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Setup & Workload

Peer 1 Peer 2

Org aMSP

Peer 1 Peer 2

Org b

Peer 1 Peer 2

MSPPeer 1 Peer 2

MSPOrg c Org d

MSP

OSN Kafka/Zookeeper

Datacenter Network

Ordering Service

Built our own workload by surveying around 12 internal customer solutions

Write-only transactions• 1 KV write• 3 KV writes • 5 KV writes

Read-Write transactions• 1 KV read write • 3 KV reads writes • 5 KV reads writes

Setup Workload

15

Page 16: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Results: Impact of various configurable parameters on the performance Guidelines, Bottlenecks, & Research Opportunities

16

Page 17: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(1) Impact of Transaction Arrival Rate & Block Size

0

20

40

60

80

100

120

140

25 50 75 100 125 150 175 100

1000

10000

100000T

hro

ug

hp

ut

(tp

s)

La

ten

cy

(m

se

c)

Transaction Arrival Rate (tps)

Throughput (block size: 10)Throughput (block size: 30)Throughput (block size: 50)

Throughput (block size: 100)Latency (block size: 10)Latency (block size: 30)Latency (block size: 50)

Latency (block size: 100)

Latency

Throughput

Saturation: 140 tps

Incre

ased

with

bloc

k size

17

Page 18: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(1) Impact of Transaction Arrival Rate & Block Size

• Guidelines on configuring the block size:• transaction arrival rate < saturation point à lower block size• transaction arrival rate >= saturation point à higher block size

• Bottleneck:• CPU resources are under-utilized (~7% utilization) - Serial validation of transactions by VSCC

• Parallel validation has some challenges but could improve the performance

• Research opportunity:• On higher transaction arrival rate, the latency increased by >10x • Admission control for transactions is necessary to get lower latency

• very challenging in an untrusted and distributed system

18

Page 19: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(2) Impact of Endorsement Policy

And/Or1 Endorser : Or (A, B, C, D)2 Endorsers: Or (And(A, B), And(A, C), And(A, D), And(B, C), And(B, D), And(C, D))3 Endorsers: Or (And(A, B, C), And(A, B, D), And(B, C, D), And(A, C, D)) 4 Endorsers: And (A, B, C, D)

NOutOf1 Endorser : 1-out-of (A, B, C, D)2 Endorsers: 2-out-of (A, B, C, D)3 Endorsers: 3-out-of (A, B, C, D)4 Endorsers: 4-out-of (A, B, C, D)

• Guideline on configuring the endorsement policy• To achieve higher performance, define endorsement policy with lesser #sub-policies and #endorsers

• NOutOf policy is better performant than And/Or but less powerful

19

Page 20: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(2) Impact of Endorsement Policy

• Bottleneck:• Validation of endorsers signature against the policy

• Repetitive crypto operation -- usage of cache could improve the performance

• Research opportunity:• Matching digital signature set against the endorsement policy is a NP complete problem

• In a 5 minutes run, 96K out of 220K crypto operations performed were useless – due to greedy way of matching the signature set against the policy.

• An algorithm that can reduce/avoid such unnecessary crypto operations is needed.

20

Page 21: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(3) Impact of Channels & Resource Allocation

0

200

400

600

800

1000

1200

2 4 8 16 32 0

10000

Th

rou

gh

pu

t (t

ps

)

Allocated vCPUs (for all peers)(a) Homogeneous Peers, 16 Channels

Throughput

0

200

400

600

800

1000

1200

(8,0) (4,4) (2,6) (0,8) 0

10000

Th

rou

gh

pu

t (t

ps

)

#Peers with (2, 32) vCPUs(b) Heterogeneous Peers, 16 Channels

Throughput

With increase in the number of channels à Throughput increases due to additional parallelism

Impact of Resource Allocation: Homogeneous & Heterogeneous Peers

2 * 2 + 6 * 32 = 196 vCPUs

8 * 16 = 128 vCPUs

21

Page 22: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(3) Impact of Channels & Resource Allocation

• Guideline on configuring resources for channels• Dedicated vCPUs per channel à for the maximum performance & avoid interference

• Homogeneous resource allocation is important – means the proportion as per demand and not mean the same amount of resources. For e.g.,

• If Peer 1 receives 1000 tps, it might require 2 vCPUs• If Peer 2 receives 500 tps, it might require only 1 vCPUs

• Research opportunity• Each channel would receive different load at different period

• Need for efficient resource sharing among channels

• Dynamic resource provisioning to ensure homogeneous resource allocation as per the demand

22

Page 23: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

(4) Impact of State DB choice & Transaction Complexities

• Conducted experiments with different transactions complexities for both GolevelDB & CouchDB• Refer to the paper for results

• Research opportunity:

• The usage of DB such as GoLevelDB and CouchDB, without snapshot isolation level, results in the whole database lock -- not good to achieve higher throughput

• DB does not provide read & write set per transaction -- need to enhance DB

• Need to make DB more aware of blockchain operations and aid blockchain transactions to improve performance

23

Page 24: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Fault Tolerance

• Peer failure does not affect the performance during non-overloaded scenario• App can collect endorsement from other available peers – application dependent

• Node rejoining after a failure need to sync up with other peers• Fetch missing blocks, validate and commit old transactions

• During overloaded scenario, rejoining peer could not sync up• Rate(new blocks added) = Rate(old blocks fetched by the rejoining peer) = peek rate

• Research opportunity:• protocol for rejoining peer’s sync up so that with any block commit rate, peer should be able to sync

• Adding a new peer is even worse -- need to fetch blocks from the beginning of the time, validate & commit

24

Page 25: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Proposed Optimizations & Performance Improvement

1. Introduce crypto cache to avoid repetitive crypto operations• 3X improvement -- 140 tps to 520 tps

2. Parallelly validate multiple transactions in a block – in VSCC validation phase • 7X improvement -- 140 tps to 980 tps

3. Bulk read/write during MVCC Validation and Commit• 2.5X improvement -- 50 tps to 115 tps for CouchD

Combining all three optimization resulted in 16X improvement -- 140 tps to 2250 tps

Performance Improvement from Hyperledger Fabric v1.0 to Fabric v1.1

25

Page 26: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Conclusion

• Conducted a comprehensive performance benchmarking to 1. Provide guidelines on configuring parameters2. Improve the performance by 16X3. Identity research opportunity

• Future work -- to reach 20,000 tps to support RTGS systems• Sharding• Distributed validation

26

Page 27: Performance Benchmarking & Optimizing …mascots/Papers/blockchain.pdf•Commit the block to block storage and valid transactions to state/history DB 8 Motivation for Performance Benchmarking

Thank You!Questions?

27