Hi<div><br></div><div>One possibility is that the effect is caused by <a href="http://en.wikipedia.org/wiki/Nagle&#39;s_algorithm">http://en.wikipedia.org/wiki/Nagle&#39;s_algorithm</a>. Could be that the tcp stack holds on  to the data with an increasing timeout algorithm, although that doesn&#39;t really account for the variance. You can try to turn it off.</div>
<div><br></div><div><div>From <a href="http://www.jboss.org/file-access/default/members/netty/freezone/api/3.2/index.html">http://www.jboss.org/file-access/default/members/netty/freezone/api/3.2/index.html</a>:</div><div>
ServerBootstrap b = ...;</div><div>b.setOption(&quot;child.tcpNoDelay&quot;, true);</div><div><br></div><div>I actually think you need to set if to false to turn nagle&#39;s algorithm off, although that doesn&#39;t seem very intuitive :)</div>
<div><br></div><div>If that doesn&#39;t work, try to profile your gc and see if theres some excessive object allocations or something, that could cause it to introduce long pauses.</div><div><br></div><div><br></div><div>
Regards</div><div>Jannick</div><div><br></div><br><div class="gmail_quote">2010/1/7 justkevin <span dir="ltr">&lt;<a href="mailto:filter.netty@wx3.com">filter.netty@wx3.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
After noticing my game app was occasionally running sluggish, I spent quite a<br>
bit of time trying to figure out why without success. If anyone has<br>
suggestions on what to try I&#39;d appreciate it. The details are long, but I<br>
don&#39;t know what might be important:<br>
<br>
Details:<br>
<br>
The client is written in AS3.<br>
<br>
The server is written in Java using Netty 3.2 (I&#39;ve updated to the most<br>
recent alpha).<br>
<br>
I&#39;m testing locally, with client and server on the same box.<br>
<br>
When the first client connects, latency as measured with a round-trip ping<br>
pong is low, &lt; 10 ms. It can remain low for a while, but eventually begins<br>
increasing in spurts at varying rates.  For example, it might be &lt; 10 ms for<br>
a while, then 50-100 ms for a while, then 100-200 ms, and so forth. There&#39;s<br>
no upper limit, I&#39;ve seen delays in multiple seconds. The larger the<br>
latency, the larger the variance. The increases may be correlated to large<br>
bursts of data.<br>
<br>
If I restart the client, the latency will usually drop, but not always.<br>
Sometimes it restarts high.<br>
<br>
If I restart the server, the next client to connect will get a low latency.<br>
<br>
Using system times, I&#39;ve established that the latency is entirely on the<br>
downstream-- the ping takes 0ms to reach the server, and all the increase is<br>
between the time the pong is created and when its received by the client.<br>
&gt;From this I&#39;m guessing it&#39;s something with how I&#39;m sending messages.<br>
<br>
The only ChannelPipeline handler on outbound is a LengthFieldPrepender.<br>
<br>
Here is how I&#39;m sending the message:<br>
<br>
                // A Netty channel expects a message in the format of a ChannelBuffer:<br>
                ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();<br>
                // Wrap the buffer with a ChannelBufferOutputStream, which implements<br>
DataOutput<br>
                // (our messages expect to write to a DataOutput)<br>
                ChannelBufferOutputStream output = new ChannelBufferOutputStream(buffer);<br>
                // First write the message id:<br>
                output.writeByte(message.getId());<br>
                // Then have the message write itself, checking to make sure the message<br>
                // obeys its length contract:<br>
                int beforeLength = output.writtenBytes();<br>
                int written = message.write(output);<br>
                if(beforeLength + written != output.writtenBytes()){<br>
                        logger.severe(&quot;Outbound message violated length contract:&quot; + message);<br>
                        throw new RuntimeException(&quot;Message violated length contract:&quot; +<br>
message);<br>
                }<br>
                // Finally, put into the channel. The channel pipeline should already have<br>
a length prepender:<br>
                this.channel.write(buffer);<br>
<br>
Thanks in advance for any suggestions,<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n2.nabble.com/What-might-be-causing-increasing-latency-tp4269271p4269271.html" target="_blank">http://n2.nabble.com/What-might-be-causing-increasing-latency-tp4269271p4269271.html</a><br>

Sent from the Netty User Group mailing list archive at Nabble.com.<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</font></blockquote></div><br></div>