EOS 测试方案分析

in #cn-programming5 years ago (edited)


EOS “官方” 给出过两次测试结论,一次是 BM 在自己博客上宣布的,另一次是 @spoonincode 在 github 上公布的。 

BM 是在自己的 macbook 上粗略的测的,没有给出太多细节。@spoonincode 后来给出的更详细的测试方案,这个方案也被一些 eos bp 的团队拿去重复试验过,可以算得上是官方证实的测试方案和测试结果了。   

@spoonincode 的测试方案大概是这样的:   单台物理机上起两个节点,一个负责出块,一个负责产生交易,产生交易是使用了一个 txn_test_gen_plugin 这个插件,查看这个插件的源码可以知道,其产生的交易是最简单的转账交易。   

这里有一点需要说明,就是为什么要再开一个节点用插件生成交易,而不是还原更真实的使用场景用 websocket 客户端生成交易并请求节点?原因就是通过 websocket 的话会带来很大的网络开销,节点的主要职责是执行,验证交易信息并出块,而不是提供一个高性能的网络服务。走 websocket 的话要做 1000 tps 的压测节点就需要节点每秒接收并处理 1000 条网络消息,这会影响对节点本身性能的测试。  

而通过另一个节点的插件生成交易的话,这些交易实际上会走 p2p 通道批量传给出块节点的 (事实上我没有严格考证是不是 “批量”,但这种方式得开销肯定是可以忽略的)。在 txn_test_gen_plugin 插件的 README.md 里以及这个插件的作者 @spoonincode 也说了, 插件的目的是要降低 eosio 节点的负荷:   

This plugin provides a way to generate a given amount of transactions per second against the currency contract. It runs internally to eosd to reduce overhead.
来自 <https://github.com/EOSIO/eos/tree/master/plugins/txn_test_gen_plugin

以及

txn_test_gen_plugin is a plugin that can generate test transactions at a configurable rate in transactions/sec. Since the transactions are generated internal to eosd, there is very little overhead compared to generating the transactions via eosc or other RPC mechanisms. This current implementation is a little rough; only having a rather coarse adjustment for transactions/sec and limiting it to a maximum of 400.
来自 <https://github.com/EOSIO/eos/pull/814


另外可以看出这个方案实际上测的是单节点性能,因为产生交易的节点在这里的作用就只是产生交易,本身是不负责出块的。