實(shí)戰(zhàn)Caliper測(cè)試多機(jī)Fabric環(huán)境

成功跑完caliper自帶例子之后,本人嘗試使用caliper來(lái)測(cè)試自己部署的多機(jī)fabric環(huán)境。

被測(cè)fabric網(wǎng)絡(luò)拓?fù)?/h1>

1orderer劫樟、3peer吗垮、kafka共識(shí)垛吗、無(wú)ca、native啟動(dòng)(非docker)烁登。

IP 節(jié)點(diǎn) 域名
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 無(wú)需

Caliper配置文件

基準(zhǔn)測(cè)試配置

{
  "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
  }
}

區(qū)塊鏈網(wǎng)絡(luò)配置

{
  "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"
  }
}

注:配置文件中關(guān)于fabric的msp等文件需要生成好以后復(fù)制到對(duì)應(yīng)的地點(diǎn)怯屉。

執(zhí)行測(cè)試

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

注:上圖為測(cè)試流程,部分日志是本人調(diào)試所添加代碼產(chǎn)生饵沧。

生成報(bào)告

image.png

遇到的問(wèn)題

安裝問(wèn)題:

  • error: [join-channel.js]: Failed to join peers, TypeError: Cannot read property 'getConnectivityState' of undefined
    問(wèn)題: grpc的版本錯(cuò)誤 必須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
    問(wèn)題:nodejs的版本要是8.x(不能太低也不能太高)

執(zhí)行問(wèn)題

  • error: [Peer.js]: sendProposal - timed out after:120000
    問(wèn)題:超時(shí)時(shí)間設(shè)置過(guò)短锨络。 src/fabric/e2eUtils.js里調(diào)整超時(shí)時(shí)間
  • channel已存在要設(shè)置:


    image.png
  • 由于是已經(jīng)啟動(dòng)好的鏈碼,如果已經(jīng)安裝上chaincode再次測(cè)試會(huì)報(bào)錯(cuò)狼牺,需要調(diào)整代碼羡儿。可以看Pr162的解決辦法是钥,在區(qū)塊鏈網(wǎng)絡(luò)配置中chaincodes項(xiàng)加deployed參數(shù)掠归,并且在src/fabric/install-chaincode.js文件以及src/fabric/instantiate-chaincode.js文件中加入相應(yīng)的處理邏輯:
    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}],

安裝成功后再執(zhí)行的時(shí)候 chaincodes的deployed為true

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

其他問(wèn)題可以在https://github.com/hyperledger/caliper/issues 查找

fabric性能影響的要素

  • 交易復(fù)雜度
  • solo/kafka
  • 出塊時(shí)間&&出塊交易個(gè)數(shù)
  • leveldb/couchdb
  • 機(jī)器cpu、內(nèi)存資源
  • 網(wǎng)絡(luò)拓?fù)洳渴鹎闆r
  • ...
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末悄泥,一起剝皮案震驚了整個(gè)濱河市虏冻,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌弹囚,老刑警劉巖厨相,帶你破解...
    沈念sama閱讀 217,826評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡蛮穿,警方通過(guò)查閱死者的電腦和手機(jī)庶骄,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)践磅,“玉大人瓢姻,你說(shuō)我怎么就攤上這事∫粽” “怎么了幻碱?”我有些...
    開封第一講書人閱讀 164,234評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)细溅。 經(jīng)常有香客問(wèn)我褥傍,道長(zhǎng),這世上最難降的妖魔是什么喇聊? 我笑而不...
    開封第一講書人閱讀 58,562評(píng)論 1 293
  • 正文 為了忘掉前任恍风,我火速辦了婚禮,結(jié)果婚禮上誓篱,老公的妹妹穿的比我還像新娘朋贬。我一直安慰自己,他們只是感情好窜骄,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,611評(píng)論 6 392
  • 文/花漫 我一把揭開白布锦募。 她就那樣靜靜地躺著,像睡著了一般邻遏。 火紅的嫁衣襯著肌膚如雪糠亩。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,482評(píng)論 1 302
  • 那天准验,我揣著相機(jī)與錄音赎线,去河邊找鬼。 笑死糊饱,一個(gè)胖子當(dāng)著我的面吹牛垂寥,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播另锋,決...
    沈念sama閱讀 40,271評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼滞项,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了砰蠢?” 一聲冷哼從身側(cè)響起蓖扑,我...
    開封第一講書人閱讀 39,166評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤唉铜,失蹤者是張志新(化名)和其女友劉穎台舱,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,608評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡竞惋,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,814評(píng)論 3 336
  • 正文 我和宋清朗相戀三年柜去,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片拆宛。...
    茶點(diǎn)故事閱讀 39,926評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡嗓奢,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出浑厚,到底是詐尸還是另有隱情股耽,我是刑警寧澤,帶...
    沈念sama閱讀 35,644評(píng)論 5 346
  • 正文 年R本政府宣布钳幅,位于F島的核電站物蝙,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏敢艰。R本人自食惡果不足惜诬乞,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,249評(píng)論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望钠导。 院中可真熱鬧震嫉,春花似錦、人聲如沸牡属。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)逮栅。三九已至换衬,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間证芭,已是汗流浹背瞳浦。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留废士,地道東北人叫潦。 一個(gè)月前我還...
    沈念sama閱讀 48,063評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像官硝,于是被迫代替她去往敵國(guó)和親矗蕊。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,871評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容