Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 82466 invoked from network); 22 Dec 2010 16:53:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Dec 2010 16:53:57 -0000 Received: (qmail 57472 invoked by uid 500); 22 Dec 2010 16:53:53 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 57349 invoked by uid 500); 22 Dec 2010 16:53:52 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 57340 invoked by uid 99); 22 Dec 2010 16:53:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Dec 2010 16:53:52 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [72.22.94.67] (HELO virtual.halosg.com) (72.22.94.67) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Dec 2010 16:53:47 +0000 Received: (qmail 11809 invoked from network); 22 Dec 2010 10:53:26 -0600 Received: from c-98-245-245-160.hsd1.co.comcast.net (HELO ?10.1.10.166?) (98.245.245.160) by halosg.com with (AES256-SHA encrypted) SMTP; 22 Dec 2010 10:53:26 -0600 Message-ID: <4D122D07.6020003@hanik.com> Date: Wed, 22 Dec 2010 09:53:27 -0700 From: Filip Hanik - Dev Lists User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Tomcat 6.0.18 related NIO questions. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit hi shrikant, there are many benefits of NIO in a tomcat 6, the main being there is no longer a thread-per-connection limit. 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 inputstream.read 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. best Filip On 12/22/2010 9:31 AM, shrikant patel wrote: > We are using tomcat connector as follows --> > > 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 - www.avg.com > Version: 10.0.1170 / Virus Database: 1435/3329 - Release Date: 12/21/10 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org