为什么要用Thrift

Why Thrift, Why not HTTP RPC(JSON+gzip)

 https://stackoverflow.com/questions/9732381/why-thrift-why-not-http-rpcjsongzip

 

89down voteaccepted

A few reasons other than speed:

  1. Thrift generates the client and server code completely, including the data structures you are passing, so you don't have to deal with anything other than writing the handlers and invoking the client. and everything, including parameters and returns are automatically validated and parsed. so you are getting sanity checks on your data for free.

  2. Thrift生成的代码,包含传递数据的数据结构。不用费劲地写客户端处理器,参数和返回值都被自动化实现验证,你可以很方便地对你的数据做常规的检查。
  3. Thrift is more compact than HTTP, and can easily be extended to support things like encryption, compression, non blocking IO, etc.

  4. Thrift比HTTP协议更紧凑,很容易扩展去支持一些东西:加密,压缩,非阻塞的IO。
  5. Thrift can be set up to use HTTP and JSON pretty easily if you want it (say if your client is somewhere on the internet and needs to pass firewalls)

  6. Thrift能够简单设置为使用HTTP协议和JSON协议,如果你需要这么做(比如说你的客户端运行在因特网的某个地方,需要穿越防火墙)。
  7. Thrift supports persistent connections and avoids the continuous TCP and HTTP handshakes that HTTP incurs.

  8. Thrift支持持久化连接,并且能够避免并不断的TCP和HTTP握手操作,这些操作常在HTTP协议里发生。

Personally, I use thrift for internal LAN RPC and HTTP when I need connections from outside.

I hope all this makes sense to you. You can read a presentation I gave about thrift here:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值