AS3 HttpService 很慢,响应时间为 1-5 秒
使用 Flex Builder 4.5 和在全新 MacBook Air 上的本地主机上运行的 Rails。使用curl,一次读取的服务器响应时间在200-300ms左右。当我使用 HTTPService 时,从服务器接收到的不到 10 行 XML,从 send() 到收到结果需要 1-5 秒。如果我使用浏览器来呈现 URL,它会匹配curl,即它是瞬时的,我不会等待 XML 呈现。
调试/非调试模式的数字相同。创建完成后调用 HTTPService,这样 GUI 就完成了。收到数据后,应用程序中的其余算法将在 20 毫秒内完成。
这是预期的时间,还是我做错了什么,或者配置不正确?
Using Flex Builder 4.5 with rails running on localhost on a brand new MacBook Air. Using curl, the response time of the server of a read is around 200-300ms. When I use HTTPService, from send() to result received is between 1-5 seconds for less than ten lines of XML received from the server. If I use the browser to render the URL, it matches curl, ie it is instantaneous, I'm not waiting for the XML to render.
The number is the same for debug/non-debug mode. The HTTPService is called after creation complete, so the GUI is done. After data is received, the rest of my algorithms are completing under 20ms in the application.
Is this time expected, or am I doing something wrong, or have something configured incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所描述的听起来像是
HTTPService
在发送请求之前没有在其套接字上设置TCP_NODELAY
套接字选项 (setsockopt(3)
) 。从我的 Linuxtcp(7)
:也许您的平台有另一种方法可以要求禁用 Nagle 算法。
What you've described sounds like
HTTPService
isn't setting theTCP_NODELAY
socket option (setsockopt(3)
) on its sockets before sending a request. From my Linuxtcp(7)
:Perhaps your platform has another way you can ask to disable Nagle's algorithm for a specific connection.
要扩展 sarnold 的答案,您需要做的是添加以下行:
To expand on sarnold's answer, what you need to do is add the following line: