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的序列化器也提供了这个选项,但它是无模式的,参见上面的链接。
其他回答
同样重要的是要注意,并非所有受支持的语言都与thrift或protobuf一致。在这一点上,除了底层序列化之外,还涉及到模块实现的问题。注意检查您计划使用的语言的基准。
这里有一些很好的观点,我要再补充一个,以防有人在这里遇到。
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上运行。
与python上的protobuff相比,我能够使用基于文本的协议获得更好的性能。然而,没有类型检查或其他花哨的utf8转换等…这是protobuff提供的。
因此,如果序列化/反序列化是您所需要的,那么您可能可以使用其他方法。
http://dhruvbird.blogspot.com/2010/05/protocol-buffers-vs-http.html
RPC是另一个关键区别。Thrift生成代码来实现RPC客户机和服务器,其中协议缓冲区似乎主要被设计为单独的数据交换格式。
推荐文章
- 如何JSON序列化集?
- 如何将TimeSpan序列化为XML
- 如何在Intellij生成串行版本UID
- 在Go中使用JSON Marshal的小写JSON键名
- 什么是序列化?
- 我如何复制一个哈希在Ruby?
- 为什么生成较长的serialVersionUID而不是简单的1L?
- 将流转换为字符串并返回
- Parcelable遇到IOException写入序列化对象getactivity()
- 谷歌协议缓冲区vs json vs XML
- 不带空格的Python - json
- 打印对象的所有属性
- 在Swift中将字典转换为JSON
- 将类实例序列化为JSON
- 任务不可序列化:java.io.NotSerializableException,当只对类而不是对象调用闭包外部的函数时