When I first read about the facebook platform last week I have to admit I wasn’t all that excited. Sure it’s great to see facebook open its doors to 3rd parties, but I’m not itching to code the next social slideshow widget. What’s got got me all fired up however, is something else facebook launched a couple of months ago which largely went unnoticed, called Thrift. It’s what they built their platform with.
Thrift is essentially a framework for building web services that can be accessed by most languages. It’s similar to CORBA in that you define a interface file and thrift will generate stubs implementing that interface in any of it’s supported languages.
- C++
- PHP
- Python
- Java
- Ruby
- And recently Perl (thanks to us)
Once you have these stubs you can build the service backend in the above language of your choice and access it from any of the other languages.
This brings us to rule #1 of programming. Knowing when to use the right tool for the right job.
You would (hopefully) never write a web frontend layer in c++ when php was built specifically for that purpose. You would also (hopefully) never build a search engine backend in php since it will be difficult to maximize performance while minimizing memory and cpu time.
So with thrift you can build the search engine in c++ and access it via php (which is what facebook does).
The default transport mechanism is a compact binary format but its fully extensible to any format (xml,json).
But thats just the beginning. You can do some really cool things with Thrift, like log all messages to file and play them back (instant redo logs). Version your data structures so you can still keep backwards compatibility with older stored data.
Thrift comes with some top notch c++ code to quickly build scalable backend c++ services. We are using thrift today as the search backend for junkdepot.com.
I hope to start a series of artcles on how to use Thrift as an alternative to standard LAMP. I really think thrift will become the backbone of next generation web services. We also will be releasing some of the services we’ve built with thrift as open source projects soon.
Feel free to ask questions.
-Jake
jake TR Site, coding, facebook, thrift