简体   繁体   English

Thrift php lib性能问题

[英]Thrift php lib performance issue

I recently use php thrift client to call some service implemented by java thrift server. 我最近使用php thrift客户端来调用由Java thrift服务器实现的某些服务。

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. 但是我发现,当我传输大量复杂数据时,由于花费了成千上万的TBinaryProtocol::readXXX()TBinaryProtocol::writeXXX()调用,php花了很多时间对数据进行序列化和反序列化。

Any good idea to optimize this? 有什么好主意可以优化吗?

The TBufferedTransport or TFramedTransport may help. TBufferedTransportTFramedTransport可能会有所帮助。 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 (ie an Int32 holding the total length of the data block is inserted at the beginning). 前者之间只有一个缓冲区,以减少I / O调用,而后者还通过修改线路数据来更改传输堆栈(即,在开头插入了保存数据块总长度的Int32)。

Hence, TBufferedTransport is a purely local thing, in contrast TFramedTransport must be used on both client and server. 因此, TBufferedTransport纯粹是本地事物,相比之下, TFramedTransport必须同时在客户端和服务器上使用。 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. 此外,某些可用的服务器类型需要TFramedTransport ,因此对于任何新的API,从一开始就添加TFramedTransport可能是一个不错的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM