This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article contains content that is written like an advertisement. Please help improve it by removing promotional content and inappropriate external links, and by adding encyclopedic content written from a neutral point of view. (August 2019) (Learn how and when to remove this template message) This article is written like a manual or guide. Please help rewrite this article and remove advice or instruction. (August 2019) (Learn how and when to remove this template message)
Apache Thrift
Original author(s)Facebook, Inc.
Developer(s)Apache Software Foundation
Stable release
0.19.0 / 2 September 2023; 6 months ago (2023-09-02)[1]
RepositoryThrift Repository
Written inActionScript, C, C#, C++, D, Dart, Delphi, Erlang, Go, Haskell, Haxe, Java, JavaScript, Node.js, OCaml, Perl, PHP, Python, Rust, Scala, Smalltalk
TypeRemote procedure call framework
LicenseApache 2.0

Thrift is an interface definition language and binary communication protocol[2] used for defining and creating services for programming languages.[3] It was developed by Facebook. Since 2020, it is an open source project in the Apache Software Foundation.

It uses a remote procedure call (RPC) framework and combines a software stack with a code generation engine to build cross-platform services. Ultimately, Thrift can connect applications written in a variety of languages and frameworks, including ActionScript, C, C++,[4] C#,[5] Cocoa, Delphi, Erlang, Go, Haskell, Java, JavaScript, Objective-C, OCaml, Perl, PHP, Python, Ruby, Elixir,[6] Rust, Scala, Smalltalk, and Swift.[7] The implementation was described in a April 2007 technical paper released by Facebook, now hosted on Apache.[8][9]


The Apache Thrift API client/server architecture

Thrift includes a complete stack for creating clients and servers.[10] The top part is generated code from the Thrift definition. From this file, the services generate client and processor codes. In contrast to built-in types, created data structures are sent as a result of generated code. The protocol and transport layer are part of the runtime library. With Thrift, it is possible to define a service and change the protocol and transport without recompiling the code. Besides the client part, Thrift includes server infrastructure to tie protocols and transports together, like blocking, non-blocking and multi-threaded servers. The underlying I/O part of the stack is implemented differently for different languages.

Thrift supports a number of protocols:[10]

The supported transports are:

Thrift also provides a number of servers, which are:


Some stated benefits of Thrift include:[12]

Creating a Thrift service

Thrift is written in C++, but can create code for a number of languages. To create a Thrift service, one has to write Thrift files that describe it, generate the code in the destination language, write some code to start the server and call it from the client. Here is a code example of such a description file:

enum PhoneType {

struct Phone {
  1: i32 id,
  2: string number,
  3: PhoneType type

service PhoneService {
  Phone findById(1: i32 id),
  list<Phone> findAll()

Thrift will generate the code out of this descriptive information. For instance, in Java, the PhoneType will be a simple enum inside the Phone class.

See also


  1. ^ "Apache Thrift - Downloads". Retrieved 6 January 2024.
  2. ^ "Installing and using Apache Cassandra With Java Part 4 (Thrift Client)". Sodeso – Software Development Solutions. Retrieved 2011-03-30. Thrift is a separate Apache project which is a binary communication protocol
  3. ^ Andrew Prunicki. "Apache Thrift: Introduction". Object Computing. Archived from the original on 2011-07-23. Retrieved 2011-04-11. Through a simple and straightforward Interface Definition Language (IDL), Thrift allows [users] to define and create services which are both consumable by and serviceable by numerous languages. Using code generation, Thrift creates a set of files which can then be used for creating clients and/or servers. In addition to interoperability, Thrift can be very efficient through a unique serialization mechanism that is efficient in both time and space.
  4. ^ Thrift Requirements, see this issue for Windows support
  5. ^ Fred Potter, Using Thrift with Cappuccino Archived 2011-08-12 at the Wayback Machine, parallel48's posterously luscious blog, 10 June 2010.
  6. ^ pinterest/elixir-thrift, Pinterest, 2020-02-05, retrieved 2020-02-06
  7. ^ Andrew Prunicki. "Apache Thrift: Code Generation". Object Computing. Archived from the original on 2011-07-23. Retrieved 2011-04-12. Thrift supports many programming languages too varying degrees. The complete list is below. Be careful before assuming that just because your language has some support that it supports all of Thrift's features. Python for example, only supports TBinaryProtocol. Cocoa, C++, C#, Erlang, Haskell, Java, OCaml, Perl, PHP, Python, Ruby, and Smalltalk
  8. ^ Mark Slee, Aditya Agarwal, Marc Kwiatkowski, Thrift: Scalable Cross-Language Services Implementation
  9. ^ "LibraryFeatures - Thrift Wiki". Retrieved 2016-04-21.
  10. ^ a b Andrew Prunicki. "Apache Thrift: Introduction". Object Computing. Archived from the original on 2011-07-23. Retrieved 2011-04-11. The top portion of the stack is generated code from your Thrift definition file. Thrift services result in generated client and processor code. These are represented by the brown boxes in the diagram. The data structures that are sent (other than built-in types) also result in generated code. These result in the red boxes. The protocol and transport are part of the Thrift runtime library. Therefore with Thrift, you can define a service, and are free to change the protocol and transport without re-generating your code. Thrift also includes a server infrastructure to tie the protocols and transports together. There are blocking, non-blocking, single and multi-threaded servers available. The "Underlying I/O" portion of the stack differs based on the language in question. For Java and Python network I/O, the built-in libraries are leveraged by the Thrift library, while the C++ implementation uses its own custom implementation.
  11. ^ Skelton, Steven (3 August 2013). "Developer Friendly Thrift Request Logging". Retrieved 3 July 2014.
  12. ^ Programmer's Guide to Apache Thrift, Randy Abernathy, Manning Publications, 2019, ISBN 978-1-6172-9616-1