Thrift is a serialization and RPC framework for service communication. Thrift enables these features in all major languages, and there is strong support for C++, Python, Hack, and Java. Most services at Facebook are written using Thrift for RPC, and some storage systems use Thrift for serializing records on disk.
A CODE GENERATOR
Thrift has a code generator which generates data structures that can be serialized using Thrift, and client and server stubs for RPC, in different languages.
A SERIALIZATION FRAMEWORK
Thrift has a set of protocols for serialization that may be used in different languages to serialize the generated structures created from the code generator.
AN RPC FRAMEWORK
Thrift has a framework to frame messages to send between clients and servers, and to call application-defined functions when receiving messages in different languages.
There are several key goals for these components:
-
Ease of use: Thrift takes care of the boilerplate of serialization and RPC, and enables the developer to focus on the schema of the system's serializable types and on the interfaces of system's RPC services.
-
Cross language support: Thrift enables intercommunication between different languages. For example, a Python client communicating with a C++ server.
-
Performance: Thrift structures and services enable fast serialization and deserialization, and its RPC protocol and frameworks are designed with performance as a feature.
-
Backwards compatibility: Thrift allows fields to be added to and removed from serializable types in a manner that preserves backward and forward compatibility.
** References **
Faceboook Thrift Lab
如何实现一个简单的RPC
网友评论