You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Harper <br...@smartsheet.com> on 2009/06/12 00:22:37 UTC

Periodic slow response to initial call to HttpServletRequest.getParameter()

I've been trying to locate the source of an issue we've encountered
periodically, and am hoping to find some enlightenment here. The issue
is that we're seeing periodic slow responses - in some cases as long as
30-40 seconds for servlet requests that normally come in well under a
second. In troubleshooting the problem, I've traced the source to the
first time that our servlet makes a call to getParameter on the
HttpServletRequest. Our servlet often handles very large - as much as
1MB or so - post requests, with a great deal of JSON form data being
passed up from the client. Even so, it doesn't seem like parsing the
request should take anywhere this long. 

Some background:
- We're using Tomcat 5.5.26 fronted by Apache 2.0 using the mod_jk
connector.
- We have multiple Tomcat instances in our cluster, but the slow
responses occur on each of them with roughly the same frequency.
- Requests are via SSL, with the SSL handshake handled by a load
balancer.
- The slow requests are all POST requests
- Requests are all handled by a single servlet

Questions:
1. When is my servlet instantiated by Tomcat and its doPost method
called? Does this happen before the entire body of the request has been
received? In which case perhaps the delays are simply due to slow client
connections?
2. What is Tomcat doing when the first call to getParameter is made?
What kind of parsing does it have to do to respond?
3. Any ideas why we'd see such long response times on occasion, but not
consistently? If it had something to do with the Apache or mod_jk
config, I'd have expected that the request wouldn't have been hanging on
the getParameter call, it would have been hung up before my servlet was
ever invoked.

Any help would be greatly appreciated. 

Thanks,
Brian Harper


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Periodic slow response to initial call to HttpServletRequest.getParameter()

Posted by Martin Gainty <mg...@hotmail.com>.
quite possible the Session timed out so you should check 
socket_connect_timeout for timeout related to the socket
connection_pool_size for how many connections are in the pool
connectionTimeout the number of ms the connector will wait after accepting a connection for request URI to present

default is 60 seconds

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Mon, 6 Jul 2009 16:38:47 -0700
> From: mcox@tripadvisor.com
> To: users@tomcat.apache.org
> Subject: Re: Periodic slow response to initial call to HttpServletRequest.getParameter()
> 
> 
> I'm investigating the same type of issue with very similar symptoms. It's
> always a POST but when the call to getParamter finally returns there are no
> parameters. 
> 
> 
> -- 
> View this message in context: http://www.nabble.com/Periodic-slow-response-to-initial-call-to-HttpServletRequest.getParameter%28%29-tp23989988p24364728.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
Insert movie times and more without leaving Hotmail®. 
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009

Re: Periodic slow response to initial call to HttpServletRequest.getParameter()

Posted by mcoxta <mc...@tripadvisor.com>.
I'm investigating the same type of issue with very similar symptoms. It's
always a POST but when the call to getParamter finally returns there are no
parameters. 


-- 
View this message in context: http://www.nabble.com/Periodic-slow-response-to-initial-call-to-HttpServletRequest.getParameter%28%29-tp23989988p24364728.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Periodic slow response to initial call to HttpServletRequest.getParameter()

Posted by Bill Barker <wb...@wilshire.com>.
"Mark Thomas" <ma...@apache.org> wrote in message 
news:4A31874F.8040708@apache.org...
> Brian Harper wrote:
>> Questions:
>> 1. When is my servlet instantiated by Tomcat and its doPost method
>> called?
> Once the headers have been received and Tomcat can map the request.
>

But it is instantiated only for the first request, unless it specifies 
load-on-startup, then it is instantiated when the webapp is loaded.

>> Does this happen before the entire body of the request has been
>> received?
> Yes.
>
>> In which case perhaps the delays are simply due to slow client
>> connections?
> Maybe.
>
>> 2. What is Tomcat doing when the first call to getParameter is made?
>> What kind of parsing does it have to do to respond?
> It has to read all of the POST body and parse it.
>
>> 3. Any ideas why we'd see such long response times on occasion, but not
>> consistently?
> Slow clients is one option. Clients that specify an invalid content
> length could be another. Tomcat might be hanging around waiting for the
> extra data that never arrives. Eventually a time-out kicks in. I'd need
> to check the source to see exactly how this is handled. I can't remember
> if Tomcat abandons the request, ignores the missing data or does
> something else.
>

Using AJP, the handling of the content-length is done by httpd.  Unless it 
is so slow that the connectionTimeout kicks in, Tomcat won't timeout on 
reading the body (but httpd probably will).  But, this isn't a 
content-length issue (I looked at the code), since what would happen then is 
that no POST parameters would be available.  Also, the AJP/1.3 protocol 
tells mod_jk/mod_proxy_ajp to send the (by default) first 8Kb of the body to 
Tomcat without Tomcat asking.  So, unless the body is really big, the gap is 
probably between the client and httpd.

But to do more than guess, the OP would need to follow Rainer's suggestion, 
and provide DEBUG level logs.
> Mark 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Periodic slow response to initial call to HttpServletRequest.getParameter()

Posted by Mark Thomas <ma...@apache.org>.
Brian Harper wrote:
> Questions:
> 1. When is my servlet instantiated by Tomcat and its doPost method
> called?
Once the headers have been received and Tomcat can map the request.

> Does this happen before the entire body of the request has been
> received?
Yes.

> In which case perhaps the delays are simply due to slow client
> connections?
Maybe.

> 2. What is Tomcat doing when the first call to getParameter is made?
> What kind of parsing does it have to do to respond?
It has to read all of the POST body and parse it.

> 3. Any ideas why we'd see such long response times on occasion, but not
> consistently?
Slow clients is one option. Clients that specify an invalid content
length could be another. Tomcat might be hanging around waiting for the
extra data that never arrives. Eventually a time-out kicks in. I'd need
to check the source to see exactly how this is handled. I can't remember
if Tomcat abandons the request, ignores the missing data or does
something else.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Periodic slow response to initial call to HttpServletRequest.getParameter()

Posted by Rainer Jung <ra...@kippdata.de>.
On 12.06.2009 00:22, Brian Harper wrote:
> I've been trying to locate the source of an issue we've encountered
> periodically, and am hoping to find some enlightenment here. The issue
> is that we're seeing periodic slow responses - in some cases as long as
> 30-40 seconds for servlet requests that normally come in well under a
> second. In troubleshooting the problem, I've traced the source to the
> first time that our servlet makes a call to getParameter on the
> HttpServletRequest. Our servlet often handles very large - as much as
> 1MB or so - post requests, with a great deal of JSON form data being
> passed up from the client. Even so, it doesn't seem like parsing the
> request should take anywhere this long. 
> 
> Some background:
> - We're using Tomcat 5.5.26 fronted by Apache 2.0 using the mod_jk
> connector.
> - We have multiple Tomcat instances in our cluster, but the slow
> responses occur on each of them with roughly the same frequency.
> - Requests are via SSL, with the SSL handshake handled by a load
> balancer.
> - The slow requests are all POST requests
> - Requests are all handled by a single servlet
> 
> Questions:
> 1. When is my servlet instantiated by Tomcat and its doPost method
> called? Does this happen before the entire body of the request has been
> received? In which case perhaps the delays are simply due to slow client
> connections?
> 2. What is Tomcat doing when the first call to getParameter is made?
> What kind of parsing does it have to do to respond?
> 3. Any ideas why we'd see such long response times on occasion, but not
> consistently? If it had something to do with the Apache or mod_jk
> config, I'd have expected that the request wouldn't have been hanging on
> the getParameter call, it would have been hung up before my servlet was
> ever invoked.
> 
> Any help would be greatly appreciated. 

If you can reproduce on a test system, or your site is low traffic, you
could set JkLogLevel to debug. Thsi will log all packets forwarded
betwenn httpd and Tomcat, so you might get an idea, whether the pause
happens inside Tomcat/your webapp or maybe between client and httpd.
Beware that JkLogLevel debug will produce huge amounts of output.

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org