Caliper Multihost Benchmark Setup For Hyperledger Fabric

Caliper Multihost Benchmark Setup For Hyperledger Fabric

Caliper Multihost Benchmark Setup For Hyperledger Fabric

Caliper Multihost Benchmark Setup For Hyperledger Fabric

Caliper Multihost Benchmark Setup For Hyperledger Fabric

Table Of Content
Read Time: 4 minutes

Introduction

This tutorial is indent to help you setup fabric in multiple machine and taking benchmark using caliper.

Blockchain has emerged as a public ledger that records all transactions in the network and it is distributed among all the participants. It is decentralised hence no one controls the blockchain,but every individual user can inspect transactions at any time.

Later blockchain enters in the enterprise domain, where it is decentralised and at the same time the administrator of the organization can determine the roles and permissions of each node.

Hyperledger fabric is a private blockchain framework developed by IBM and it is the first project hosted by Linux foundation.

Hyperledger caliper is a blockchain benchmark tool,its is also hosted by linux foundation.Caliper is used to measure the performance of a specific blockchain implementation such as TPS(Transaction Per Second),transaction latency,resource utilisation

Prerequisites

  • You should be familiar with basic hyperledger fabric.
  • Make sure your machine has the following
  • Docker version 18.09.8,
  • docker-compose version 1.17.1
  • Node.js v8.16.0
  • NPM 6.4.1

Caliper Installation

After installing the  prerequisites, clone the caliper repository from github.

Run the command below to clone latest caliper repository.

Git clone https://github.com/hyperledger/caliper.git

Once the cloning is finished go to the caliper folder and install the required packages.

To install required packages go to caliper root directory follow the steps below.

npm install

npm run bootstrap

cd packages/caliper-tests-integration

npm run start_verdaccio

npm run publish_packages

npm run install_cli



Go to caliper-samples folder which is inside the caliper folder and run the command to ensure that caliper installation is successful.

caliper benchmark run --caliper-workspace ./ --caliper-benchconfig benchmark/simple/config.yaml --caliper-networkconfig network/fabric-v1.4.1/2org1peercouchdb/fabric-node.yaml

The above command will generate benchmark report in html format and stores it in the working directory.

We can setup fabric network easily by using the samples provided in the caliper-samples folder.

For this tutorial we will be using 2org1peercouchdb  of fabric 1.4.1.

As the name suggest we will be having the code to set up fabric network with two organisations each having one peer.You can also experiment with other samples with tls enabled or disabled as you prefer.For this tutorial the minimal approach is taken for basic understanding.

Caliper requires a benchmark configuration file and fabric network configuration file.The benchmark configuration file defines the arguments such as workload and monitoring settings. The network configuration file or the blockchain configuration file specifies the information required to interact with the backend blockchain network.

For this tutorial we will be using simple benchmark config which is provided in the samples.We need to modify the fabric network configuration file to specify ip address of the other physical machine.If you want to create more number of organisations and peers you must edit crypto-config.yaml and configtx.yaml with with required changes and generate artifacts.

Initially we will edit fabric-node.yaml in the first machine.This is our network configuration file that caliper requires.In the caliper samples under the network directory open  fabric1.4.1 and edit fabric-node.yaml.After editing the file should be like the following.

1st machine fabric-node.yaml


<script src="https://gist.github.com/devilbits/8a50cf4ea7cc0f8332238528c765e1c8.js"></script>


As mentioned earlier our first machine consists of an organization with one peer,an orderer and a certificate authority.According to this we modify docker-compose.yaml 

1st machine docker-compose.yaml <script src="https://gist.github.com/devilbits/4cec3b568a2281ea3cc3bfd2e489c2f7.js"></script>

In the second machine we need to setup a fabric network having one organization with a single peer. We can use the samples provided in the caliper-samples directory.To do that we have to install caliper on second machine.Follow the caliper installation steps given above to install the caliper on the second machine

On the second machine we have another organisation having single peer.Here we only need to edit the docker-compose.yaml. We need to add peer from first organisation as an extra hosts so that the two peers can establish a channel and communicate.

After editing the file should be as below :

docker-compose.yaml

<script src="https://gist.github.com/devilbits/b600c7e1d9d6d9f59ee409410941875d.js"></script>

Run the below command to start the peer.

Docker-compose up -d

We have to run caliper in first machine.The second machine will join the network.

After completing all the above steps,In first machine enter the command below to get benchmark readings.We assume that you are in caliper-sample directory.if not then please make sure the path for the files in the command are entered correctly.

caliper benchmark run

 --caliper-workspace ./ --caliper-benchconfig benchmark/simple/config.yaml --caliper-networkconfig network/fabric-v1.4.1/2org1peergoleveldb/fabric-node.yaml


 Automated Caliper multi-host network setup using the script:

Prerequisites

  • Docker version 18.09.8,
  • docker-compose version 1.17.1
  • Node.js v8.16.0
  • NPM 6.4.1
  • Before running the scripts make sure you have installed the prerequisites with latest version except node,we recommend using node 8.
  • These steps are automated using shell script , there are two scripts,one for setting up the first machine and one for setting up the second machine.

In your first machine create a new file first_machine_setup.sh or any name you like ending with an extension .sh and copy the code below 

<script src="https://gist.github.com/devilbits/050d124a833681695a6e774e70f1ad81.js"></script>

If your newly created script is not executable use the command below to make it executable and run it.

Sudo chmod 777 first_mechine_setup.sh

In the second machine create a file second_machine_setup.sh and copy the code below

<script src="https://gist.github.com/devilbits/0fb6b14c97a4dcb47cc73baa77c0f10f.js"></script>

Run the below commands to make it executable and to run.

Sudo chmod 777 second_mechine_setup.sh




./second_machine_setup.sh

To run caliper go to the caliper-samples directory and enter the code below

caliper benchmark run --caliper-workspace ./ --caliper-benchconfig benchmark/simple/config.yaml --caliper-networkconfig network/fabric-v1.4.1/2org1peergoleveldb/fabric-node.yaml

At QuillHash, we understand the Potential of Blockchain and have a good team of developers who can develop any blockchain applications like Smart Contracts, dApps,Smart Coins, DeFi, DEX on the any Blockchain Platform like Ethereum, EOS and Hyperledger.

To be up to date with our work, Join Our Community :-

Telegram | Twitter | Facebook | LinkedIn

3,882 Views

Blockchain for dog nose wrinkles' Ponzi makes off ~$127M🐶

Project promised up to 150% returns on investment in 100 days, raising about 166.4 billion South Korean won — or about $127 million — from 22,000 people.

Latest blogs for this week

Understanding Fuzzing and Fuzz Testing: A Vital Tool in Web3 Security

Read Time: 5 minutes When it comes to smart contracts, ensuring the robustness and security of code is paramount. Many techniques are employed to safeguard these contracts against vulnerabilities
Read More

How EigenLayer’s Restaking Enhances Security and Rewards in DeFi

Read Time: 7 minutes Decentralized finance (DeFi) relies on Ethereum staking to secure the blockchain and maintain consensus. Restaking allows liquid staking tokens to be staked with validators in
Read More

ERC 404 Standard: Everything You Need to Know

Read Time: 7 minutes Introduction Ethereum has significantly shaped the crypto world with its introduction of smart contracts and decentralized applications (DApps). This has led to innovative developments in
Read More

DNS Attacks:  Cascading Effects and Mitigation Strategies

Read Time: 8 minutes Introduction DNS security is vital for a safe online space. DNS translates domain names to IP addresses, crucial for internet functionality. DNS ensures unique name-value
Read More

EIP-4844 Explained: The Key to Ethereum’s Scalability with Protodanksharding

Read Time: 7 minutes Introduction  Ethereum, the driving force behind dApps, has struggled with scalability. High fees and slow processing have limited its potential. They have kept it from
Read More

QuillAudits Powers Supermoon at ETH Denver!

Read Time: 4 minutes Calling all the brightest minds and leaders in the crypto world! Are you ready to build, connect, and innovate at the hottest event during ETH
Read More

Decoding the Role of Artificial Intelligence in Metaverse and Web3

Read Time: 7 minutes Introduction  Experts predict a transformative shift in global software, driven by AI and ML, marking the dawn of a new era. PwC predicts AI will
Read More

Transforming Assets: Unlocking Real-World Asset Tokenization

Read Time: 7 minutes In the blockchain, real-world assets (RWAs) are digital tokens that stand for tangible and conventional financial assets, including money, raw materials, stocks, and bonds. As
Read More
Scroll to Top

Become a Quiffiliate!
Join our mission to safeguard web3

Sounds Interesting, Right? All you have to do is:

1

Refer QuillAudits to Web3 projects for audits.

2

Earn rewards as we conclude the audits.

3

Thereby help us Secure web3 ecosystem.

Total Rewards Shared Out: $200K+