Thrift 与 protocol buffers 的比较

hrift vs Protocol Bufffers 

-----------------

 

 

Google recently released its Protocol Buffers as open source. About a year ago, Facebook released a similar product called Thrift . I’ve been comparing them; here’s what I’ve found:

The Comparison

 ThriftProtobuf
Language BindingsJava, C++, Python, C#, Cocoa, Erlang, Haskell, OCaml, Perl, PHP, Ruby, SmalltalkJava, C++, Python
Primitive Typesbool, byte, 16/32/64-bit integers, double, string, byte sequence, map<t1,t2>, list<t>, set<t>bool, 32/64-bit integers, float, double, string, byte sequence, “repeated” properties act like lists
EnumerationsYesYes
ConstantsYesNo
Composite TypeStructMessage
Exception HandlingYesNo
DocumentationLackingGood
LicenseApacheBSD-style
CompilerC++C++
RPC InterfacesYesYes
RPC ImplementationYesNo
Composite Type ExtensionsNoYes
Data VersioningYesYes
Pros- More languages supported out of the box
- Richer data structures than Protobuf (e.g.: Map and Set)
- Includes RPC implementation for services
- Slightly faster than Thrift when using “optimize_for = SPEED”
- Serialized objects slightly smaller than Thrift due to more aggressive data compression
- Better documentation
- API a bit cleaner than Thrift
Cons- Good examples are hard to find 
- Missing/incomplete documentation
- .proto can define services, but no RPC implementation is defined (although stubs are generated for you).

 

Much of this table was originally compiled by Stuart Sierra but has been edited to include additional information relevant to my own requirements.

Thrift and Protocol Buffers are both great choices and there seems like no clear winner between them. Since they seem to have more in common than they do in conflict, it really comes down to real-world application-specific needs.

I’d choose Protocol Buffers over Thrift if:

  • You’re only using Java, C++ or Python. Experimental support for other languages is being developed by third parties but are generally not considered ready for production use
  • You already have an RPC implementation
  • On-the-wire data size is crucial
  • The lack of any real documentation is scary to you

I’d choose Thrift over Protocol Buffers if:

  • Your language requirements are anything but Java, C++ or Python. See above.
  • You need additional data structures like Map and Set
  • You want a full client/server RPC implementation built-in
  • You’re a Rock Star programmer that doesn’t need documentation or examples
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值