tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <>
Subject Re: Tomcat 6.0.18 related NIO questions.
Date Wed, 22 Dec 2010 16:53:27 GMT
hi shrikant,
there are many benefits of NIO in a tomcat 6, the main being there is no longer a thread-per-connection
Note in Tomcat 7, even with the blocking connector, you can have more connections than threads.
The NIO connector will read your request headers in a non blocking fashion, it will also do
SSL negotiation in a non blocking fashion, so 
while this is taking place, you're not holding a thread waiting for a client response.
Same thing, if you use send file, then the NIO connector can download a file to more than
one client using a single thread.
However, as soon as you enter a the HttpServlet.service method, all non blocking benefits
are gone. Per the servlet specification, the same 
thread is used executing this method, and that means, blocking. Even if you do
or outputstream.write, and you use the NIO 
connector, tomcat blocks these calls for you.
In Tomcat 7 (Servlet 3.0) you will be able to do a bit more async stuff using the async API,
but in Tomcat 6, those features only exists 
using the Comet interface.


On 12/22/2010 9:31 AM, shrikant patel wrote:
> We are using tomcat connector as follows -->
> <Connector connectionTimeout="500000" port="8080" protocol="HTTP/1.1" ...
> Based on the documentation we are using the blocking call, right? So the
> servlet thread is blocked for IO while reading request and writing response.
> In case we want to use NIO, we have to specify protocol as
> org.apache.coyote.http11.Http11NioProtocol - non blocking Java connector,
> org.apache.coyote.http11.Http11AprProtocol - the APR connector.
> I have basic understanding of NIO. My understanding is that tomcat
> internally use Java NIO to read the request into buffer. When complete
> request is read then dispatch it to servlet for processing. That way each
> servlet thread is not blocked on IO. Similarly in case of response, it get
> response from servlet, keep buffering it and send it to client. This way
> servlet is not completely blocked for entire duration of the response being
> send to client.
> Please let me know if this is correct.
> Is there document in this regards you can point to get better understanding?
> I have googled, i do get many article but about NIO in general nothing
> specific to how tomcat handles it.
> Thanks in Advance.
> Shri
> -----
> No virus found in this message.
> Checked by AVG -
> Version: 10.0.1170 / Virus Database: 1435/3329 - Release Date: 12/21/10

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message