我知道 StackOverflow 上有几篇关于 HBase 的 REST 和 Thrift 的帖子,但我想稍微关注一下性能问题。
我一直在使用 Node.js 中的以下库来连接到 HBase 实例:
- Node -hbase:https://github.com/wdavidw/node-hbase
- Node 节俭:https://github.com/apache/thrift/tree/trunk/lib/nodejs
在弄清楚为什么我无法从 Thrift 网关获得响应的一些麻烦之后,我终于让两个脚本都运行了,结果如下(每个输出相当于完成了 1000 个操作):
┌─[mt@Marcs-MacBook-Pro]─[~/Sources/node-hbase]
└──╼ node hbase.js
hbase-write: 99ms
hbase-write: 3412ms
hbase-write: 3854ms
hbase-write: 3924ms
hbase-write: 3808ms
hbase-write: 9035ms
hbase-read: 216ms
hbase-read: 4676ms
hbase-read: 3908ms
hbase-read: 3498ms
hbase-read: 4139ms
hbase-read: 3781ms
completed
┌─[mt@Marcs-MacBook-Pro]─[~/Sources/node-hbase]
└──╼ node thrift.js
hbase-write: 4ms
hbase-write: 931ms
hbase-write: 1061ms
hbase-write: 988ms
hbase-write: 839ms
hbase-write: 807ms
hbase-read: 2ms
hbase-read: 435ms
hbase-read: 562ms
hbase-read: 414ms
hbase-read: 427ms
hbase-read: 423ms
completed
┌─[mt@Marcs-MacBook-Pro]─[~/Sources/node-hbase]
└──╼
使用的脚本可以在这里找到:https://github.com/stelcheck/node-hbase-vs-thrift
我的问题是,有没有人注意到 REST 和 Thrift 对于 HBase(或者甚至只是一般来说对于任何应用程序/语言)之间的巨大差异?
最佳答案
REST 以 XML 或 JSON 的形式提供,因此模式存在于数据本身中。 Thrift 不这样做:它只是一个字节负载,然后只能针对生成的实体进行反序列化(基于 thrift IDL 定义)。
因此,无论数据如何压缩,thrift 肯定会更快,因为它不携带任何架构,其“代价”是依赖其他对象来解释二进制数据。
关于node.js - HBase:Thrift vs Rest 性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732082/