Thursday, September 15, 2011

Apache Thrift

Using Facebook all the time nowadays? Have you ever wondered how this user friendly yet innovative site has been made ? Do they use Java, C++ or Python for coding purpose?
The answer is - “Thrift”, now called “Apache Thrift”.
From its home page:
Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between multiple programming languages.
So it basically allows us to write a code and then implement it in various other languages. Thrift has been written in C++ and it supports the following languages.
Objective C/Cocoa


How Thrift works

1. We write files with .thrift extension in which we declare data (such as objects and procedure) which are to be passed between applications running on different languages.
2. Then we build the .thrift files for the language of our choice. For example, server side programming can be done with Java and client side programming using PHP.
3. Then create server and client side applications using the code generated above. Then the client should call for a procedure which has been implemented in the server side code and declared in thrift files.
4. At last you need to start the server and use client scripts to perform the actions.

Thinking where to use Thrift?

Thrift can be used when your application relies on the client-server model. Also if you believe(as Facebook did), that some applications run better on some languages and you cannot to stick to one language for all your purpose.
Best of all, Thrift has been presented to open source community in April 2007 and entered the Apache Incubator in May, 2008. So now you can implement this on your server application.
It is possible to install Thrift on both Linux (CentOS and Ubuntu) and Windows. It can be downloaded from here. Though fairly simple to install, there are few GOTCHAS you need to be careful with while installing.
Want to know more on it this ? Read the white paper here and for all the coders out there, here is a reference site.
With more and more sites growing on Thrift, its future is very bright indeed.