You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by cr...@thetimmermans.net on 2009/07/23 16:10:04 UTC

Logging servlet time and connections

Hello,

    I need to log incoming connections to tomcat (when connected, then
disconnected), as well as the servlet it's running.  I am trying to
find out information on how long its taking to process our servlet as
well as how long connections may be queued.   Is there anything I can
turn on in tomcat to find out this information?

I haven't been able to find a reference to this anywhere.

Thanks,

Craig


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


RE: Logging servlet time and connections

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jess Holle [mailto:jessh@ptc.com]
> Subject: Re: Logging servlet time and connections
> 
> In this scenario once you exceed maxThread minus 2 simultaneous
> connections (there's a clear off by 2 error here somewhere) any
> additional simultaneous connections go into some sort of weird
> limbo, are never processed, and eventually time out.

That would be expected, since AJP connections are intended to be persistent.  Once the max connections have been established, Tomcat gets no indication that more are needed, since that's all handled by the TCP/IP stack, not Tomcat or the JVM.  The "weird limbo" is likely just the normal TCP/IP accept queue.  (There's no timeout limit for that queue - the server is expected to do accepts within a "reasonable" amount of time and get the connection requests off the queue; TCP clients can specify a timeout for the request.)  It's extremely important to have compatible configurations for Tomcat and httpd when using AJP.

> This is irrespective of the value of acceptCount used, which is simply
> ignored in this case!

It's not ignored - incoming requests that would exceed the acceptCount are refused; some server TCP/IP stacks send an RST back when the accept queue is full, some just silently discard the SYN.  Tomcat has no way of finding out that refusals happened.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Logging servlet time and connections

Posted by Jess Holle <je...@ptc.com>.
Beware of acceptCount.

If you use this with the AJP connector and don't enable the native 
connector, then you won't get what you expect -- and last I checked the 
documentation gave no warning of this.

In this scenario once you exceed maxThread minus 2 simultaneous 
connections (there's a clear off by 2 error here somewhere) any 
additional simultaneous connections go into some sort of weird limbo, 
are never processed, and eventually time out.  This is irrespective of 
the value of acceptCount used, which is simply ignored in this case!  
You'd /expect/ a warning to be logged if acceptCount is non-zero and is 
simply going to be ignored.  You'd also expect 503's for requests that 
are not going to be handled -- not this weird limbo thing.

Overall this is a pretty big gotcha -- especially for those of us 
supporting enough odd ball platforms that continuously building the 
native connector for all of these platforms is a non-starter.  [One 
might say just build it once, but we've also had issues with the native 
connector that are not reproducible with the pure-Java connector.]

This has to be one of the ugliest Tomcat warts I've ever run into.

--
Jess Holle

Caldarale, Charles R wrote:
>> From: craig@thetimmermans.net [mailto:craig@thetimmermans.net]
>> Subject: RE: Logging servlet time and connections
>>
>> It could be user sessions if thats whats available.
>>     
> You can implement an HttpSessionListener to track sessions coming and going within a webapp.  See the servlet spec for details
>> Basically the acceptCount for the connector is much higher 
>> than the maxThread count.
>>     
> The two values are unrelated, so one being higher than the other is irrelevant.  Tomcat just passes the acceptCount to the TCP/IP stack, and has no means of examining what the TCP/IP stack does with it
>> So some connections are being held (queued?) without processing.
>>     
> Are you sure?  Regardless, such information is not available to Tomcat, but it /may/ be available from your OS
>> No, just when the servlet starts processing and when its complete
>> (we do know the exact servlet we are worried about).
>>     
> It's probably easiest to add logging to the particular servlet to get that specific information.  Once the logging calls are added, you can control whether or not they are recorded by manipulating conf/logging.properties.
>
> You may be able to get Tomcat to display such fine-grained detail, but it would likely require setting a logging level of DEBUG, which would get way too much data written and be a performance problem.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>   

RE: Logging servlet time and connections

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: craig@thetimmermans.net [mailto:craig@thetimmermans.net]
> Subject: RE: Logging servlet time and connections
> 
> It could be user sessions if thats whats available.

You can implement an HttpSessionListener to track sessions coming and going within a webapp.  See the servlet spec for details.

> Basically the acceptCount for the connector is much higher 
> than the maxThread count.

The two values are unrelated, so one being higher than the other is irrelevant.  Tomcat just passes the acceptCount to the TCP/IP stack, and has no means of examining what the TCP/IP stack does with it.

> So some connections are being held (queued?) without processing.

Are you sure?  Regardless, such information is not available to Tomcat, but it /may/ be available from your OS.

> No, just when the servlet starts processing and when its complete
> (we do know the exact servlet we are worried about).

It's probably easiest to add logging to the particular servlet to get that specific information.  Once the logging calls are added, you can control whether or not they are recorded by manipulating conf/logging.properties.

You may be able to get Tomcat to display such fine-grained detail, but it would likely require setting a logging level of DEBUG, which would get way too much data written and be a performance problem.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Logging servlet time and connections

Posted by cr...@thetimmermans.net.
Sorry, the Tomcat version is 5.5.  See below...

Quoting "Caldarale, Charles R" <Ch...@unisys.com>:

>> From: craig@thetimmermans.net [mailto:craig@thetimmermans.net]
>> Subject: Logging servlet time and connections
>>
>> I need to log incoming connections to tomcat
>
> What you really need to do is tell us the version of Tomcat you're   
> using.  Since you didn't, this response pertains to the current   
> version (6.0.20).
>
>> (when connected, then disconnected),
>
> Are you referring to the TCP connection?  Or the user session?

It could be user sessions if thats whats available.  Basically the  
acceptCount for the connector is much higher than the maxThread count.  
  So some connections are being held (queued?) without processing.  We  
would like to know when this is happening and for how long (if  
possible).

>
>> as well as the servlet it's running.
>
> A request may pass through many servlets (and filters) before   
> completion.  Do you want to know each one?  If so, you'll need to   
> implement some logging in your webapp.

No, just when the servlet starts processing and when its complete (we  
do know the exact servlet we are worried about).  Ideally we would  
have had debug logging in the servlet, but the one we are looking at  
does not contain that information so we were hoping tomcat has  
something we can turn on that would tell us when "doPost" is called  
and when its completed.

>
>> I am trying to find out information on how long its taking to
>> process our servlet
>
> Start with the AccessLogValve:
> http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access%20Log%20Valve
>
>> as well as how long connections may be queued.
>
> If you're referring to queuing for an actual TCP connection, that's   
> not visible to Tomcat.  It's done by the OS in its TCP/IP stack, and  
>  monitoring of that is OS specific - and you didn't tell us what   
> you're using.

See the comment about the accept count above.

Thanks,

Craig

>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE   
> PROPRIETARY MATERIAL and is thus for use only by the intended   
> recipient. If you received this in error, please contact the sender   
> and delete the e-mail and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>




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


RE: Logging servlet time and connections

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: craig@thetimmermans.net [mailto:craig@thetimmermans.net]
> Subject: Logging servlet time and connections
> 
> I need to log incoming connections to tomcat

What you really need to do is tell us the version of Tomcat you're using.  Since you didn't, this response pertains to the current version (6.0.20).

> (when connected, then disconnected),

Are you referring to the TCP connection?  Or the user session?

> as well as the servlet it's running.

A request may pass through many servlets (and filters) before completion.  Do you want to know each one?  If so, you'll need to implement some logging in your webapp.

> I am trying to find out information on how long its taking to 
> process our servlet

Start with the AccessLogValve:
http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access%20Log%20Valve

> as well as how long connections may be queued.

If you're referring to queuing for an actual TCP connection, that's not visible to Tomcat.  It's done by the OS in its TCP/IP stack, and monitoring of that is OS specific - and you didn't tell us what you're using.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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