fabric2.4.3环境搭建见:
超详细的Hyperledger Fabric2.4.3环境搭建
1. 安装nvm
sudo sucd ~git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`gedit .bashrc
将如下内容添加到文件末尾
source ~/.nvm/nvm.sh
保存退出
执行命令:
source.bashrc
查看nvm版本:
nvm --version#我的版本是0.33.11
2.安装node
执行命令:
nvm install v14.15.0
打开.bashrc文件
gedit .bashrc
在末尾加入:
export NVM_DIR="/Users/YOURUSERNAME/.nvm"[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
然后执行
source .bashrc
node -v#看看是不是v 14.15.0
npm -v#v6.14.8
3安装Hyperledger Caliper
- 这一步要让自己处于fabric-sample的上层目录中,一定要在这个地方进行操作,不然跑benchmark时会找不到文件
cd ~/fabric #根据自己的情况,让自己来到fabric-sample的上一级目录中
执行:下载caliperj文件
git clone https://github.com/hyperledger/caliper-benchmarks
然后打开caliper-benchmarks文件夹
cd caliper-benchmarks
执行命令,安装最新版的hyperledger caliper
npm install --only=prod @hyperledger/caliper-cli
绑定我们的hyperledger fabric2.4.3注意要对应自己的fabric版本
npx caliper bind --caliper-bind-sut fabric:2.4
查看版本:
npx caliper --version #目前最新版是0.5.0
对fabric2.4.3进行测试
cd ../fabric-samples/test-network
开启网络创建通道:
./network.sh up createChannel -s couchdb
执行结果:
对官方的fabcar案例进行压力测试
确保我们现在位于fabric-sample/test-network文件夹中
执行命令这条,将fabcar chainnode上链
./network.sh deployCC -ccn fabcar -ccp ../../caliper-benchmarks/src/fabric/samples/fabcar/go -ccl go
命令行截图:
然后就可以开启测试了:
先到caliper-benchmarks目录下
cd ../../caliper-benchmarks/
开始测试:
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/samples/fabric/fabcar/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
要跑好一会儿。。。完成后会在caliper-benchmarks文件夹中生成一个report.html文件:
report.html文件截图:
Caliper report
Summary of performance metrics
Name | Succ | Fail | Send Rate (TPS) | Max Latency (s) | Min Latency (s) | Avg Latency (s) | Throughput (TPS) |
---|---|---|---|---|---|---|---|
Create a car. | 5000 | 0 | 12.1 | 2.27 | 0.11 | 0.51 | 12.0 |
Change car owner. | 503 | 0 | 17.2 | 2.20 | 0.13 | 0.40 | 16.0 |
Query all cars. | 4885 | 0 | 168.2 | 0.14 | 0.01 | 0.04 | 168.1 |
Query a car. | 6100 | 0 | 210.3 | 1.06 | 0.00 | 0.03 | 210.2 |
Benchmark round: Create a car.
rateControl:type: fixed-loadopts:transactionLoad: 5
Performance metrics for Create a car.
Name | Succ | Fail | Send Rate (TPS) | Max Latency (s) | Min Latency (s) | Avg Latency (s) | Throughput (TPS) |
---|---|---|---|---|---|---|---|
Create a car. | 5000 | 0 | 12.1 | 2.27 | 0.11 | 0.51 | 12.0 |
Resource utilization for Create a car.
Benchmark round: Change car owner.
txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5
Performance metrics for Change car owner.
Name | Succ | Fail | Send Rate (TPS) | Max Latency (s) | Min Latency (s) | Avg Latency (s) | Throughput (TPS) |
---|---|---|---|---|---|---|---|
Change car owner. | 503 | 0 | 17.2 | 2.20 | 0.13 | 0.40 | 16.0 |
Resource utilization for Change car owner.
Benchmark round: Query all cars.
txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5
Performance metrics for Query all cars.
Name | Succ | Fail | Send Rate (TPS) | Max Latency (s) | Min Latency (s) | Avg Latency (s) | Throughput (TPS) |
---|---|---|---|---|---|---|---|
Query all cars. | 4885 | 0 | 168.2 | 0.14 | 0.01 | 0.04 | 168.1 |
Resource utilization for Query all cars.
Benchmark round: Query a car.
txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5
Performance metrics for Query a car.
Name | Succ | Fail | Send Rate (TPS) | Max Latency (s) | Min Latency (s) | Avg Latency (s) | Throughput (TPS) |
---|---|---|---|---|---|---|---|
Query a car. | 6100 | 0 | 210.3 | 1.06 | 0.00 | 0.03 | 210.2 |
Resource utilization for Query a car.
Test Environment
benchmark config
workers:type: localnumber: 5rounds:- label: Create a car.txNumber: 5000rateControl:type: fixed-loadopts:transactionLoad: 5workload:module: benchmarks/samples/fabric/fabcar/createCar.js- label: Change car owner.txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5workload:module: benchmarks/samples/fabric/fabcar/changeCarOwner.jsarguments:assets: 500- label: Query all cars.txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5workload:module: benchmarks/samples/fabric/fabcar/queryAllCars.jsarguments:assets: 500startKey: '1'endKey: '50'- label: Query a car.txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 5workload:module: benchmarks/samples/fabric/fabcar/queryCar.jsarguments:assets: 500
SUT
not provided