Facebook Thrift
Facebook Thrift
Thrift is a software library and a set of code generation tool which was developed at the Facebook Office at Palo Alto, California, to expedite development and implementation of scalable and efficient backend services. The primary goal of thrift is enable efficient and reliable communication across programming languages by abstracting the portions of each language that tend to require the most customization into a common library that is implemented in each language. This is done by allowing the users to define the data types and service interfaces in a common Interface Definition Logic File (IDL File) which is supposed to be language neutral file and it generates all the necessary code to build Remote Procedure Calls to clients and servers. This report explains the design choices and implementation level details and also tries to demonstrate a sample Thrift Service.
The whole concept of Thrift stemmed out from the fact that a new direction was required to tackle the resource demands problems for many of Facebook's on-site applications, which couldn?t be addressed by staying within the LAMP framework. LAMP is the acronym for Linux, MySQL, Apache and PHP. When Facebook was being laboriously designed, it was done from ground up using this LAMP framework. By 2006 Facebook was widely accepted all over the world as the social networking site and consequently its network traffic also grew giving rise to the need for scaling its network structure for many of its onsite applications like, search, ad selection and delivery and event logging.
Base Types
The type system rests upon a few base types. In considering which types to support, we aimed for clarity and simplicity over abun-dance, focusing on the key types available in all programming lan-guages, ommitting any niche types available only in specific lan-guages.
The base types supported by Thrift are:
bool A boolean value, true or false byte A signed byte
i16 A 16-bit signed integer i32 A 32-bit signed integer i64 A 64-bit signed integer
double A 64-bit floating point number
string An encoding-agnostic text or binary string
Of particular note is the absence of unsigned integer types. Because these types have no direct translation to native types in many languages, the advantages they afford are lost. Further, there is no way to prevent the application developer in a language like Python from assigning a negative value to an integer variable, leading to unpredictable behavior. From a design standpoint, we observed that unsigned integers were very rarely, if ever, used for arithmetic purposes, but in practice were much
more often used as keys or identifiers. In this case the sign is irrelevant. Signed integers serve this same purpose and can be safely cast to their unsigned counterparts (commonly in C++) when absolutely necessary.
Comments
Post a Comment