CITA 链经过性能测试后,节点/浏览器有一些问题

首先CITA链的性能真的很棒!

在4核8G内存的机器上,2个共识节点构成的CITA测试网,能跑出3.6万笔转账交易,每个区块。然后存证交易也有 1.6 万笔,而且存证交易感觉还可以堆上去,因为转账交易的压测已经让一个节点有点问题了,因此运行存证交易时只有往一个端口压数据。具体后面会说。

测试工具是自己用Rust实现的,使用cita-cli工具里面的cita-tool模块。通过一次组装一万笔交易,然后统一发送上链。起了两个进程分别向两个节点的RPC内网端口发送交易。

刚开始时每个区块最多800笔交易,而且两个节点的CPU都红了,原因是过多的RPC查询:
构造交易时重复性的和RPC端口交互拿 chain_id, current_height,version 等链上参数。这样不仅给节点很多压力,benchmark测试程序也需要一直等待RPC Response。提前设置好了就没事了。最后能轻松实现上万笔交易的打包构造上链。

但是不好的消息是压测之后出现了一些异常:

  1. 有个节点的rpc接口有问题,一笔一笔发就还ok,一旦用 ab 程序去测试,就导致这边压测程序从rpc那里拿不到数据,unwrap() 报错。然后就一直报错。
  2. 浏览器有问题,浏览器从 rebirth拿数据,rebirth接口什么的正常,浏览器主页也能看到一些数据,但是浏览器有时会报错network error,有时加载要很久了。而且有些列表,比如区块列表,交易列表,加载不出来。还要区块搜索也有问题。但是一查节点服务,两个节点,./bin/cita top xxx/0 之类的都正常,有7个服务。节点出块也正常。
  3. 运行压力测试之前,CPU占用基本为5%附近,测试时90+%,测试后那个正常的节点CPU退回到5%了,但是异常节点一直维持在30%附近。从服务器上top查看主要是cita-chain占用了CPU
1赞

过了一夜恢复正常了,CPU占用也降下来了。

做性能测试需要有很强的环境要求。问一下,你的测试是怎么部署的?
测试程序本身、浏览器 & rebirth 都部署在哪里?最好不要与 CITA 节点部在一起,因为压测的时候,这些程序也会消耗大量的资源。

是的,通过rpc查询会消耗大量的资源。我们自己的压测程序也都是把能固定下来的参数都固定下来。压测过程中尽量不去访问rpc,事后再去统计tps。

  1. 你说的unwrap() 报错是你的压测工具报错吗?如果是以性能摸底为目的的压测,建议的方法是逐渐增加并发数的方式去摸索性能上限在哪里?同时要观察下发交易接口返回的时延。因为cita是微服务架构的,中间有服务间的调用,所以时延是30ms起步的。并发数增加之后,时延还会进一步延长。可能要看一下是cpu先满,还是时延先长到不可接受。不要一上来就疯狂发交易,任何系统压力超过一个临界值之后都会雪崩,就变可靠性测试了。
  2. rebirth也是通过jsonrpc拿数据的。jsonrpc的读性能确实不高,尤其是压测之后,块里面有大量交易的时候,是会比较费劲。可以像 @leeyr 的建议一样,单独弄一个只读节点,跟rebirth一起部署在另外的机器上,会好一点。
  3. 这个应该就是前面说的压的太狠,雪崩了。这个时候chain的日志有什么异常情况吗?方便的话,可以把日志贴一下。 @UDLD 我们可以尝试复现一下。

测试程序在另外新启动的服务器,4核16G,通过内网直接连到节点1337/1338rpc端口(启了两个压测程序)。

浏览器&rebirth确实就部署在某个节点上。

嗯,因为我的方法是先实现简单的web服务器,在web服务器里面打包一万笔交易上链。然后用ab来测试web服务器的端口。这样ab访问端口一次,就至少需要rpc拿一次当前块高,这个结果的有时间拿不到。

这个我可以接下来尝试一下,对于测试目前还没有很多的概念。目前还只是开始吧,后续准备做一些更细致测试,如果有一些 测试 相关的资料,期待分享。当然也期待一起做这次测试相关的。

log我可以明天贴一下,刚刚看了还挺大,几百M。

不用全贴,就贴

这段时间的一段日志就可以了,看看是否有error或者warning级别的日志。

cita-chain.log

2020-06-12 - 17:24:02 | core::libchain::chai - 1356  | INFO  - new chain status height 1725402, hash 401d121f4bb4853e7da72cbbb48b48d040910caf42ce013a06893c40bb04ea2e
2020-06-12 - 17:24:07 | core::libchain::chai - 1356  | INFO  - new chain status height 1725403, hash 92e3cdf1e2f52140e3647d34bf7e80e82b543c427fc92240973a908c53cfff23
2020-06-12 - 17:24:11 | core::libchain::chai - 1356  | INFO  - new chain status height 1725404, hash a951595c10fd2369a0650c7cde549100c4e19be50c99556fab1e4a354709845c
2020-06-12 - 17:24:16 | core::libchain::chai - 1356  | INFO  - new chain status height 1725405, hash ed38d3300fc8d1e763d22d64fd2b90e45b98f038b9081c3e9ce2792468923397
2020-06-12 - 17:24:23 | core::libchain::chai - 1356  | INFO  - new chain status height 1725406, hash ac468a12ba3541075ca054e05d661c46065ebcd392cea57e2449076bf60422c3
2020-06-12 - 17:24:27 | core::libchain::chai - 1356  | INFO  - new chain status height 1725407, hash fc8a242ff44ab2519ae9817e47cad504e4eb311698043ace938a1bd9b4c44dc7
2020-06-12 - 17:24:30 | core::libchain::chai - 1356  | INFO  - new chain status height 1725408, hash 796a64d16db25a0133f192fd30e2111cc687aa49ac7d0fb5e7cc9f8cfebe7089
2020-06-12 - 17:24:33 | core::libchain::chai - 1356  | INFO  - new chain status height 1725409, hash 30ff5041c805a4d4bd40da2ea3b19105f8d7ed3fb9d20e1e41b294a12638baa3
2020-06-12 - 17:24:36 | core::libchain::chai - 1356  | INFO  - new chain status height 1725410, hash 53d14edd9cea14e33aa88fe02ed66659dd509acac32d9caed6f2a5a6f81a90d9
2020-06-12 - 17:24:39 | core::libchain::chai - 1356  | INFO  - new chain status height 1725411, hash 91f0661a3fb939b9f020df89a6930934fd37e618f533a2126b82d5fdc6a948c7
2020-06-12 - 17:24:43 | core::libchain::chai - 1356  | INFO  - new chain status height 1725412, hash 162a119e8f591a1802bd3f18b9d0e02a7c4edeb94a38e9bdaa51077984b0ab17
2020-06-12 - 17:24:45 | core::libchain::chai - 1356  | INFO  - new chain status height 1725413, hash 21ee0160409f864fb88933d8e4387e3b4b0fef9ee2eff831fe965089ce6565cb
2020-06-12 - 17:24:48 | core::libchain::chai - 1356  | INFO  - new chain status height 1725414, hash 43fa85ae9a585e0934ad479a89ec0a9d5b6cbfd2d0702d6562592e345fa83d70
2020-06-12 - 17:24:51 | core::libchain::chai - 1356  | INFO  - new chain status height 1725415, hash 41823e0dd126a2478b39d941994c25bd3420c1cc93231c79b4af3e6080e6f4e6
2020-06-12 - 17:24:54 | core::libchain::chai - 1356  | INFO  - new chain status height 1725416, hash e774ed74bbb350f2c4b9a98a9e4beed2c92d1128a814106915e0a172952fb3dd
2020-06-12 - 17:24:57 | core::libchain::chai - 1356  | INFO  - new chain status height 1725417, hash f0e000d30b65a3919823cfa8edc6dc6491c13942d1a93dec62ef2378548d7580
2020-06-12 - 17:25:00 | core::libchain::chai - 1356  | INFO  - new chain status height 1725418, hash 2a40e8fbf828eb7a6897667140a35f9220f926814294683e2d561f1d75ecc758
2020-06-12 - 17:25:03 | core::libchain::chai - 1356  | INFO  - new chain status height 1725419, hash 2178b04335ce893d8fa33b357eab2a83c61e8ed65fd765ab836a2710e471c597
2020-06-12 - 17:25:06 | core::libchain::chai - 1356  | INFO  - new chain status height 1725420, hash 7cafe2bf83bf89d02edb7bf0a5c8d3e1d98a533cf2d9f3225fe7ef02294e2a81
2020-06-12 - 17:25:09 | core::libchain::chai - 1356  | INFO  - new chain status height 1725421, hash b7655aaa0e9506a8a4db9098b3567dbdc948eead6f87f5a50089666e0f0f4715
2020-06-12 - 17:25:12 | core::libchain::chai - 1356  | INFO  - new chain status height 1725422, hash 351a7f3f43f708c58c22a37464a8dc9c149bb94b35d4408562f8eac697a343ab
2020-06-12 - 17:25:16 | core::libchain::chai - 1356  | INFO  - new chain status height 1725423, hash d24f5759329d4a1a1761e9745b40af8c1bf5f560a3a155f65be1fd145b6f7d66
2020-06-12 - 17:25:18 | core::libchain::chai - 1356  | INFO  - new chain status height 1725424, hash 6bfbb747533daf048c2bd588904d7579b26918df7056a15b67082c4117b7ce1e
2020-06-12 - 17:25:21 | core::libchain::chai - 1356  | INFO  - new chain status height 1725425, hash f83b3f2d86618626cf8c24a25ed1ba8853f65a8ff9b89a615370e197e5045c99
2020-06-12 - 17:25:24 | core::libchain::chai - 1356  | INFO  - new chain status height 1725426, hash fcf5b2de5bcfb217e45f54353b0be57e441e86d53e6217a27efaede0e8d47aab
2020-06-12 - 17:25:27 | core::libchain::chai - 1356  | INFO  - new chain status height 1725427, hash e561eae3e16529c74fa002fb7589bebeb53a60266d09bae2e3304397ea297048
2020-06-12 - 17:25:30 | core::libchain::chai - 1356  | INFO  - new chain status height 1725428, hash a85cf16c574f2e7f1d81ca0182927fecd836f849e0b57c278693bf1e19493ace
2020-06-12 - 17:25:33 | core::libchain::chai - 1356  | INFO  - new chain status height 1725429, hash 1b39e7141d20b977e11cf29ffcb43f740f075bbaa88d9a01b9e093cff3f994bc
2020-06-12 - 17:25:36 | core::libchain::chai - 1356  | INFO  - new chain status height 1725430, hash a226938fd4b7b536a7c5cf037770cffd7b661c3c4265417a1c3db8f565c40531
2020-06-12 - 17:25:39 | core::libchain::chai - 1356  | INFO  - new chain status height 1725431, hash faf19acbbc45f59a885a8544421f6b649da9625cde22fe8c66aa45b869d5cceb
2020-06-12 - 17:25:42 | core::libchain::chai - 1356  | INFO  - new chain status height 1725432, hash f0682f7786827cc566a4a9c90ddf41f0da5095596e75e2e57cbce75a18ad95ca
2020-06-12 - 17:25:45 | core::libchain::chai - 1356  | INFO  - new chain status height 1725433, hash 67f5944b394ef66542390734df0211f3331294542b0f03530269961b235d6d48
2020-06-12 - 17:25:48 | core::libchain::chai - 1356  | INFO  - new chain status height 1725434, hash 45ef81f3fb42b3438224dacb4fd9da43495f4ff186830e46565f758ce2fb0db5
2020-06-12 - 17:25:52 | core::libchain::chai - 1356  | INFO  - new chain status height 1725435, hash 9a2f5fa2664488d7408702bc17470b58ae765a81c1b21ef5428a4da902d2df0d
2020-06-12 - 17:25:54 | core::libchain::chai - 1356  | INFO  - new chain status height 1725436, hash 667f9bc0e50015a7598db1118fdfcb922e4c6b13cdb489dbcd9c3e24a1bdda2d
2020-06-12 - 17:25:57 | core::libchain::chai - 1356  | INFO  - new chain status height 1725437, hash 0b52ca7df2881ccfbfb5c11f6a9e46bca889b090df037ca85b217a983bcdfb27
2020-06-12 - 17:26:00 | core::libchain::chai - 1356  | INFO  - new chain status height 1725438, hash 4dd424a94267f88d5e04beb0a27fa28b771bba1feb5bfebaf39fbec1cfa763ac
2020-06-12 - 17:26:03 | core::libchain::chai - 1356  | INFO  - new chain status height 1725439, hash 4f031fbc88d5821c160287b7fae8d6a456cbe95c8e240898eb060d4451603573
2020-06-12 - 17:26:06 | core::libchain::chai - 1356  | INFO  - new chain status height 1725440, hash 963b28d2b4d7db85a1dae8b1a212239d6ad57f0c42a135d8de8af3d6ab348539
2020-06-12 - 17:26:09 | core::libchain::chai - 1356  | INFO  - new chain status height 1725441, hash e76785e70e571df07d515af1282d6e6f979a174440ffde5c4231b81cdca1a804
2020-06-12 - 17:26:12 | core::libchain::chai - 1356  | INFO  - new chain status height 1725442, hash fc786de7d701a8204e15598ec1a4b0428f0aa7513fa7cc96885250deb92f985f
2020-06-12 - 17:26:15 | core::libchain::chai - 1356  | INFO  - new chain status height 1725443, hash 57b5b46977cf1569466c995cea6cb9ff83494fb7d62050578576d5b6350b8ca2
2020-06-12 - 17:26:18 | core::libchain::chai - 1356  | INFO  - new chain status height 1725444, hash 2f831f76f775d9425975eb6a08234151872cf56738c4bd501dfb32f4d0717ce9
2020-06-12 - 17:26:21 | core::libchain::chai - 1356  | INFO  - new chain status height 1725445, hash dba544466a1b5a293cc9173517645ad631077cc3b732cf6e8cd040987c3925dc
2020-06-12 - 17:26:24 | core::libchain::chai - 1356  | INFO  - new chain status height 1725446, hash 0d2c3fc238b829a68d53eeed99dde772fe8a8c827d18f8c7bc4a8ab6091e67ea
2020-06-12 - 17:26:27 | core::libchain::chai - 1356  | INFO  - new chain status height 1725447, hash 85ec27ad86102f42d53d04686a6fb51b7bd48f4ac96f445121c419d0576cef87
2020-06-12 - 17:26:30 | core::libchain::chai - 1356  | INFO  - new chain status height 1725448, hash a2caeac849a27e353a5346b5d3e79e79640ed9f1e36ad558f7186d0530aa286c
2020-06-12 - 17:26:33 | core::libchain::chai - 1356  | INFO  - new chain status height 1725449, hash 2fde248fea1424739b9b8d15b492fea8e6cff9bc610e3f704f559cda2cf3cdd2
2020-06-12 - 17:26:36 | core::libchain::chai - 1356  | INFO  - new chain status height 1725450, hash 3bc10943d75f1c7aa829669beda306826c1ce92d63860a424d89e8381112452b
2020-06-12 - 17:26:40 | core::libchain::chai - 1356  | INFO  - new chain status height 1725451, hash d5fb6f83f1c8095834746041f93aebf5a91e9027e7afe7ac6a649a0e7a82c037
2020-06-12 - 17:26:42 | core::libchain::chai - 1356  | INFO  - new chain status height 1725452, hash eb7cc4ddb639e35b62dca34f355a9ba82b2291cc08fd0b8f159c5db545dd6dd8
2020-06-12 - 17:26:45 | core::libchain::chai - 1356  | INFO  - new chain status height 1725453, hash 25d8bbeda8346a2377c4bd2855c0eede75e26f1faf5158ada176320afb71c5cd
2020-06-12 - 17:26:48 | core::libchain::chai - 1356  | INFO  - new chain status height 1725454, hash 13ff9fa7a1b5b34fb2487c8722f00772f56912188d72a3ea8c62e9ad170499ef
2020-06-12 - 17:26:51 | core::libchain::chai - 1356  | INFO  - new chain status height 1725455, hash 4eb8e1861d86109ebb164816c705f1a38b6a792ecb5f8b96d264f0e6a101d4a8
2020-06-12 - 17:26:54 | core::libchain::chai - 1356  | INFO  - new chain status height 1725456, hash 86beb0c0c15c93c8bfa50e8a20fc58dedd74329a89c622a96477c1a03e3d39e1
2020-06-12 - 17:26:57 | core::libchain::chai - 1356  | INFO  - new chain status height 1725457, hash ef5a5fa44bc01ae7fb6deb3d04f1d47ea10a5c2b056321671708416f29509bd1
2020-06-12 - 17:27:00 | core::libchain::chai - 1356  | INFO  - new chain status height 1725458, hash aa8e4c6cf85ca41555a5018fdf99219b3bc6646533a156fb9c4b95690620c375
2020-06-12 - 17:27:03 | core::libchain::chai - 1356  | INFO  - new chain status height 1725459, hash ff78391d96d49aadc96fc35b83a939e0195d9878f2d38ac63804e3634d9817e2
2020-06-12 - 17:27:06 | core::libchain::chai - 1356  | INFO  - new chain status height 1725460, hash 37f9b0e7765ac81e6b19284166792c66e2e73baf3fa34190888ba6a35512999c
2020-06-12 - 17:27:09 | core::libchain::chai - 1356  | INFO  - new chain status height 1725461, hash f966d3230a287997be6057ea5fd89653bce03701343ddefcdb6fea09da8a54f5
2020-06-12 - 17:27:12 | core::libchain::chai - 1356  | INFO  - new chain status height 1725462, hash 0404e424d72bb99e63a117c3c2c7786e58100adc58c52b0fc11f116552643580
2020-06-12 - 17:27:15 | core::libchain::chai - 1356  | INFO  - new chain status height 1725463, hash 77a0b5366ab1ecfcfd7ac37c15d483fdc8c029d4d12b52ca3f75b5131d0fa387
2020-06-12 - 17:27:18 | core::libchain::chai - 1356  | INFO  - new chain status height 1725464, hash 7fe25781c343441b55812e360e8fc0df637e46070746b56d75d80d22e12b395b
2020-06-12 - 17:27:21 | core::libchain::chai - 1356  | INFO  - new chain status height 1725465, hash 173be256761050e73362d3f9a860df79efb5b8f9564b7877bd7f3b024df2aa70

1725410-1725402 这几个里面的交易量比较大

cita-network.log:

2020-06-12 - 17:46:07 | cita_network::p2p_pr - 59    | INFO  - [Transfer] Connected sessions: [SessionId(1), SessionId(2), SessionId(3)]
2020-06-12 - 17:46:07 | cita_network::node_m - 733   | INFO  - [NodeManager] Send network init message!, id: SessionId(2), peer_addr: 0xa2d772833c1169e5c35e5f6ebabb6dabd28d5055, ret: Ok(())
2020-06-12 - 17:46:07 | cita_network::node_m - 733   | INFO  - [NodeManager] Send network init message!, id: SessionId(3), peer_addr: 0xa2d772833c1169e5c35e5f6ebabb6dabd28d5055, ret: Ok(())
2020-06-12 - 17:46:07 | cita_network::p2p_pr - 74    | INFO  - [Transfer] Disconnected proto id [ProtocolId(1)] close on session [SessionId(3)]
2020-06-12 - 17:46:07 | cita_network::p2p_pr - 74    | INFO  - [Transfer] Disconnected proto id [ProtocolId(1)] close on session [SessionId(2)]
2020-06-12 - 17:46:07 | cita_network::node_m - 904   | INFO  - [NodeManager] Disconnected session [SessionId(2)]
2020-06-12 - 17:46:07 | cita_network::node_m - 904   | INFO  - [NodeManager] Disconnected session [SessionId(3)]
2020-06-12 - 17:46:07 | cita_network::node_m - 954   | ERROR - [NodeManager] Can not get node status from known_addr, this should not happen!
2020-06-12 - 17:46:13 | cita_network::synchr - 130   | INFO  - current: 1725798, sync_end: 0, global: 1725798, sync: false
2020-06-12 - 17:46:13 | cita_network::node_m - 1022  | INFO  - DealRichStatusReq rich status hash: "\377\373\334\306\010\022C\265@\331\240z\301\002\343R\312`\350\246\226XYh\001\342\354k\273\206U\304" height: 1725798 nodes: "_K\372\035\001\320\350'\225\245\001\226\366\002\263\013K\177\201\353" nodes: "\242\327r\203<\021i\345\303^_n\272\273m\253\322\215PU" interval: 3000 version: 2 validators: "\242\327r\203<\021i\345\303^_n\272\273m\253\322\215PU" validators: "_K\372\035\001\320\350'\225\245\001\226\366\002\263\013K\177\201\353"
.
.
.
2020-06-12 - 21:40:10 | cita_network::synchr - 130   | INFO  - current: 1730342, sync_end: 0, global: 1730342, sync: false
2020-06-12 - 21:40:11 | cita_network::p2p_pr - 138   | INFO  - [P2pProtocol] Service open on : V4(185.202.2.149:62576), session id: SessionId(5), ty: Inbound, public_key: None
2020-06-12 - 21:40:11 | tentacle::session    - 660   | WARN  - MuxerError: Custom { kind: InvalidData, error: "yamux.version=3" }
2020-06-12 - 21:40:11 | cita_network::node_m - 884   | INFO  - [NodeManager] Session [SessionId(5)], address: V4(185.202.2.149:62576) pending to add to Connected_addrs.
2020-06-12 - 21:40:11 | cita_network::p2p_pr - 113   | WARN  - [P2pProtocol] ServiceError::MuxerError Sessionid SessionId(5)--IoError(Custom { kind: InvalidData, error: "yamux.version=3" })
2020-06-12 - 21:40:11 | cita_network::node_m - 904   | INFO  - [NodeManager] Disconnected session [SessionId(5)]
2020-06-12 - 21:40:13 | cita_network::synchr - 130   | INFO  - current: 1730343, sync_end: 0, global: 1730343, sync: false
2020-06-12 - 21:40:13 | cita_network::node_m - 1022  | INFO  - DealRichStatusReq rich status hash: "\262\271\202\214pO\221;S\"\333\013\246\002E\231\216JC \365\2502D\242\340\3119K_\274\277" height: 1730343 nodes: "_K\372\035\001\320\350'\225\245\001\226\366\002\263\013K\177\201\353" nodes: "\242\327r\203<\021i\345\303^_n\272\273m\253\322\215PU" interval: 3000 version: 2 validators: "\242\327r\203<\021i\345\303^_n\272\273m\253\322\215PU" validators: "_K\372\035\001\320\350'\225\245\001\226\366\002\263\013K\177\201\353"

这个日志看起来挺正常的,没什么问题。
压测之后chain的cpu占用率还持续了一段时间,有可能是rocksdb在compact数据。

下面网络这个报错倒是挺奇怪的。
应该是收到了一些非法的数据。
不知道是不是你们的网络端口是否跟其他的服务有冲突,导致别的应用的数据发到这边来了?