Facebook Thrift
Facebook Thrift
Facebook Thrift
CONTENTS
THRIFT FACEBOOK THRIFT GOALS TYPES OF THRIFT VERSIONING TRANSPORT IMPLEMENTATION OF TRANSPORT IN THRIFT TARGET LANGUAGES IN THRIFT IMPLEMENTATION FACEBOOK SERVICES WITH THRIFT THRIFT USAGES
FACEBOOK THRIFT
THRIFT
Thrift -software library Origin To expedite development and implementation of scalable and efficient backend services. The primary goal of thrift - communication across programming languages It abstracts the portions of each language that tend to require the most customization into a common library that is implemented in each language.
FACEBOOK THRIFT
FACEBOOK THRIFT
Evolution of Thrift- A new direction was required to
tackle the resource demands problems for many of Facebook's on-site applications.
Some couldnt be addressed by staying within the LAMP framework.
FACEBOOK THRIFT
GOALS
FACEBOOK THRIFT
LAMP
TYPES OF THRIFT
BASE TYPES
CONTAINERS
FACEBOOK THRIFT
BASE TYPES
The type system rests upon a few base types. 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
FACEBOOK THRIFT
CONTAINERS IN THRIFT
Stores collection of other objects(elements).
They are annotated using the C++ template.
There are three types available: list<type> An ordered list of elements. set<type> An unordered set of unique elements map<type1,type2> A map of strictly unique keys to values.
FACEBOOK THRIFT
VERSIONING
Datatypes
10
ISSET
Determine if a variable is set and is not null.
This is implemented via an inner isset structure inside the defined objects.
When a reader receives a struct, it should
FACEBOOK THRIFT
11
FIELD IDENTIFIERS
Versioning in Thrift is implemented via field
identifiers. The field header for every member of a struct in Thrift is encoded with a unique field identifier. The combination of this field identifier and it type specifier is used to uniquely identify the field.
FACEBOOK THRIFT
12
FIELD IDENTIFIERS
The Thrift definition language supports automatic
assignment of field identifiers. Good programming practice-always explicitly specify field identifiers.
Identifiers are specified as follows: struct Example { 1:i32 number=10, 2:i64 bigNumber, 3:double decimals, 4:string name="thrifty" }
FACEBOOK THRIFT
13
TRANSPORT
The generated Thrift code only needs to
know how to read and write data. The origin and destination of the data are irrelevant. It may be a socket, a segment of shared memory, or a file on the local disk.
FACEBOOK THRIFT
14
TRANSPORT
The Thrift transport interface supports the following methods:
open - Opens the transport
15
IMPLEMENTATION OF TRANSPORT
The transport interface is designed for simple
implementation in any programming language. New transport mechanisms can be easily defined as needed by application developers.
TYPES:
1.TFILE TRANSPORT It can be used to write out a set of incoming Thrift requests to a file on disk. 2.UTILITIES Utilities include the TBufferedTransport, which buffers the writes and reads on an underlying transport.
FACEBOOK THRIFT
16
FACEBOOK THRIFT
17
FACEBOOK SERVICES
Thrift has been employed in a large number of applications at Facebook. The two specific usages are: 1.SEARCH 2.LOGGING
FACEBOOK THRIFT
18
SEARCH
Multi-language code generation Well suited for search Allows for application development in an
efficient server side language (C++) and allows the Facebook PHP-based web application. Make calls to the search service using Thrift PHP libraries.
FACEBOOK THRIFT
19
SEARCH
FACEBOOK THRIFT
20
LOGGING
The Thrift TFile Transport functionality is used
purposes,
processing.
including
inline
and
offline
FACEBOOK THRIFT
21
FACEBOOK THRIFT
22
THRIFT EXTENSABILITY
Thrift has been added to Apache Software Foundation as the Apache Thrift Project , making it open source framework for crosslanguage service implementation.
FACEBOOK THRIFT
23
FACEBOOK THRIFT
24
CONCLUSION
Thrift has enabled Facebook to build scalable
backend services efficiently by enabling engineers to divide and conquer. Thrift has been employed in a wide variety of applications at Facebook, including search, logging, mobile, ads, and the developer platform.
FACEBOOK THRIFT
25
REFERENCES
A. Acquisti. Privacy in electronic commerce and the economics of immediate gratification. In Proceedings of the ACM Conference on
Electronic Commerce (EC 04). Thrift: Scalable Cross-Language Services Implementation, Mark Slee, Aditya Agarwal and Marc Kwiatkowski, Facebook, Palo Alto, CA Kempf, William, Boost.Threads, http://www.boost.org/doc/html/threads.html Henkel, Philipp, thread pool, http://threadpool.sourceforge.net
FACEBOOK THRIFT
26
FACEBOOK THRIFT
27
FACEBOOK THRIFT
28