
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.
- What it is
- Remote procedure calls
- Type
- Open source
- Made by
- Apache Software Foundation
- 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 →
Cap’n ProtoOpen sourceA binary format laid out like an in-memory struct, so reading needs no parse step, plus an RPC system built on object references and promise pipelining.
gRPCOpen sourceGoogle’s open RPC framework: describe a service in a `.proto` file, generate typed clients and servers, and call them over HTTP/2 with streaming, deadlines and standard status codes.
Protocol BuffersOpen sourceGoogle’s schema-first binary encoding: messages defined in `.proto` files, fields identified by number, code generated for each language.How it fits with other technologies
What Apache Thrift uses
- Apache Thriftcarries Metastore and HiveServer2 calls forApache Hive
- Apache Thriftcarries client and internal calls forApache Impala
- Apache Thriftgives non-Java clients a gateway API toApache HBase
- Apache Thriftencodes the file metadata ofApache Parquet
- Apache Thriftwas the client API, until 4.0, ofApache Cassandra
- Apache Thriftlinks interpreter processes to the server inApache Zeppelin
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
- 2007
Facebook publishes the Thrift paper and open-sources it in April
- 2008
Enters the Apache Incubator in May
- 2010
Becomes a top-level Apache project in October
- 2021
Cassandra 4.0 removes its deprecated Thrift interface
- 2026
Thrift 0.25.0 released in September
- Slee, Agarwal and Kwiatkowski: Thrift, scalable cross-language services implementation (Facebook, April 2007)
- Apache Thrift: About (open-sourced April 2007, Incubator May 2008, TLP October 2010)
- Apache Cassandra 4.0 NEWS.txt (Thrift interface removed)
- Thrift compact protocol specification
- Apache Thrift v0.25.0 release on GitHub (Sep 2026)
- Google Developers Blog: Introducing gRPC (February 2015)
Sources14 · facts checked 6 October 2026
- Apache Thrift docs: Concepts (transport, protocol, processor, server)
- Apache Thrift docs: Interface Definition Language (fields, requiredness, `oneway`)
- Thrift binary protocol specification
- Thrift compact protocol specification (zigzag varints, field id deltas)
- Apache Thrift: Language support (LANGUAGES.md)
- Slee, Agarwal and Kwiatkowski: Thrift paper (framed transport, non-blocking server, April 2007)
- Apache Thrift v0.25.0 release on GitHub (Sep 2026)
- Hive wiki: HiveServer2 overview (Thrift service, TBinaryProtocol)
- Impala docs: Ports used by Impala (HiveServer2 protocol, internal Thrift)
- Apache HBase Reference Guide: Thrift API and Thrift gateway
- Apache Parquet docs: File format (Thrift metadata)
- Zeppelin docs: Writing a new interpreter (separate JVM, Thrift)
- Apache Cassandra 4.0 NEWS.txt (Thrift interface removed)
- facebook/fbthrift on GitHub (Facebook’s branch of Apache Thrift)