python在服务器上运行慢_Thrift服务器对于简单操作来说非常慢

博主在使用Thrift作为Python服务器和Haskell客户端之间的跨语言通信平台时遇到了性能问题,服务器响应时间约为0.5s,远高于所需的0.1s。服务器端实现简单,遵循Thrift教程。现在寻求优化方案,提高响应速度。
摘要由CSDN通过智能技术生成

我正在运行一个简单的Thrift服务器(http://thrift.apache.org/),作为Python(服务器)和Haskell(客户机)之间的跨语言平台。唯一需要发送的数据结构是一个3元组的double,因此服务器/客户端的实现也非常简单-只需遵循教程就足够了。在

然而,它真的,真的很慢!每次服务器响应的响应时间大约为0.5s,而我需要的响应时间大约为0.1s或更低。在

有人对如何加快速度有什么想法吗?您可以在下面看到我的简单服务器实现:1 import sys

2

3 from vision import Vision

4 from vision.ttypes import *

5

6 from thrift.transport import TSocket

7 from thrift.transport import TTransport

8 from thrift.protocol import TBinaryProtocol

9 from thrift.protocol.TBinaryProtocol import TBinaryProtocolAccelerated

10 from thrift.server import TServer

11

12 class VisionHandler:

13 def observe(self):

14 ret = Position()

15 ret.x,ret.y,ret.z = (1,2,3)

16 return ret

17

18 ret = Position()

20 handler = VisionHandler()

21 processor = Vision.Processor(handler)

22 transport = TSocket.TServerSocket(port=9090)

23 tfactory = TTransport.TBufferedTransportFactory()

24 pfactory = TBinaryProtocol.TBinaryProtocolFactory()

25

26 server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

27

28 print 'Starting the vision server...'

29 server.serve()

30 print 'done.'

客户机只需通过运行

^{pr2}$

然后呢res

据我所知,这一切都很标准!为什么这么慢??在

谢谢!在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值