AS3 HttpService速度很慢,响应时间为1至5秒
问题描述:
在全新MacBook Air上使用运行在本地主机上的rails的Flex Builder 4.5。使用卷曲,读取服务器的响应时间大约为200-300ms。当我使用HTTPService时,从send()到接收到的结果的时间在1-5秒之间,用于从服务器接收少于10行的XML。如果我使用浏览器来呈现网址,它将与curl匹配,即它是即时的,我不会等待XML呈现。AS3 HttpService速度很慢,响应时间为1至5秒
调试/非调试模式下的编号相同。 HTTPService在创建完成后调用,因此GUI已完成。数据收到后,我的算法的其余部分在应用程序中完成20ms以下。
这是预计的时间,还是我做错了什么,或者有东西配置不正确?
答
您所描述的听起来像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's algorithm为特定连接。
答
要扩大sarnold的答案,你需要做的是添加以下行:
<socket-tcp-no-delay-enabled>true</socket-tcp-no-delay-enabled>
在哪里添加该行? –
这些似乎引用LCDS - 我在Flash Builder中使用HTTPService对象。 – Joe