Receive buffers and ReceiveBufferSizePredictorFactory

"Trustin Lee (이희승)" trustin at gmail.com
Tue Jan 26 10:53:41 EST 2010


Hi Albert,

Thanks for reporting the problem.  I've just checked in the fix.

receiveBufferSize is the socket parameter that advices the operating
system how large kernel buffer should be allocated for receiving
packets.  This is identical to Socket.setReceiveBufferSize().

receiveBufferSizePredictor determines how large userspace buffer should
be allocated to read data from the kernel buffer.  This is necessary in
NIO because there is no way to know how many bytes are available in the
kernel buffer.

In most cases, you don't need to configure receiveBufferSizePredictor or
its factory because the default implementation usually works fine.

receiveBufferSize is sometimes critical to application throughput
because it affects the O/S network layer directly.

If you want to increase the receive buffer size to 64KiB+, you have to
use "receiveBufferSize" option instead of "child.receiveBufferSize".
Otherwise the option will not be affected.  "receiveBufferSize" is
identical to ServerSocket.setReceiveBufferSize() and
"child.receivedBufferSize" is identical to Socket.getReceiveBufferSize().

The default receiveBufferSizePredictor is
AdaptiveReceiveBufferSizePredictor.  You might want to set
"child.receiveBufferSizePredictorFactory" to
AdaptiveReceiveBufferSizePredictor with proper parameters.  If not
satisfied, you could even write your own predictor and predictor factory.

If you don't want to build Netty from the source code which fixes the
problem you reported, you can call
NioSocketChannelConfig.setReceiveBufferSizePredictor() directly at
channelOpen event.

HTH,
Trustin

Albert Strasheim wrote:
> Hello all (mostly Trustin),
> 
> I've started looking at the ReceiveBufferSizePredictorFactory stuff that was
> recently added to Netty.
> 
> Firstly, I suspect that DefaultNioSocketChannelConfig#setOption is missing
> code to set the ReceiveBufferSizePredictorFactory.
> 
> It's also not clear to me how the NioSocketChannelConfig's
> ReceiveBufferSizePredictorFactory interacts with the receiveBufferSize in
> ServerSocketChannelConfig.
> 
> I have a server with a ServerBootstrap that uses a
> NioServerSocketChannelFactory for which I want to set large receive buffers
> for newly accepted channels. Which of these options should I be using?
> 
> I'm using Netty 3.2.0 ALPHA3.
> 
> Regards,
> 
> Albert

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100127/0e9bdd05/attachment.bin 


More information about the netty-users mailing list