fabric-gateway-java vs fabric-java-pool 写测试

文章目录

  • fabric-gateway-java vs fabric-java-pool 写测试
  • 为什么这么应用?
  • 代码案例&它的原理?
  • 对比fabric-gateway-java
  • 附录

fabric-gateway-java vs fabric-java-pool 写测试

fabric-java-pool 是一个将fabric-gateway-java和fabric-sdk-java基础上封装为链接池使得开发人员可以像使用jdbc链接池那样使用fabric的个人项目。

为什么这么应用?

我们假设同一组织内的员工采用组织的账号来授权区块链上的交易。比如同一新闻社的记者或者编辑将他们的文章发布的同时上链做版权认证。

Person 1 webUI Person 2 Mobile APP Java Server Blockchain Network publish new article publish new article publish me some data It takes some time for completed publish me some data publish me some data publish me some data It takes some time for completed Person 1 webUI Person 2 Mobile APP Java Server Blockchain Network

代码案例&它的原理?

FabricJavaPool

对比fabric-gateway-java

测试结果:

fabric-gateway-java vs fabric-java-pool 写测试_第1张图片
为什么会这样:
先看出块的设置块是1s一出的,我们client的tps远远不足100000的块数,因为fabric-gateway-java监听了落块,而fabric-java-pool使用fabric-sdk-java时没有监听,所以最快,gateway-pool和gateway性能接近,1m一个请求。

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

# 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: 100000

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 512 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 MB

那么,我们把块改小点,10次一出块

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

# 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: 512 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 MB

fabric-gateway-java vs fabric-java-pool 写测试_第2张图片
所以我们看到,是检查落块机制导致的时间区别。使用pool能够提升一定的性能,但是性能还是由出块和落块决定的。

在每个提交都出块的情况下对比pool和没有pool情况下使fabric-gateway-java
fabric-gateway-java vs fabric-java-pool 写测试_第3张图片

附录

  • 项目地址
  • 读测试
  • Hyperledger Fabric性能测试相关文章总结(个人向)

你可能感兴趣的:(Fabric,Hyperledger,FabricJavaPool)