Skip to content

Thrift Server Models

Thrift Server Models define the underlying architecture used to handle incoming RPC requests. Apache Thrift provides several server implementations, each optimized for different scenarios involving threading, blocking I/O, and concurrency.

Server Types

Thrift includes four primary server models:

  • TSimpleServer: This is the most basic server model. It typically handles all requests in a single thread using a blocking I/O approach, making it suitable for testing or simple, low-concurrency use cases.
  • TThreadPoolServer: This model manages a pool of worker threads to handle incoming requests. It is designed to process requests concurrently, making it appropriate for standard applications where blocking I/O is acceptable.
  • TNonblockingServer: This server utilizes non-blocking I/O (often implemented with Java NIO). It is designed to handle multiple connections efficiently without requiring a thread for every single connection, which can improve resource utilization under high load.
  • THsHaServer: The "Half-Sync/Half-Async" server combines aspects of the non-blocking model with a thread pool. It typically uses a single thread to accept non-blocking connections and a worker thread pool to process the requests, offering a balance between the throughput of TNonblockingServer and the CPU utilization of TThreadPoolServer.

Context

These server models are part of Apache Thrift's stack for defining and creating cross-language RPC services.^[600-developer__big-data__java-serializable.md] When configuring a service, developers must pair a server model with a specific Transport (e.g., TSocket) and Protocol (e.g., TBinaryProtocol) to fully define the communication layer.^[600-developer__big-data__java-serializable.md]

  • [[RPC]]
  • [[Microservices]]
  • [[Java Serializable]]

Sources

^[600-developer__big-data__java-serializable.md]