Apache Thrift和谷歌的协议缓冲区最大的优点和缺点是什么?


当前回答

与python上的protobuff相比,我能够使用基于文本的协议获得更好的性能。然而,没有类型检查或其他花哨的utf8转换等…这是protobuff提供的。

因此,如果序列化/反序列化是您所需要的,那么您可能可以使用其他方法。

http://dhruvbird.blogspot.com/2010/05/protocol-buffers-vs-http.html

其他回答

另一个重要的区别是默认支持的语言。

协议缓冲区:Java, Android Java, c++, Python, Ruby, c#, Go, Objective-C, Node.js 节俭:Java、c++、Python、Ruby、c#、Go、Objective-C、JavaScript、Node.js、Erlang、PHP、Perl、Haskell、Smalltalk、OCaml、Delphi、D、Haxe

两者都可以扩展到其他平台,但这些都是现成的语言绑定。

一个尚未提到的明显的事情是,它们既可以是赞成的,也可以是反对的(两者都是一样的),它们是二进制协议。这允许更紧凑的表示和可能更好的性能(优点),但降低了可读性(或更确切地说,可调试性),这是一个缺点。

此外,两者对工具的支持都比xml(甚至json)等标准格式少一些。

(编辑)这里有一个有趣的比较,解决了大小和性能的差异,并包括一些其他格式(xml, json)的数字。

RPC是另一个关键区别。Thrift生成代码来实现RPC客户机和服务器,其中协议缓冲区似乎主要被设计为单独的数据交换格式。

同样重要的是要注意,并非所有受支持的语言都与thrift或protobuf一致。在这一点上,除了底层序列化之外,还涉及到模块实现的问题。注意检查您计划使用的语言的基准。

正如我在“节俭vs协议缓冲区”主题中所说:

参考Thrift vs Protobuf vs JSON的比较:

Thrift supports out of the box AS3, C++, C#, D, Delphi, Go, Graphviz, Haxe, Haskell, Java, Javascript, Node.js, OCaml, Smalltalk, Typescript, Perl, PHP, Python, Ruby, ... C++, Python, Java - in-box support in Protobuf Protobuf support for other languages (including Lua, Matlab, Ruby, Perl, R, Php, OCaml, Mercury, Erlang, Go, D, Lisp) is available as Third Party Addons (btw. Here is SWI-Prolog support). Protobuf has much better documentation and plenty of examples. Thrift comes with a good tutorial Protobuf objects are smaller Protobuf is faster when using "optimize_for = SPEED" configuration Thrift has integrated RPC implementation, while for Protobuf RPC solutions are separated, but available (like Zeroc ICE ). Protobuf is released under BSD-style license Thrift is released under Apache 2 license

此外,对于这些解决方案,还有许多有趣的附加工具可用,这可能会决定。以下是Protobuf的示例:Protobuf-wireshark, protobufeditor。