0

您好,我创建了一个 Hyperledger Fabric 网络,当我一次提交几个交易提案时工作正常,但由于我必须进行一些基准测试,所以当我向具有高发送率的对等方发送多个提案时出现错误。该网络具有以下元素:

  • 3 组织
  • 3 个对等点(每个组织一个)
  • 1 订购者
  • 1 个频道
  • 1 使用 fabric-chaincode-shim 1.4.4 编译的 Java 链码
  • 链码的背书策略需要所有对等方的积极回复来验证交易

全部在一台机器上运行:

英特尔 i7-8750H CPU @ 2.20GHz

8 GB 内存 DDR4

带有内核 5.0.0-35-generic 的 Ubuntu 19.04

Docker 版本 19.03.4

码头工人撰写版本 1.21.0

peers 和 orderer 的 Docker 容器使用 1.4.3 版本的 Fabric 镜像,但我尝试了最新的,结果是一样的。

我使用 Hyperledger Caliper 以高发送率提交提案,其中一些被同行接受(数量因执行而异)但其他人因以下错误而失败:

Transaction[901d0036b2] 生命周期错误:

peer0.org1.com 的提案响应错误:事务返回失败:未能提交任务进行处理

我在这里报告了错误的对等日志片段:

peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1439 21:14:56:720 FINE    org.hyperledger.fabric.shim.impl.InnvocationTaskManager onChaincodeMessage       [2b83c641] {
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143a   "type": "TRANSACTION",
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143b   "payload": "ChVpbml6aWFDb3JzYU1vYlN0YXRpY2EKCHBhc3F1YWxlCgp0cmVuaXRhbGlhCggxMTcwODM0MgoFMTM6MDAKBGF1dG8KFnBhcmNoZWdnaW9fZnVvcmlncm90dGEKA2duaQ==",
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143c   "txid": "2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25",
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143d   "proposal": {
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143e     "proposalBytes": "CvkHCnUIAxABGgwI0Ijx7gUQgLnvogIiDGNvcnNlY2hhbm5lbCpAMmI4M2M2NDEzNzE1NzNiNDlkN2Q4ODU4OTQwNGMxNGFjNWIwM2ZkMTRhMWE3ZTUzOGNkZmIxNDM1OTk3MmEyNToREg8SDWNvcnNhY29udHJhY3QS/wYK4gYKDk9yZ0NpdGl6ZW5zTVNQEs8GLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNRekNDQWVtZ0F3SUJBZ0lRVkdPVVpQMElaRUhUTWJ4SSszUmJvREFLQmdncWhrak9QUVFEQWpDQmd6RUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhJVEFmQmdOVkJBb1RHRzl5WjBOcGRHbDZaVzV6TG0xNWQyRjVNbWR2TG1OdmJURWtNQ0lHCkExVUVBeE1iWTJFdWIzSm5RMmwwYVhwbGJuTXViWGwzWVhreVoyOHVZMjl0TUI0WERURTVNVEF4TkRJek1EQXcKTUZvWERUSTVNVEF4TVRJek1EQXdNRm93ZERFTE1Ba0dBMVVFQmhNQ1ZWTXhFekFSQmdOVkJBZ1RDa05oYkdsbQpiM0p1YVdFeEZqQVVCZ05WQkFjVERWTmhiaUJHY21GdVkybHpZMjh4RHpBTkJnTlZCQXNUQm1Oc2FXVnVkREVuCk1DVUdBMVVFQXd3ZVZYTmxjakZBYjNKblEybDBhWHBsYm5NdWJYbDNZWGt5WjI4dVkyOXRNRmt3RXdZSEtvWkkKemowQ0FRWUlLb1pJemowREFRY0RRZ0FFd3JoZ0JlVXVPQVhDZmVVbGdKVG9YM053ckdraE1meHdUR0ZpRjFxcgp2YWRXR1c0VTBsUDlwdjg2cXVnelNXS3AzRTI0em5iNjNTWUdONHc0c2o0VVQ2Tk5NRXN3RGdZRFZSMFBBUUgvCkJBUURBZ2VBTUF3R0ExVWRFd0VCL3dRQ01BQXdLd1lEVlIwakJDUXdJb0FnaSszRHdteU9sTmtaa1BBbHZxcVoKWW5VeHpPU0puWVk3bU80WmRSSHR5a013Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUloQVBLSVlFcFhBbE9Ib05TNQpLNnlYQWxLb0FaM3VPYUlyWURxM1FrU1o0VlJkQWlCSWN0OUhCNFRNclhCU2V3K3ZuSzl3MUppOGt2NXFiaERDCmxzZlBrTWhxZnc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tChIYnuHVxQX6OmrGPWoF3N6vpFLq18V1SGXOEnoKeAp2CAESDxINY29yc2Fjb250cmFjdBphChVpbml6aWFDb3JzYU1vYlN0YXRpY2EKCHBhc3F1YWxlCgp0cmVuaXRhbGlhCggxMTcwODM0MgoFMTM6MDAKBGF1dG8KFnBhcmNoZWdnaW9fZnVvcmlncm90dGEKA2duaQ==",
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 143f     "signature": "MEUCIQDMAGTa6+CuBfav5v9+UsVo9vde5nMYIYbQpvDHgYrTRgIgeYseOCIm1CTwx3c8oIMVUkfVDt5nSvb6Ytd7x5lCtAk="
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1440   },
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1441   "channelId": "mychannel"
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1442 }
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1443 21:14:56:720 FINE    org.hyperledger.fabric.shim.impl.InnvocationTaskManager handleMsg                [2b83c641] Received TRANSACTION
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1444 21:14:56:720 FINE    org.hyperledger.fabric.shim.impl.InnvocationTaskManager newTask                  > newTask:created 2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1445 21:14:56:721 FINE    org.hyperledger.fabric.shim.impl.InnvocationTaskManager newTask                  > newTask:submitting 2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1446 21:14:56:721 WARNING org.hyperledger.fabric.shim.impl.InnvocationTaskManager newTask                  Failed to submit task 2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25Task java.util.concurrent.CompletableFuture$AsyncRun@39cf8f2a rejected from org.hyperledger.fabric.shim.impl.InnvocationTaskExecutor@e00a3e59[Running, pool size = 1, active threads = 1, queued tasks = 1, completed tasks = 15]
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1447 java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.CompletableFuture$AsyncRun@39cf8f2a rejected from org.hyperledger.fabric.shim.impl.InnvocationTaskExecutor@e00a3e59[Running, pool size = 1, active threads = 1, queued tasks = 1, completed tasks = 15]
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1448   at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1449   at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144a   at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144b   at java.util.concurrent.CompletableFuture.asyncRunStage(CompletableFuture.java:1640)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144c   at java.util.concurrent.CompletableFuture.runAsync(CompletableFuture.java:1858)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144d   at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.newTask(InnvocationTaskManager.java:226)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144e   at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.handleMsg(InnvocationTaskManager.java:172)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 144f   at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.onChaincodeMessage(InnvocationTaskManager.java:141)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1450   at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$$Lambda$148.0000000094ECAD00.accept(Unknown Source)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1451   at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$1.onNext(ChaincodeSupportClient.java:86)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1452   at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$1.onNext(ChaincodeSupportClient.java:82)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1453   at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:429)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1454   at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1455   at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1456   at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:599)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1457   at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:584)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1458   at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1459   at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [endorser] callChaincode -> INFO 145a [mychannel][2b83c641] Exit chaincode: name:"mycontract"  (93ms)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 145b   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 145c   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 145d   at java.lang.Thread.run(Thread.java:819)
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 145e 
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 145f 21:14:56:722 FINE    org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$2 accept                 > sendToPeer 2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [peer.chaincode.dev-peer0.org1.com-mycontract-v0] func2 -> INFO 1460 21:14:56:722 FINE    org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$2 accept                 < sendToPeer 2b83c641371573b49d7d88589404c14ac5b03fd14a1a7e538cdfb14359972a25
peer0.org1.com         | 2019-11-25 21:14:56.723 UTC [endorser] SimulateProposal -> ERRO 1461 [mychannel][2b83c641] failed to invoke chaincode name:"mycontract" , error: transaction returned with failure: Failed to submit task for processing
peer0.org1.com         | github.com/hyperledger/fabric/core/chaincode.processChaincodeExecutionResult
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:266
peer0.org1.com         | github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:240
peer0.org1.com         | github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:147
peer0.org1.com         | github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:146
peer0.org1.com         | github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:247
peer0.org1.com         | github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:500
peer0.org1.com         | github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
peer0.org1.com         | github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:32
peer0.org1.com         | github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler.func1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:169
peer0.org1.com         | github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:31
peer0.org1.com         | github.com/hyperledger/fabric/core/comm.(*Throttle).UnaryServerIntercptor
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/core/comm/throttle.go:54
peer0.org1.com         | github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
peer0.org1.com         | github.com/hyperledger/fabric/common/grpclogging.UnaryServerInterceptor.func1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/common/grpclogging/server.go:91
peer0.org1.com         | github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
peer0.org1.com         | github.com/hyperledger/fabric/common/grpcmetrics.UnaryServerInterceptor.func1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/common/grpcmetrics/interceptor.go:30
peer0.org1.com         | github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:39
peer0.org1.com         | github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:171
peer0.org1.com         | github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).processUnaryRPC
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:982
peer0.org1.com         | github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).handleStream
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1208
peer0.org1.com         | github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1
peer0.org1.com         |    /opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:686
peer0.org1.com         | runtime.goexit
peer0.org1.com         |    /opt/go/src/runtime/asm_amd64.s:1337
peer0.org1.com         | 2019-11-25 21:14:56.724 UTC [comm.grpc.server] 1 -> INFO 1462 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.18.0.1:34430 grpc.code=OK grpc.call_duration=96.086094ms

正如消息 INFO 1447 所暗示的,对等方未能为提案创建新任务,可能是因为许多请求一起到达。这种考虑正确吗?有什么方法可以更改对等方可以创建的最大并行任务数?因为这种情况即使在 100 rps 的速率下也会发生,我认为我可以进一步推动性能。

解决方案

据此链接报道:

https://jira.hyperledger.org/browse/FAB-17110

当 Java 链码在 1.4.4 版本中使用 fabric-chaincode-shim 编译时,默认线程池设置得太低,使用链接中描述的解决方法我更改了池队列大小以减少高负载条件下丢弃的事务。

感谢 david_k 的回复。

4

1 回答 1

1

交易吞吐量取决于各种因素。超级账本结构中有不同的可配置参数

  • 块大小
  • 背书政策
  • 渠道
  • 国家数据库

使用这些参数以获得更好的吞吐量(tps)。

也有一些主要的瓶颈

  • 加密操作
  • 区块中 tx 的串行验证
  • 沙发数据库的多个休息 API

如果我们发送的 tx 超过网络容量,则 tx 将失败。CryptoOperation 是最繁重的,如果您使用节点 SDK(API),只需创建客户端对象和通道对象,几乎需要 150 到 200 毫秒(因资源而异)。尝试在创世区块中更改批次大小和批次时间,或者对背书策略进行一些更改。

于 2019-11-26T08:54:33.140 回答