实战Caliper测试多机Fabric环境

成功跑完caliper自带例子之后,本人尝试使用caliper来测试自己部署的多机fabric环境。

被测fabric网络拓扑

1orderer、3peer、kafka共识、无ca、native启动(非docker)。

IP 节点 域名
10.254.186.164 orderer orderer.example.com
10.254.186.164 peer peer0.org1.example.com
10.254.247.165 peer peer1.org1.example.com
10.254.207.154 peer peer0.org2.example.com
10.254.186.164 kafka 无需

Caliper配置文件

基准测试配置

{
  "blockchain": {
    "type": "fabric",
    "config": "benchmark/simple/fabric-test.json"
  },
  "command" : {
  },
  "test": {
    "name": "simple",
    "description" : "This is an example benchmark for caliper, to test the backend DLT's performance with simple account opening & querying transactions",
    "clients": {
      "type": "local",
      "number": 1
    },
    "rounds": [{
      "label" : "open",
      "txNumber" : [1000, 1000, 1000,1000, 1000, 1000],
      "rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 50}}, {"type": "fixed-rate", "opts": {"tps" : 100}}, {"type": "fixed-rate", "opts": {"tps" : 150}},{"type": "fixed-rate", "opts": {"tps" : 200}},{"type": "fixed-rate", "opts": {"tps" : 250}},{"type": "fixed-rate", "opts": {"tps" : 300}}],
      "arguments": { "money": 10000 },
      "callback" : "benchmark/simple/open.js"
    },
    {
      "label" : "query",
      "txNumber" : [5000, 5000,5000, 5000,5000, 5000],
      "rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 100}}, {"type": "fixed-rate", "opts": {"tps" : 200}},{"type": "fixed-rate", "opts": {"tps" : 300}},{"type": "fixed-rate", "opts": {"tps" : 400}},{"type": "fixed-rate", "opts": {"tps" : 500}},{"type": "fixed-rate", "opts": {"tps" : 600}}],
      "callback" : "benchmark/simple/query.js"
    }]
  },
  "monitor": {
    "type": ["docker", "process"],
    "docker":{
      "name": ["all"]
    },
    "process": [
      {
        "command" : "node",
        "arguments" : "local-client.js",
        "multiOutput" : "avg"
      }
    ],
    "interval": 1
  }
}

区块链网络配置

{
  "blockchain": {
    "type": "fabric",
    "config": "benchmark/simple/fabric-test.json"
  },
  "command" : {
  },
  "test": {
    "name": "simple",
    "description" : "This is an example benchmark for caliper, to test the backend DLT's performance with simple account opening & querying transactions",
    "clients": {
      "type": "local",
      "number": 1
    },
    "rounds": [{
      "label" : "open",
      "txNumber" : [1000, 1000, 1000,1000, 1000, 1000],
      "rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 50}}, {"type": "fixed-rate", "opts": {"tps" : 100}}, {"type": "fixed-rate", "opts": {"tps" : 150}},{"type": "fixed-rate", "opts": {"tps" : 200}},{"type": "fixed-rate", "opts": {"tps" : 250}},{"type": "fixed-rate", "opts": {"tps" : 300}}],
      "arguments": { "money": 10000 },
      "callback" : "benchmark/simple/open.js"
    },
    {
      "label" : "query",
      "txNumber" : [5000, 5000,5000, 5000,5000, 5000],
      "rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 100}}, {"type": "fixed-rate", "opts": {"tps" : 200}},{"type": "fixed-rate", "opts": {"tps" : 300}},{"type": "fixed-rate", "opts": {"tps" : 400}},{"type": "fixed-rate", "opts": {"tps" : 500}},{"type": "fixed-rate", "opts": {"tps" : 600}}],
      "callback" : "benchmark/simple/query.js"
    }]
  },
  "monitor": {
    "type": ["docker", "process"],
    "docker":{
      "name": ["all"]
    },
    "process": [
      {
        "command" : "node",
        "arguments" : "local-client.js",
        "multiOutput" : "avg"
      }
    ],
    "interval": 1
  }
}
[dc2-user@cli caliper]$ cat benchmark/simple/fabric-test.json
{
  "fabric": {
    "cryptodir": "network/fabric/simple/crypto-config-test",
    "network": {
      "orderer": {
        "url": "grpcs://10.254.186.164:7050",
        "mspid": "OrdererMSP",
        "domain": "example.com",
    "user": {
          "key": "network/fabric/simple/crypto-config-test/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/80a9e436031bf3df0a79ea7523d66dfb04ac659ef5b637dc945dae0b07949abe_sk",
          "cert": "network/fabric/simple/crypto-config-test/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/Admin@example.com-cert.pem"
        },
        "server-hostname": "orderer.example.com",
        "tls_cacerts": "network/fabric/simple/crypto-config-test/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
      },
      "org1": {
        "name": "Org1MSP",
        "mspid": "Org1MSP",
        "domain": "org1.example.com",
    "user": {
          "key": "network/fabric/simple/crypto-config-test/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/90a3c8fafce618c26fbb8be65497ba40e03e60684e7288b346dfa370f93cf06a_sk",
          "cert": "network/fabric/simple/crypto-config-test/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
        },
        "peer1": {
          "requests": "grpcs://10.254.186.164:7051",
          "events": "grpcs://10.254.186.164:7053",
          "server-hostname": "peer0.org1.example.com",
          "tls_cacerts": "network/fabric/simple/crypto-config-test/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
        },
        "peer2": {
          "requests": "grpcs://10.254.247.165:7051",
          "events": "grpcs://10.254.247.165:7053",
          "server-hostname": "peer1.org1.example.com",
          "tls_cacerts": "network/fabric/simple/crypto-config-test/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
        }
      },
      "org2": {
        "name": "Org2MSP",
        "mspid": "Org2MSP",
        "domain": "org2.example.com",
    "user": {
          "key": "network/fabric/simple/crypto-config-test/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/bc3d0a927a1a6d9d46cf273be11242eaa45141e2e7aa8492b7c0116257079588_sk",
          "cert": "network/fabric/simple/crypto-config-test/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem"
        },
        "peer1": {
          "requests": "grpcs://10.254.207.154:7051",
          "events": "grpcs://10.254.207.154:7053",
          "server-hostname": "peer0.org2.example.com",
          "tls_cacerts": "network/fabric/simple/crypto-config-test/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
        }
      }
    },
    "channel": [
      {
        "name": "mychannel",
        "config": "network/fabric/simple/mychannel.tx",
    "deployed": true,
        "organizations": ["org1", "org2"]
      }
    ],
    "chaincodes": [{"id": "simple11", "path": "contract/fabric/simple/go", "language":"golang", "version": "v2", "channel": "mychannel","deployed": true}],
    "endorsement-policy": {
      "identities": [
        {
          "role": {
            "name": "member",
            "mspId": "Org1MSP"
          }
        },
        {
          "role": {
            "name": "member",
            "mspId": "Org2MSP"
          }
        },
        {
          "role": {
            "name": "admin",
            "mspId": "Org1MSP"
          }
        }
      ],
      "policy": { "2-of": [{"signed-by": 0},{"signed-by": 1}]}
    },
    "context": {
      "open": "mychannel",
      "query": "mychannel"
    }
  },
  "info" : {
    "Version": "1.1.0",
    "Size": "3 Peers",
    "Orderer": "Kafka",
    "Distribution": "Multi Hosts"
  }
}

注:配置文件中关于fabric的msp等文件需要生成好以后复制到对应的地点。

执行测试

node ./benchmark/simple/main.js -c ./config-test.json -n ./fabric-test.json
image.png

注:上图为测试流程,部分日志是本人调试所添加代码产生。

生成报告

image.png

遇到的问题

安装问题:

  • error: [join-channel.js]: Failed to join peers, TypeError: Cannot read property 'getConnectivityState' of undefined
    问题: grpc的版本错误 必须v.1.10.1
  • info: [bench-flow.js]: #######Caliper Test######
    (node:25548) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
    问题:nodejs的版本要是8.x(不能太低也不能太高)

执行问题

  • error: [Peer.js]: sendProposal - timed out after:120000
    问题:超时时间设置过短。 src/fabric/e2eUtils.js里调整超时时间
  • channel已存在要设置:


    image.png
  • 由于是已经启动好的链码,如果已经安装上chaincode再次测试会报错,需要调整代码。可以看Pr162的解决办法,在区块链网络配置中chaincodes项加deployed参数,并且在src/fabric/install-chaincode.js文件以及src/fabric/instantiate-chaincode.js文件中加入相应的处理逻辑:
    https://github.com/hyperledger/caliper/pull/162
    具体:在安装初始化之前chaincodes的deployed为false:
    "chaincodes": [{"id": "simple11", "path": "contract/fabric/simple/go", "language":"golang", "version": "v2", "channel": "mychannel","deployed": false}],

安装成功后再执行的时候 chaincodes的deployed为true

 "chaincodes": [{"id": "simple11", "path": "contract/fabric/simple/go", "language":"golang", "version": "v2", "channel": "mychannel","deployed": true}],

其他问题可以在https://github.com/hyperledger/caliper/issues 查找

fabric性能影响的要素

  • 交易复杂度
  • solo/kafka
  • 出块时间&&出块交易个数
  • leveldb/couchdb
  • 机器cpu、内存资源
  • 网络拓扑部署情况
  • ...
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,837评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,551评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,417评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,448评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,524评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,554评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,569评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,316评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,766评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,077评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,240评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,912评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,560评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,176评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,425评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,114评论 2 366
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,114评论 2 352

推荐阅读更多精彩内容