Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 13242 invoked from network); 14 May 2009 12:35:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 May 2009 12:35:38 -0000 Received: (qmail 11070 invoked by uid 500); 14 May 2009 12:35:34 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 11022 invoked by uid 500); 14 May 2009 12:35:34 -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 11011 invoked by uid 99); 14 May 2009 12:35:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2009 12:35:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=FM_FAKE_HELO_VERIZON,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dckerber@verizon.net designates 206.46.173.1 as permitted sender) Received: from [206.46.173.1] (HELO vms173001pub.verizon.net) (206.46.173.1) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2009 12:35:23 +0000 Received: from [127.0.0.1] ([216.41.111.254]) by vms173001.mailsrvcs.net (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPA id <0KJM00DETW9X47XZ@vms173001.mailsrvcs.net> for users@tomcat.apache.org; Thu, 14 May 2009 07:34:50 -0500 (CDT) Message-id: <4A0C0FE4.8040009@verizon.net> Date: Thu, 14 May 2009 08:34:44 -0400 From: David kerber User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-version: 1.0 To: Tomcat Users List Subject: Peformance on socket reads Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org This post is a follow-on to my "performance with many small requests" thread from a couple days ago. I have been watching my app, and taking thread dumps when things seem to be running a bit slower than I would like. Right now, the biggest bottleneck seems to be on the POST data read. Here is the thread dump of interest (there are several identical ones in my full dump): [2009-05-13 15:49:50] [info] "http-1024-Processor11" [2009-05-13 15:49:50] [info] daemon [2009-05-13 15:49:50] [info] prio=6 tid=0x26c97858 [2009-05-13 15:49:50] [info] nid=0xe18 [2009-05-13 15:49:50] [info] runnable [2009-05-13 15:49:50] [info] [0x2761f000..0x2761fa64] [2009-05-13 15:49:50] [info] at java.net.SocketInputStream.socketRead0(Native Method) [2009-05-13 15:49:50] [info] at java.net.SocketInputStream.read(Unknown Source) [2009-05-13 15:49:50] [info] at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747) [2009-05-13 15:49:50] [info] at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777) [2009-05-13 15:49:50] [info] at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:115) [2009-05-13 15:49:50] [info] at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:712) [2009-05-13 15:49:50] [info] at org.apache.coyote.Request.doRead(Request.java:423) [2009-05-13 15:49:50] [info] at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:283) [2009-05-13 15:49:50] [info] at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:404) [2009-05-13 15:49:50] [info] at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:298) [2009-05-13 15:49:50] [info] at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:192) [2009-05-13 15:49:51] [info] at eddsrv.EddRcvr.processRequest(EddRcvr.java:198) [2009-05-13 15:49:51] [info] at eddsrv.EddRcvr.doPost(EddRcvr.java:99) [2009-05-13 15:49:51] [info] at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) [2009-05-13 15:49:51] [info] at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) [2009-05-13 15:49:51] [info] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) [2009-05-13 15:49:51] [info] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) [2009-05-13 15:49:51] [info] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) [2009-05-13 15:49:51] [info] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) [2009-05-13 15:49:51] [info] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667) [2009-05-13 15:49:51] [info] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) [2009-05-13 15:49:51] [info] at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) [2009-05-13 15:49:51] [info] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) [2009-05-13 15:49:51] [info] at java.lang.Thread.run(Unknown Source) [2009-05-13 15:49:51] [info] The line eddsrv.EddRcvr.processRequest(EddRcvr.java:198) points to my InputStream.read() line. All these variables are declared locally in the method doing the work, not at the class level, so there is no synchronization needed on them. This method is called from the doPost() method of the servlet class. Here are a few code lines for context setting: req is my HttpServletRequest iStream is a ServletInputStream Then I have: len = req.getContentLength(); b = new byte[ len ]; iStream = req.getInputStream(); /* this is the line 198 that the above thread dump is waiting for: */ strLen = iStream.read( b, 0, len ); iStream.close(); And then I convert b to a string and finish processing. Is there anything stupid I'm missing that would cause the .read() to be slow? Or is it just that my OS tcp/ip stack and/or network infrastructure appear to be slow? I did quite a bit of reading on InputStream performance, it couldn't find any suggestions to improve on what I've already got (the biggest one was to read the whole thing at once rather than byte-by-byte, and I'm already doing that). Thanks! Dave --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org