> From: Michael Ludwig [mailto:mil...@gmx.de] 
> Subject: Re: (Tomcat) Does NIO connector make a difference outside of 'Comet' 
> ?

> can we say that:

> (a) blocking IO requires one thread (or, in some other
> server environments, one process) per socket

Well, sort of.  The actual requirement is one thread per established HTTP 
connection, where a connection is typically done using sockets.  There's no 
switching overhead until traffic arrives on the connection, and the waiting 
thread is activated to process it.  Otherwise, the thread is stalled until 
either input arrives or a timeout occurs.

> (b) non-blocking IO allows a thread or process to switch
> between sockets, thus providing scheduling and concurrency
> on just another level, possibly with advantages?

Again, kind of.  There's one thread that polls the connections for traffic, and 
when something arrives, it passes the connection off to a request handler to do 
something useful with it.  When the request handling is finished, the worker 
thread goes back to the pool, and control of the connection is relinquished to 
the polling thread.  Consequently, you only need as many threads as there are 
active requests, as opposed to needing one per active (and usually idle) 
connection.

I suspect you'd be hard pressed to measure any switching difference between the 
two (NIO may actually be slightly worse); the main advantage of NIO is that 
fewer resources (threads) are tied up doing nothing while waiting for clients 
to send something.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to