码迷,mamicode.com
首页 > 其他好文 > 详细

为什么要用Thrift

时间:2018-03-20 22:55:57      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:div   encrypt   gpo   ref   ida   tle   code   useful   方便   

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:

 

为什么要用Thrift

标签:div   encrypt   gpo   ref   ida   tle   code   useful   方便   

原文地址:https://www.cnblogs.com/rgqancy/p/8613152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!