Apache Thrift和谷歌的协议缓冲区最大的优点和缺点是什么?
当前回答
这里有一些很好的观点,我要再补充一个,以防有人在这里遇到。
Thrift gives you an option to choose between thrift-binary and thrift-compact (de)serializer, thrift-binary will have an excellent performance but bigger packet size, while thrift-compact will give you good compression but needs more processing power. This is handy because you can always switch between these two modes as easily as changing a line of code (heck, even make it configurable). So if you are not sure how much your application should be optimized for packet size or in processing power, thrift can be an interesting choice.
PS:请看thekvs的这个优秀的基准测试项目,它比较了许多序列化器,包括thrift-binary, thrift-compact和protobuf: https://github.com/thekvs/cpp-serializers
PS:有另一个名为YAS的序列化器也提供了这个选项,但它是无模式的,参见上面的链接。
其他回答
另一个重要的区别是默认支持的语言。
协议缓冲区: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
两者都可以扩展到其他平台,但这些都是现成的语言绑定。
这里有一些很好的观点,我要再补充一个,以防有人在这里遇到。
Thrift gives you an option to choose between thrift-binary and thrift-compact (de)serializer, thrift-binary will have an excellent performance but bigger packet size, while thrift-compact will give you good compression but needs more processing power. This is handy because you can always switch between these two modes as easily as changing a line of code (heck, even make it configurable). So if you are not sure how much your application should be optimized for packet size or in processing power, thrift can be an interesting choice.
PS:请看thekvs的这个优秀的基准测试项目,它比较了许多序列化器,包括thrift-binary, thrift-compact和protobuf: https://github.com/thekvs/cpp-serializers
PS:有另一个名为YAS的序列化器也提供了这个选项,但它是无模式的,参见上面的链接。
根据维基百科的说法,Thrift运行时不能在Windows上运行。
ProtocolBuffers是fast。 这里有一个很好的基准: https://github.com/eishay/jvm-serializers/wiki(最后一次更新是2016年,但到2020年,已经有包含更快序列化器的fork,例如ActiveJ创建了一个fork来演示它们在JVM上的速度:https://github.com/activej/jvm-serializers)。
你可能还想看看Avro,它速度更快。在。net中有两个用于Avro的库:
Apache。Avro 空空的。由供应链物流公司C.H. Robinson的工程师编写
顺便说一下,我见过最快的是captain 'nProto; c#实现可以在Marc Gravell的Github-repository中找到。
与python上的protobuff相比,我能够使用基于文本的协议获得更好的性能。然而,没有类型检查或其他花哨的utf8转换等…这是protobuff提供的。
因此,如果序列化/反序列化是您所需要的,那么您可能可以使用其他方法。
http://dhruvbird.blogspot.com/2010/05/protocol-buffers-vs-http.html