eagle xue
eagle xue

Reputation: 31

How to select Transport of thrift?TBufferedTransport or TFramedTransport?

What is the difference between TBufferedTransport and TFramedTransport? How to make choice?

Upvotes: 3

Views: 1449

Answers (1)

JensG
JensG

Reputation: 13411

TBufferedTransport implements simply an internal buffer that is put in between the sender/receiver part and the "raw" transports. The idea is to improve performance, but you should test if it really does in your particular use case.

In contrast, TFramedTransport adds a 4 byte header in front of the data carrying the number of message bytes to follow. This allows for certain optimizations on the receiving end. Furthermore, some server types implicitly require the client to use TFramedTransport.

Long story short

  • TFramedTransport is usually a good choice, but both ends have to support it, because it changes the message data that go over the wire.
  • Buffered transports can be used if "framed" is not an option. Since it does not change any data it can be used freely at will.
  • Using both is discouraged, because TFramedTransport already buffers data internally.

Upvotes: 3

Related Questions