How to select Transport of thrift?TBufferedTransport or TFramedTransport?
Olivia Zamora
What is the difference between TBufferedTransport and TFramedTransport? How to make choice?
1 Answer
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
TFramedTransportis 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
TFramedTransportalready buffers data internally.