0

I recently use php thrift client to call some service implemented by java thrift server.

But I found that when I transfer a large amount of complex data, php spent a lot of time serialize and deserialize data because of tens of thousands of TBinaryProtocol::readXXX() or TBinaryProtocol::writeXXX() calls.

Any good idea to optimize this?

andreas
  • 16,357
  • 12
  • 72
  • 76
Just_CJ
  • 61
  • 1
  • 8
  • I'd suggest to discuss this [on the mailng lists](https://thrift.apache.org/mailing) if you suspect a bug or problem within Thrift. – JensG Feb 24 '17 at 08:43

1 Answers1

1

The TBufferedTransport or TFramedTransport may help. The former only has a buffer in between to reduce I/O calls, while the latter also changes the transport stack by modifying the wire data (i.e. an Int32 holding the total length of the data block is inserted at the beginning).

Hence, TBufferedTransport is a purely local thing, in contrast TFramedTransport must be used on both client and server. Aside from that, both are working very similar.

Furthermore, some of the server types available require TFramedTransport, so for any new API it may be a good choice to add TFramedTransport from the beginning.

JensG
  • 13,148
  • 4
  • 45
  • 55
  • Thank you. I found that using TBinaryProtocolAccelerated with php extention thrift_protocol is the best way. – Just_CJ Feb 26 '17 at 08:38