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

jebbthe picture jebbthe · Mar 16, 2012 · Viewed 31k times · Source

Thrift's primary goal is to enable efficient and reliable communication across programming languages. but I think HTTP-RPC can also do that, web developer almost everyone knows how to work on http and it is easier to implement HTTP-RPC(json) than Thrift,

Maybe Thrift-RPC is faster, then who can tell me the difference in perfermance between them?

Answer

Not_a_Golfer picture Not_a_Golfer · Mar 16, 2012

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 is more compact than HTTP, and can easily be extended to support things like encryption, compression, non blocking IO, etc.

  3. 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)

  4. Thrift supports persistent connections and avoids the continuous TCP and HTTP handshakes that HTTP incurs.

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:

http://www.slideshare.net/dvirsky/introduction-to-thrift

It has links to a few other alternatives to thrift.