Facebook Thrift

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

FACEBOOK THRIFT

SHRUTHI MOHANAN TE-IT ROLL NO:43142


GUIDE: PROF.SHUCHI GUPTA
FACEBOOK THRIFT
1

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.

LAMP is the acronym for Linux, MySQL, Apache and PHP.

FACEBOOK THRIFT

GOALS

Transparent Interaction between multiple programming languages.


Maintain Right balance between
Performance Ease and speed of development Availability of existing libraries

FACEBOOK THRIFT

LAMP

ENABLE TRANSPARENT INTERACTION BETWEEN THESE


FACEBOOK THRIFT

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

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

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

check for a field being set before operating directly on it.

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

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

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

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

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

for structured logging.


This log can then be used for a variety of

purposes,
processing.

including

inline

and

offline

FACEBOOK THRIFT

21

LOGGING PAGE OF FACEBOOK

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

APACHE THRIFT ARCHITECTURE

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

You might also like