Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Hyperledger结构-Fabcar性能_Node.js_Performance_Hyperledger Fabric_Hyperledger - Fatal编程技术网

Node.js Hyperledger结构-Fabcar性能

Node.js Hyperledger结构-Fabcar性能,node.js,performance,hyperledger-fabric,hyperledger,Node.js,Performance,Hyperledger Fabric,Hyperledger,我正在尝试使用Hyperledger Fabric运行一个项目,其设置类似于Fabcar示例 我对提交交易所需的大量时间感到惊讶 为了使它简单且完全可复制,我测量了在实际的Fabcar项目上提交事务createCar所需的时间。 设置网络(startFabric.shjavascript)并注册管理员和用户后,我运行invoke.js脚本整个脚本大约需要2.5秒 据我所知,运行合同只需几毫秒。发送交易建议时也是如此。 它主要花费时间让eventHandler监听和等待事件(在transactio

我正在尝试使用Hyperledger Fabric运行一个项目,其设置类似于Fabcar示例

我对提交交易所需的大量时间感到惊讶

为了使它简单且完全可复制,我测量了在实际的Fabcar项目上提交事务
createCar
所需的时间。 设置网络(
startFabric.sh
javascript)并注册管理员和用户后,我运行
invoke.js
脚本整个脚本大约需要2.5秒

据我所知,运行合同只需几毫秒。发送交易建议时也是如此。 它主要花费时间让eventHandler监听和等待事件(在
transaction.js
库中)


有没有办法加快这一进程?我希望每秒能够提交几个事务。

简短回答:在configtx.yaml中减少BatchTimeout

长答覆:

如果您只运行一个查询,如您所描述的,这是完全正常的

如果查看configtx.yaml,在“Orderer”部分,您可以看到:

Orderer: &OrdererDefaults

# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo

Addresses:
    - orderer.example.com:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s

# Batch Size: Controls the number of messages batched into a block
BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # Preferred Max Bytes: The preferred maximum number of bytes allowed for
    # the serialized messages in a batch. A message larger than the preferred
    # max bytes will result in a batch larger than preferred max bytes.
    PreferredMaxBytes: 512 KB
有两件重要的事情:

  • 批处理超时
  • MaxMessageCount
BatchTimeout定义创建块之前的最长时间。这意味着,在进行调用时,订购方计算事务并等待2秒钟,然后再创建块。这意味着,每个第一次交易将花费2秒以上的时间!但是如果有另一个调用,比如说,在第一个事务后1,5秒,第二个调用将花费不到1秒的时间

MaxMessageCount,为自己说话。这意味着,如果有10个以上的调用,将创建一个块,即使这2秒还没有过去。例如,在0.5s的行中调用10次将在不到一秒钟的时间内创建块

此设置用于根据您的网络平衡负载。假设您有一个低使用率的应用程序,其tps(每秒事务数)小于10,您可以将BatchTimeout减少到2秒以下,以增加调用的响应时间。如果tps较高,可以增加MaxMessageCount以创建更大的块

其他设置定义消息的最大大小

尝试了解您的网络将如何,使用测试用例模拟估计的测试程序集,并调整参数以找到您需要的配置