AS3 HttpService 很慢,响应时间为 1-5 秒

发布于 2024-12-14 07:07:24 字数 317 浏览 5 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷→糖丶微凉 2024-12-21 07:07:24

您所描述的听起来像是 HTTPService 在发送请求之前没有在其套接字上设置 TCP_NODELAY 套接字选项 (setsockopt(3)) 。从我的 Linux tcp(7)

  TCP_NODELAY
          If set, disable the Nagle algorithm.  This means that
          segments are always sent as soon as possible, even if
          there is only a small amount of data.  When not set,
          data is buffered until there is a sufficient amount to
          send out, thereby avoiding the frequent sending of
          small packets, which results in poor utilization of
          the network.  This option is overridden by TCP_CORK;
          however, setting this option forces an explicit flush
          of pending output, even if TCP_CORK is currently set.

也许您的平台有另一种方法可以要求禁用 Nagle 算法

What you've described sounds like HTTPService isn't setting the TCP_NODELAY socket option (setsockopt(3)) on its sockets before sending a request. From my Linux tcp(7):

  TCP_NODELAY
          If set, disable the Nagle algorithm.  This means that
          segments are always sent as soon as possible, even if
          there is only a small amount of data.  When not set,
          data is buffered until there is a sufficient amount to
          send out, thereby avoiding the frequent sending of
          small packets, which results in poor utilization of
          the network.  This option is overridden by TCP_CORK;
          however, setting this option forces an explicit flush
          of pending output, even if TCP_CORK is currently set.

Perhaps your platform has another way you can ask to disable Nagle's algorithm for a specific connection.

不美如何 2024-12-21 07:07:24

要扩展 sarnold 的答案,您需要做的是添加以下行:

<socket-tcp-no-delay-enabled>true</socket-tcp-no-delay-enabled>

To expand on sarnold's answer, what you need to do is add the following line:

<socket-tcp-no-delay-enabled>true</socket-tcp-no-delay-enabled>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文