Facebook Thrift
-
Upload
shanysunny -
Category
Documents
-
view
318 -
download
2
Transcript of Facebook Thrift
1
FACEBOOK THRIFTSHRUTHI MOHANANTE-ITROLL NO:43142
FACEBOOK THRIFT
GUIDE: PROF.SHUCHI GUPTA
FACEBOOK THRIFT 2
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 3
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 4
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 couldn’t be addressed by staying within the LAMP framework.
LAMP is the acronym for Linux, MySQL,
Apache and PHP.
FACEBOOK THRIFT 5
GOALS Transparent Interaction between
multiple programming languages.
Maintain Right balance between Performance Ease and speed of development Availability of existing libraries
FACEBOOK THRIFT 6ENABLE TRANSPARENT INTERACTION BETWEEN THESE
LAMP
FACEBOOK THRIFT 7
BASE TYPES CONTAINERS
TYPES OF THRIFT
FACEBOOK THRIFT 8
BASE TYPESThe 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 9
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 10
VERSIONING Datatypes must be able to version
themselves without any interruption in service.
There are mainly two types of versioning used in thrift implementation, namely:
1) ISSET 2) FIELD IDENTIFIERS
FACEBOOK THRIFT 11
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 check for a field being set before operating directly on it.
FACEBOOK THRIFT 12
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 13
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 14
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 15
TRANSPORTThe Thrift transport interface supports the following
methods:
open - Opens the transport close - Closes the transport isOpen - Indicates whether the transport is open Read - Reads from the transport write -Writes to the transport flush - Forces any pending writes
FACEBOOK THRIFT 16
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 17
TARGET LANGUAGES IN THRIFT
IMPLEMENTATION Thrift currently supports five target
languages : C, C++, Java, Python, Ruby, and PHP.
The Thrift services implemented in PHP has also been embedded into Apache web server, providing the transparent backend access.
FACEBOOK THRIFT 18
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 19
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 20
SEARCH
FACEBOOK THRIFT 21
LOGGING
The Thrift TFile Transport functionality is used for structured logging.
This log can then be used for a variety of purposes, including inline and offline processing.
FACEBOOK THRIFT 22
LOGGING PAGE OF FACEBOOK
FACEBOOK THRIFT 23
THRIFT EXTENSABILITY Thrift has been added to Apache
Software Foundation as the Apache Thrift Project , making it open source framework for cross-language service implementation.
FACEBOOK THRIFT 24
APACHE THRIFT ARCHITECTURE
FACEBOOK THRIFT 25
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 26
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 27
THANK YOU!!
FACEBOOK THRIFT 28
Any Questions???