You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Ludwig <mi...@gmx.de> on 2010/12/01 00:40:04 UTC
Re: (Tomcat) Does NIO connector make a difference outside of 'Comet'
?
Caldarale, Charles R schrieb am 29.11.2010 um 22:47 (-0600):
> > From: Michael Ludwig [mailto:milu71@gmx.de]
>
> > 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
Which is where the non-blocking comes in, because if it were blocking
the thread would block on checking the connection (reading from the
socket).
> 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.
That makes sense. Thanks.
> 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.
--
Michael Ludwig
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org