Java serialization in distributed systems¶
Java serialization is a fundamental mechanism in distributed computing, primarily utilized within Java Remote Method Invocation (RMI) to enable communication between objects located on different Java Virtual Machines (JVMs)^[600-developer-big-data-java-serializable.md].
While the native Java Serializable interface facilitates this communication, modern distributed systems often adopt alternative RPC (Remote Procedure Call) frameworks to support interoperability across different programming languages^[600-developer-big-data-java-serializable.md].
Cross-Language Serialization Frameworks¶
In environments requiring cross-language support, several serialization frameworks are commonly employed over native Java serialization^[600-developer-big-data-java-serializable.md]:
- Thrift (developed by Facebook)
- Protobuf (developed by Google)
- Avro
- gRPC
- XML-based WebService
- JSON-based RESTful APIs^[600-developer-big-data-java-serializable.md]
Apache Thrift¶
Apache Thrift is a prominent framework that provides a comprehensive stack for cross-language development. It defines specific protocols for data formats and various models for handling service transport^[600-developer-big-data-java-serializable.md].
Transmission Formats¶
Thrift supports multiple protocols to control how data is encoded for transmission^[600-developer-big-data-java-serializable.md]: * TBinaryProtocol: Binary encoding. * TCompactProtocol: More efficient binary encoding. * TJsonProtocol: JSON encoding. * TSimpleJsonProtocol: Simple JSON encoding (without metadata). * TDebugProtocol: Used for debugging purposes.
Transport Layers¶
The framework offers several transport layer implementations to determine how data moves between nodes^[600-developer-big-data-java-serializable.md]: * TSocket: Standard socket blocking I/O. * TFramedTransport: Framed transport (often used with non-blocking servers). * TFileTransport: File-based transport. * TMemoryTransport: Memory-based I/O.
Server Models¶
Thrift provides different server models to handle concurrent requests^[600-developer-big-data-java-serializable.md]: * TSimpleServer: A simple single-threaded server. * TThreadPoolServer: A multi-threaded server using a thread pool. * TNonblockingServer: A non-blocking server. * THsHaServer: Half-Sync/Half-Async server.
Related Concepts¶
- [[RMI]]
- [[RPC]]
- [[Protobuf]]
Sources¶
^[600-developer-big-data-java-serializable.md]