The current Node.JS project contains a TPC-C workload implementation for a custom Hyperledger Caliper v0.3.2. The project consists of the following main artifacts:
benchconfig.yaml
: the benchmark configuration file that describes the rounds and their parameters that constitute the benchmark run.load.js
: the workload module that implements the data ingestion phase of the TPC-C benchmark, i.e., when entries are inserted into the database.execute.js
: the workload module that implements the actual execution of the TPC-C benchmark, i.e., when transactions of different types are generated and submitted by terminals.tpcc/
: the Caliper-independent implementation of TPC-C entry and transaction data generators.
The execution of the workload requires the following preparation steps:
- Get the supported Caliper version.
- Configure the workload.
- Set up a Fabric network and Execute the workload with Caliper.
Currently, only the custom klenik/caliper-fabric-1.4.17:experimental Caliper Docker image can execute the implemented workload. The image pre-bound Caliper to the v1.4 Fabric SDK version, however, Fabric v2 networks might also be targeted (not tested) by rebinding during the benchmark execution.
The available configurations of the workload can be changed in the benchconfig.yaml benchmark configuration file.
Some common attributes are extracted into a single place in the configuration using YAML anchors and aliases:
tpccArgs.warehouses
: The number of warehouses (and corresponding entries) to insert into the Fabric state database during the data loading phase.tpccArgs.scaleFactor
: The integer scaling factor to apply on the number of entries. A scale factor of1
corresponds to the TPC-C standard specification. A scale factor of10
scales down the number of entries to the tenth of the numbers specified by the standard. Used mainly for testing purposes, change it with care!
Notes (details in the related research paper):
- The standard specifies that 10 terminals must correspond to each warehouse. Increasing the terminal/warehouse ratio will result in increased data access conflicts.
The first round of the benchmark is the data loading phase (tests.rounds[0]
in the benchmark configuration). The following aspects can be configured for this round:
rateControl
: can be set to a supported Caliper rate controller specification.arguments.batchSize
: TPC-C entries are loaded in batches, i.e., a single Fabric transaction inserts multiple entries into the state database. This attribute specifies the number of entries in such a batch.arguments.invokeTimeout
: Larger batches might take more time to be committed to the ledger, thus this attribute specifies the load-specific timeout for Fabric transactions.arguments.warehouses
: See above.arguments.scaleFactor
: See above.
Notes:
- The
requiredWorkers
attribute should be set to1
, as the current implementation does not support distributed data loading. I.e., a single worker will load every entry into the Fabric state database. Our experience is that a single worker is enough to saturate Fabric during this write-heavy phase.- The optimal combination of the
rateControl
andarguments.batchSize
attributes depends on the Fabric setup. Since data loading usually takes relatively long, first it is recommended to empirically determine the optimal combination using a single warehouse setup.
The second round of the benchmark is the TPC-C execution phase (tests.rounds[1]
in the benchmark configuration). The following aspects can be configured for this round:
requiredWorkers
: The number of Caliper workers to use for the execution phase of the benchmark. Defaults to thetest.workers.number
attribute value, i.e., all available Caliper workers will be used to generate the workload in the second round.txDuration
: Specifies the duration of the measurement in milliseconds.arguments.warehouses
: See above.arguments.scaleFactor
: See above.timing
: Boolean value that indicates whether the implementation should emulate the timing constraints of the standard. Disable (and violate the standard) for higher workload rate.clients
: The number of TPC-C terminals to emulate within a single Caliper worker.
Notes (details in the related research paper):
- A single worker can emulate multiple terminals. However, too many terminals within a single worker can affect the precision of transaction scheduling.
Perform the following prerequisite steps to initialize the Fabric network and prepare for the benchmark execution:
- Create a Fabric network;
- Create a Fabric channel;
- Deploy the TPC-C chaincode;
- Assemble a Caliper network configuration;
- Finally, run the benchmark.
The official Fabric samples or MiniFabric are convenient ways to easily deploy a local Fabric network for testing. Hyperledger Bevel and similar tools can help with deploying truly distributed, production-like networks.
While Caliper v0.3.2 is capable of creating channels on a Fabric network, this feature is deprecated, and the official Fabric binaries (or samples) should be used to create the required channel.
While Caliper v0.3.2 is capable of deploying chaincodes to a Fabric network, this feature is deprecated, and the official Fabric binaries (or samples) should be used to deploy the TPC-C chaincode.
The workload generator is agnostic to the language and implementation details of the chaincode, but its exposed API (i.e., chaincode functions and their parameters) must conform to the TPC-C chaincode described here.
Caliper needs a Fabric network configuration file to communicate with the backend Fabric network. A sample network configuration is provided that can be modified to suit the deployed Fabric network, channel, identities, and chaincode.
The channel and chaincode IDs can be arbitrary, but the contractID
must be set to tpcc
in the configuration because the workload currently depends on that name to target the chaincode (see the remarks in the configuration file).
At this point the workload/caliper
directory contains every artifact required to run a Caliper benchmark:
- benchmark configuration file;
- network configuration file;
- workload modules (for both benchmark phases);
- and a running, initialized Fabric network.
Check out the corresponding documentation page on how to run Caliper in a Docker container.
Note: don't forget to use the custom Caliper Docker image to execute the benchmark: klenik/caliper-fabric-1.4.17:experimental
The project uses the Apache License Version 2.0. For more information see NOTICES.md, CONTRIBUTORS.md, and LICENSE.