Slow writes from outside an I/O-worker?

ArvidSvensson arvid.svensson at gmail.com
Thu Sep 22 10:44:01 EDT 2011


ljohnston wrote:
> 
> 
> ArvidSvensson wrote:
>> 
>> Hi there,
>> I'm trying to burst data from a server to a clients and I can't get any
>> speed out of Netty's NIO channel.
>> 
>> while (true) {
>>     Object message = nextMessage();
>>     ChannelFuture future = channel.write(message); // call write from
>> non-I/O worker.
>>     future.awaitUninterruptibly();
>> }
>> 
> 
> Is it necessary to wait for the write to complete before writing the next
> message? Netty maintains an internal write queue per channel which helps
> with bursty traffic. You can write to the channel until the channel is not
> writable then wait until you receive a channelInterestChanged event
> stating that the channel is writable again. Take a look at the 
> http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/discard/DiscardClientHandler.html
> DiscardClientHandler .
> 
> The main difference is that you'll want to notify your thread to start
> generating traffic again in channelInterestChanged to avoid blocking the
> I/O thread.
> 
> Cheers
> Lee
> 


Great news! This solves part of my problem. The isWritable in conjunction
with channelInterestChanged hook makes life a bit simpler. But still, why is
it so expensive to write from outside an I/O-worker? Once on the worker the
writes are fast regardless (more or less) of the channel's isWritable state. 

Rgds,
Arvid

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Slow-writes-from-outside-an-I-O-worker-tp6817213p6820504.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list