GithubHelp home page GithubHelp logo

divanodestiny / trustedbench Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trustedblockchain/trustedbench

0.0 1.0 0.0 9.6 MB

A blockchain benchmark framework to measure performance of multiple blockchain solutions

License: Apache License 2.0

Shell 1.67% JavaScript 87.23% Dockerfile 0.62% HTML 3.81% Go 3.20% Python 2.66% PHP 0.81%

trustedbench's Introduction

TrustedBench Introduction

TrustedBench is a blockchain performance benchmark framework, which allows users to test different blockchain solutions with predefined use cases, and get a set of performance test results. TrustedBench is a secondary developed product based on hyperledger Caliper.

Currently supported blockchain solutions:

Hyperledger Composer is also supported, please see Composer Performance Test.

Currently supported performance indicators:

  • Success rate
  • Transaction/Read throughput
  • Transaction/Read latency(minimum, maximum, average, percentile)
  • Resource consumption (CPU, Memory, Network IO,...)

See [to add the link to PSWG] to find out the definitions and corresponding measurement methods.

##Achitecture See Architecture introduction.

Build

Pre-requisites

Make sure following tools are installed

  • NodeJS 8.X
  • node-gyp
  • Docker
  • Docker-compose

Run npm install in TrustedBench folder to install dependencies locally

Install blockchain SDKs

  • Fabric

    • Install using the repository
      • run npm install fabric-ca-client fabric-client in the root folder
      • If you want to test fabric with old version such as v1.1.0, you should install compatible client SDK,
        e.g. npm install [email protected] [email protected]
  • Sawtooth

    • Install dependencies

      $npm install protocol-buffers
      
    • Install sawtooth javascript sdk using repository

      • run npm install sawtooth-sdk in the root folder
  • Iroha

    • Install dependencies

      $sudo apt-get install libv8-dev 
      $install google-protobuf grpc
      
    • A precompiled Iroha library is provided in src/iroha/external, which is compiled with Ubuntu 14 x86_64. The library should be replaced if it is incompatible with the under platform.

  • Composer

    • Install dependencies The easiest way to get started using a target version of Composer is to update the main package.json file to include the required Composer and Fabric modules, and subsequently run an npm install command. It is important that the Composer and Fabric versions are compatible.
     "composer-admin": "0.19.0",
     "composer-client": "0.19.0",
     "composer-common": "0.19.0",
     "fabric-ca-client": "1.1.0",
     "fabric-client": "1.1.0",
    

    Please see the plugin documentation for more details on using the Composer performance plugin, and developing your own tests.

Run benchmark

All predefined benchmarks can be found in benchmark folder. To start your first benchmark, just run this in root folder

node benchmark/simple/main.js -c yourconfig.json -n yournetwork.json
  • -c : specify the config file of the benchmark, if not used, config.json will be used as default.
  • -n : specify the config file of the blockchain network under test. If not used, the file address must be specified in the benchmak config file.

Some example SUTs are provided in network folder, they can be launched automatically before the test by setting the bootstrap commands in the configuration file, e.g

{
  "command" : {
    "start": "docker-compose -f network/fabric/simplenetwork/docker-compose.yaml up -d",
    "end" : "docker-compose -f network/fabric/simplenetwork/docker-compose.yaml down;docker rm $(docker ps -aq)"
  }
}

The scripts defined in command.start will be called before the test, and the scripts defined in command.end will be called after the finish of all tests. You can use them to define any preparation or clean-up works.

You can also run the test with your own blockchain network, a network configuration should be provided and corresponding file path should be specified in configuration file's blockchain.config.

Note:

  • When running the benchmark, one or more blockchain clients will be used to generate and submit transactions to the SUT. The number of launched clients as well as testing workload can be defined using the configuration file.
  • A HTML report will be generated automatically after the testing.

Alternative

You can also use npm scripts to run a benchmark.

  • npm run list: list all available benchmarks
$ npm run list

> [email protected] list /home/XXX/TrustedBench
> node ./scripts/list.js

Available benchmarks:
drm
simple
  • npm test: run a benchmark with specific config files
$ npm test -- simple -c ./benchmark/simple/config.json -n ./benchmark/simple/fabric.json

> [email protected] test /home/XXX/TrustedBench
> node ./scripts/test.js "simple" "-c" "./benchmark/simple/config.json" "-n" "./benchmark/simple/fabric.json"
......

Run benchmark with distributed clients (experimental)

In this way, multiple clients can be launched on distributed hosts to run the same benchmark.

  1. Start the ZooKeeper service

  2. Launch clients on target machines separately by running node ./src/comm/client/zoo-client.js zookeeper-server or npm run startclient -- zookeeper-server . Time synchronization between target machines should be executed before launching the clients.

    Example:

    $ npm run startclient -- 10.229.42.159:2181
    
    > [email protected] startclient /home/XXX/TrustedBench
    > node ./src/comm/client/zoo-client.js "10.229.42.159:2181"
    
    Connected to ZooKeeper
    Created client node:/TrustedBench/clients/client_1514532063571_0000000006
    Created receiving queue at:/TrustedBench/client_1514532063571_0000000006_in
    Created sending queue at:/TrustedBench/client_1514532063571_0000000006_out
    Waiting for messages at:/TrustedBench/client_1514532063571_0000000006_in......
  3. Modify the client type setting in configuration file to 'zookeeper'.

    Example:

    "clients": {
      "type": "zookeeper",
      "zoo" : {
        "server": "10.229.42.159:2181",
        "clientsPerHost": 5
      }
    }
    
  4. Launch the benchmark on any machine as usual.

Note:

  • Zookeeper is used to register clients and exchange messages. A launched client will add a new znode under /TrustedBench/clients/. The benchmark checks the directory to learn how many clients are there, and assign tasks to each client according to the workload.
  • There is no automatic time synchronization between the clients. You should manually synchronize time between target machines, for example using 'ntpdate'.
  • The blockchain configuration file must exist on machines which run the client, and the relative path (relative to the TrustedBench folder) of the file must be identical. All referenced files in the configuration must also exist.

Write your own benchmarks

TrustedBench provides a set of nodejs NBIs (North Bound Interfaces) for applications to interact with backend blockchain system. Check the src/comm/blockchain.js to learn about the NBIs. Multiple Adaptors are implemented to translate the NBIs to different blockchain protocols. So developers can write a benchmark once, and run it with different blockchain systems.

Generally speaking, to write a new TrustedBench benchmark, you need to:

  • Write smart contracts for systems you want to test
  • Write a testing flow using TrustedBench NBIs. TrustedBench provides a default benchmark engine, which is pluggable and configurable to integrate new tests easily. For more details, please refer to Benchmark Engine .
  • Write a configuration file to define the backend network and benchmark arguments.

Directory Structure

Directory Description
/benchmark Samples of the blockchain benchmarks
/docs Documents
/network Boot configuration files used to deploy some predefined blockchain network under test.
/src Souce code of the framework
/src/contract Smart contracts for different blockchain systems

How to contribute

See Contributing

License

The TrustedBench codebase is release under the Apache 2.0 license. Any documentation developed by the TrustedBench Project is licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.

trustedbench's People

Contributors

aklenik avatar davidkhala avatar feihujiang avatar nklincoln avatar ram-srini avatar subhodi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.