Maximum transmission buffer size?

Trustin Lee (이희승) trustin at gmail.com
Tue Sep 29 04:32:12 EDT 2009


Hi Iain,

Netty does not stop you from writing infinitely fast.  If you write
faster than Netty can flush, you will see OutOfMemoryError eventually.
 A mechanism that prevents this problem is provided by Netty, of
course.  If the size of the write buffer is greater than certain
threshold, Channel.isWritable() will start to return false.  You can
check this property before each write request and stop writing when it
turns false.  You are going to be notified when the write buffer size
became smaller than certain threshold, you will be notified with a
channelInterestChanged event, then you can continue writing messages.
The discard client example demonstrates how to achieve this behavior.

The threshold values are configurable in NioSocketChannelConfig.  The
property names are 'writeBufferHighWaterMark' and
'writeBufferLowWaterMark' respectively.  Please refer to the Javadoc
and let me know if you think the Javadoc could be improved.  I'd love
to improve it.

— Trustin Lee, http://gleamynode.net/

On Sat, Sep 26, 2009 at 12:00 AM, Iain McGinniss <iainmcgin at gmail.com> wrote:
> Just a quick question, which should hopefully clarify an aspect of
> Netty's philosophy for me. Say I have a network connection that is
> capable of sending 64KB/s. I have an open TCP channel in Netty, and I
> write to this channel at a rate of 128KB/s. This obviously results in
> a growing queue of data at a rate of 64KB/s. Will Netty ever refuse to
> enqueue my data for transmission, or discard any buffers passed to
> write(), or will it eventually just throw a Java OutOfMemoryError,
> when there is no more heap space left to store the queue of written
> (but untransmitted) channel buffers?
>
> Iain
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



More information about the netty-users mailing list