fabric-gateway-java vs fabric-java-pool 写测试
fabric-java-pool 是一个将fabric-gateway-java和fabric-sdk-java基础上封装为链接池使得开发人员可以像使用jdbc链接池那样使用fabric的个人项目。
为什么这么应用?
我们假设同一组织内的员工采用组织的账号来授权区块链上的交易。比如同一新闻社的记者或者编辑将他们的文章发布的同时上链做版权认证。
代码案例&它的原理?
对比fabric-gateway-java
测试结果:
为什么会这样:
先看出块的设置块是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
所以我们看到,是检查落块机制导致的时间区别。使用pool能够提升一定的性能,但是性能还是由出块和落块决定的。
在每个提交都出块的情况下对比pool和没有pool情况下使fabric-gateway-java