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

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

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

为什么这么应用?

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

Person 1webUIPerson 2Mobile APPJava ServerBlockchain Networkpublish new articlepublish new articlepublish me some dataIt takes some timefor completedpublish me some datapublish me some datapublish me some dataIt takes some timefor completedPerson 1webUIPerson 2Mobile APPJava ServerBlockchain Network

代码案例&它的原理?

FabricJavaPool

对比fabric-gateway-java

测试结果:

write_test_round_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

write_test_round_2
所以我们看到,是检查落块机制导致的时间区别。使用pool能够提升一定的性能,但是性能还是由出块和落块决定的。

在每个提交都出块的情况下对比pool和没有pool情况下使fabric-gateway-java
write_test_round_3

附录

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章