Cloud Parts

Apache Thrift

Facebook’s 2007 RPC framework: define types and services in one IDL file, generate clients and servers for over 20 languages, and pick the wire protocol and transport separately.

Type
Open source
License
Apache 2.0
Facts checked
6 October 2026

What it is

You write structs, exceptions and services in a .thrift file, and the thrift compiler generates code for each language you need: data classes, a client stub and a processor that dispatches calls to your handler. Every field carries a number, and that number, not the name, goes on the wire. A reader that meets a field number it doesn’t know uses the type tag to skip it, so old and new versions of a service can talk during a staged rollout. A method takes arguments and returns one result or throws a declared exception; oneway methods send and don’t wait. There are no streaming methods in the IDL.

The runtime is a stack of swappable layers. A transport moves bytes (a socket, HTTP, a file, a memory buffer), optionally wrapped in a framed transport that prefixes each message with its length, which non-blocking servers need. A protocol turns values into bytes: binary writes big-endian integers and length-prefixed strings; compact uses variable-length zigzag integers and packs a small field-number delta and the type into one byte; JSON is human-readable. A server ties a transport, a protocol and the generated processor together, with thread-pool and non-blocking variants among others. Client and server must be configured with the same protocol and transport.

Thrift is an Apache top-level project, free under Apache 2.0, and still versioned 0.x after almost two decades (0.25.0 in September 2026). It sits inside much of the Hadoop world: the Hive Metastore and HiveServer2 speak Thrift, Impala uses it for client and internal calls, HBase runs a Thrift gateway for non-Java clients, and Parquet encodes its file metadata with Thrift. Meta keeps its own diverged fork, fbthrift.

Why teams pick it

  • One IDL generates code for more than 20 languages, from C++, Java, Go and Python to Erlang, OCaml, Delphi and Smalltalk
  • Protocol and transport are chosen independently: compact binary over a socket for speed, JSON over HTTP for debugging or browsers
  • Numbered fields with skip-unknown semantics make adding or removing fields safe across versions
  • Mature and embedded in widely used systems (Hive, Impala, HBase, Parquet), so it is well tested in production

Watch out for

  • No streaming methods, and no deadline that travels with each call as gRPC’s does
  • Language libraries differ in features and minimum versions, tracked in a matrix the project itself says may not be correct in all cases; it has never reached 1.0
  • Client and server must be set up with the same protocol and transport (binary, compact or JSON; framed or not): HBase’s guide, for one, notes that a framed server needs a matching client setting

Alternatives

What all remote procedure calls have in common →

How it fits with other technologies

Define a service in Thrift IDL and generate Python and Java code · bash

cat > cache.thrift <<'EOF'
namespace py cache
namespace java com.example.cache

struct Item {
  1: required string key,
  2: optional binary value,
  3: optional i64 expires_at   // added later: old readers skip field 3
}

exception NotFound { 1: string key }

service Cache {
  Item get(1: string key) throws (1: NotFound nf),
  void put(1: Item item),
  oneway void touch(1: string key)   // fire and forget
}
EOF

thrift --gen py --gen java cache.thrift   # writes gen-py/ and gen-java/

See it in a real stack

No architecture uses Apache Thrift yet. Drop it into the playground and wire it up yourself.Open playground →
Where it came from2007–2026

As Facebook grew, its search, ad selection and event logging had outgrown its LAMP stack. Engineers wrote back-end services in whatever language fit best, mostly C++, Java and Python, while the website was PHP, so they needed a fast, reliable way to call across languages. The authors found that existing options were too limited, too inflexible about data types, or too slow; their paper dismissed SOAP for its XML parsing overhead and CORBA as heavyweight, and noted that Google’s Protocol Buffers were closed-source. Thrift succeeded Pillar, a similar system Adam D’Angelo had started at Caltech and continued at Facebook.

Mark Slee, Aditya Agarwal and Marc Kwiatkowski described Thrift in an April 2007 paper, and Facebook open-sourced it that month with five target languages: C++, Java, Python, Ruby and PHP. It already carried Facebook’s search service and structured logging. Thrift entered the Apache Incubator in May 2008 and became a top-level Apache project in October 2010.

Hadoop-era projects adopted it widely: Cassandra’s older client API, HBase’s gateway, Hive’s servers and Parquet’s metadata all used Thrift. In 2015 Google open-sourced gRPC, built on Protocol Buffers and HTTP/2, which now covers much of the same ground, and Cassandra removed its Thrift interface in 4.0. Thrift lives on inside the systems that built on it.

Why it’s built this way

Static code generation instead of a dynamic system
Generating code ahead of time produces validated code that runs without run-time type introspection, and the developer describes a whole service in one short file.
Separate transport and protocol layers
The paper argued that whether a service uses XML or binary is immaterial to the application, and the same data should flow over sockets, memory or files. Splitting the layers let Facebook add framing, buffering or a new encoding without touching generated code.
Numbered fields and self-delimiting data
Facebook needed staged rollouts and old log files to keep working. A field identifier plus a type tag lets a reader skip anything it doesn’t recognise, and argument lists are structs too, so method signatures can evolve safely.
Simplicity first, compactness later
The first binary protocol deliberately skipped tricks like 7-bit variable-length integers to keep the code clear. The compact protocol, with varints and field-number deltas, was added later when size mattered.

Timeline

  1. 2007

    Facebook publishes the Thrift paper and open-sources it in April

  2. 2008

    Enters the Apache Incubator in May

  3. 2010

    Becomes a top-level Apache project in October

  4. 2021

    Cassandra 4.0 removes its deprecated Thrift interface

  5. 2026

    Thrift 0.25.0 released in September

Sources14 · facts checked 6 October 2026

Improve this page on GitHub