2

I have some experience writing TCP socket servers using OpenSSL and I'm looking to understand more about Apache Thrift. I've looked over some basic examples of Thrift servers, and I understand that Thrift can handle pipes.

Can someone provide a simple explanation of the ways a Thrift server differs from a TCP server (apart from the use of pipes)? And do Thrift frameworks use a different transport protocol?

I know this is a straightforward question, but I can't seem to find a beginner level explanation.

JensG
  • 12,102
  • 4
  • 40
  • 51
Babra Cunningham
  • 2,691
  • 1
  • 17
  • 44
  • Possible duplicate of [What is RPC framework and Apache Thrift?](http://stackoverflow.com/questions/20653240/what-is-rpc-framework-and-apache-thrift) – JensG Jan 10 '17 at 09:37

2 Answers2

3

[...] ways a Thrift server differs from a TCP Server?

Thrift is at least one abstraction layer above raw sockets. It provides you with an abstraction which allows you to send and receive information across any medium, one of which could be TCP sockets.

The underlying transport medium itself is not important, nor is the protocol used (binary, compact, JSON ... you name it). Both is entirely transparent to the rest of your application.

In other words, you develop against a type-safe service API, rather than programming sockets or parse some JSON on your own.

Instead of fiddling around with bytes, encodings and fighting the subtleties of sockets, Thrift allows you to focus on what you want to do with that Service as a client and/or implementing the server-side logic.

Plus you may change transport and/or protocol as needed without affecting the rest of the code.

JensG
  • 12,102
  • 4
  • 40
  • 51
1
  1. Thrift protocol is s higher level implementation over the TCP transport layer. It provides important elements:

    • serialization
    • RPC protocol
  2. From my personal point of view, among the main benefits is type safety, especially between different languages. Manually writing TCP (socket) solutions for sophisticated case seems quite hard.

Because it is generated from a formal definition (IDL - *.thrift files, sometimes this form is called schema) it shares similarities with WSDL/SOAP, but boasts higher performance. I use it on mobile clients etc.

The most trendy last years is JSON over REST, as far I know most code should be written manually. JSON doesn't have a schema (in official standards), maybe in the future.

Acronyms I have used are generally known. My answer is very general and simplified, professionals please forgive me.

Edd
  • 1,230
  • 10
  • 14
Jacek Cz
  • 1,799
  • 1
  • 13
  • 22