Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F283EF0A4 for ; Sat, 23 Mar 2013 15:05:58 +0000 (UTC) Received: (qmail 26887 invoked by uid 500); 23 Mar 2013 15:05:57 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 26824 invoked by uid 500); 23 Mar 2013 15:05:57 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 26815 invoked by uid 99); 23 Mar 2013 15:05:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Mar 2013 15:05:57 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: unknown (athena.apache.org: error in processing during lookup of thurston@nomagicsoftware.com) Received: from [216.139.250.139] (HELO joe.nabble.com) (216.139.250.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Mar 2013 15:05:52 +0000 Received: from alf.nabble.com ([192.168.236.21]) by joe.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UJQ0h-0005ry-Ad for dev@tomcat.apache.org; Sat, 23 Mar 2013 08:05:31 -0700 Date: Sat, 23 Mar 2013 08:05:31 -0700 (PDT) From: igaz To: dev@tomcat.apache.org Message-ID: <1364051131292-4996773.post@n6.nabble.com> Subject: Getting my head around NIO 'simulated' blocking (trying to) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org So I won't bury the lede: what exactly (and why) is Tomcat doing 'simulated' read blocking when using the NIO connector? I've done some due diligence including downloading the latest source (7.0.37) and searching the tomcat mailing lists. Firstly, to make things simpler, let's take comet processing and writes off the table. In the tomcat doc, there is the nice table that compares the various http connectors and it reads this about nio: Read HTTP Request: non-blocking (I assume that means read all of the http request headers) Read HTTP Body: sim blocking (e.g. in a POST) I've browsed the code and the NIOEndpoint.Acceptor and NIOEndpoint.Poller all essentially make sense and look familiar to someone who has some experience with Java NIO But there's quite a bit of code to look at (and lots of abstraction) and I haven't got much further than there. What I don't understand is the HTTP Body: sim blocking part. Thinking about that, the only conclusion I can draw is that HttpRequest.getParameter('xxxx') potentially blocks?!?! i.e. tomcat is 'deferring' the parsing of the HTTP Body (as in the case of a POST) until the application Servlet 'asks' for it? I've always assumed that the HTTPRequest that is passed to the Servlet is fully formed. In one of the posts I saw a comment that (I believe Filip) mentioned something about Servlets that call getInputStream() requiring simulated blocking. But why would any servlet code ever do that? After all, it has the HttpRequest which is a nice abstraction over the input stream (hmm, maybe when reading uploaded files)? So the first question is (assuming my inference is correct), why use simulated blocking at all? Just read the entire http request (headers and body) until you detect that the request is complete (and using standard NIO techniques, viz. a selector). Is there something in the servlet specs that proscribes that? And the second question is how? I guess you invoke SocketChannel.configureBlocking(true) and then do SocketChannel.reads() It seems that using NIO to only read the HTTP headers vitiates the performance benefits of NIO somewhat and I'm sure you're doing it for a good reason . . . -- View this message in context: http://tomcat.10.n6.nabble.com/Getting-my-head-around-NIO-simulated-blocking-trying-to-tp4996773.html Sent from the Tomcat - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org