Confused about Netty NIO

phi6 phidinh6 at gmail.com
Wed Oct 14 11:30:23 EDT 2009


I understand that I should use NIO, not for performance specifically but for
scalability, as traditional threaded model uses up a lot of resources due to
context switching. 

So I am using NioServerSocketChannelFactory to implement my server. 

So I understand, instead of thread per connection like blocking-IO, all
reading and writing is done on one thread asynchronously. My question is,
how does Netty (or NIO in general for that matter) handle logic that takes a
long time to complete? 

For example, in my pipeline I have a message received handler which does
some tasks based on the message it receives from clients. What if a client
wants the server to do SomeLongTask() which takes about 10 seconds. If it's
all on one thread, how does it manage a second connection that wants to do
SomeOtherTask() before SomeLongTask() is completed? In the threaded model
they would run concurrently... but with NIO there is a single thread
handling all my client messages... does SomeOtherTask() get queued up until
SomeLongTask() is completed? 

I'm probably thinking about this completely the wrong way, please advise. 

Many thanks
-- 
View this message in context: http://n2.nabble.com/Confused-about-Netty-NIO-tp3823513p3823513.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list