http sessions stats anamoly

546 views
Skip to first unread message

Philip Newlon

unread,
May 21, 2013, 8:48:22 AM5/21/13
to javam...@googlegroups.com
Our Tomcat server listens on port 8080.  We have ~900 client devices that check in with the server once a minute.

JavaMelody http session stats (1 week) indicate that there is a continuous average of 50,000 alive http sessions.  I sampled connections reported by netstat at 15 second intervals for two days and found that there was an average of 32 open connections at any time (max 43).  I put a sniffer on a conversation and found that the connection lasted 205ms, ending in a TCP RESET from the client thus actively terminating the http session.  When I looked at 'active http sessions' in JavaMelody a few moments ago, there were 32,700 alive sessions.  All sessions had the same 'last access' and 'age' indicating to me that what I am seeing with a sniffer is correct - the client opens the session, does its thing, then terminates and never talks again on that connection.

- what constitutes an http session to JavaMelody?
- if a client actively disconnects a session with a TCP RESET, why would the session appear to remain alive in JavaMelody stats?
- what terminates the reported session except time?
- is this discrepancy (50,000 alive sessions versus 32 TCP connections) a JavaMelody-ism or Tomcat-ism?

Thanks!  Phil


10.2.19.167 is the client, 10.255.208.44 is the Tomcat server

No.     Time        Source                Destination           Protocol Length Info
   2397 998.594470  10.2.19.167           10.255.208.44         TCP      66     50672 > http-alt [SYN] Seq=0 Win=8192 Len=0 MSS=1372 WS=4 SACK_PERM=1
   2398 998.594629  10.255.208.44         10.2.19.167           TCP      66     http-alt > 50672 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1
   2401 998.664711  10.2.19.167           10.255.208.44         TCP      60     50672 > http-alt [ACK] Seq=1 Ack=1 Win=65856 Len=0
   2402 998.671359  10.2.19.167           10.255.208.44         TCP      357    [TCP segment of a reassembled PDU]
   2403 998.678004  10.2.19.167           10.255.208.44         HTTP/XML 883    POST /ContentManager/services/MonitorService HTTP/1.1 
   2404 998.678162  10.255.208.44         10.2.19.167           TCP      54     http-alt > 50672 [ACK] Seq=1 Ack=1133 Win=65792 Len=0
   2405 998.688297  10.255.208.44         10.2.19.167           TCP      1310   [TCP segment of a reassembled PDU]
   2406 998.691732  10.255.208.44         10.2.19.167           HTTP/XML 59     HTTP/1.1 200 OK 
   2416 998.782035  10.2.19.167           10.255.208.44         TCP      60     50672 > http-alt [ACK] Seq=1133 Ack=1262 Win=64592 Len=0
   2420 998.799586  10.2.19.167           10.255.208.44         TCP      60     50672 > http-alt [RST, ACK] Seq=1133 Ack=1262 Win=0 Len=0

Vernat Emeric

unread,
May 23, 2013, 10:32:09 AM5/23/13
to javam...@googlegroups.com
Hi Phil,

Answers below.

Le 21/05/2013 14:48, Philip Newlon a �crit :
> Our Tomcat server listens on port 8080. We have ~900 client devices
> that check in with the server once a minute.
>
> JavaMelody http session stats (1 week) indicate that there is a
> continuous average of 50,000 alive http sessions. I sampled
> connections reported by netstat at 15 second intervals for two days
> and found that there was an average of 32 open connections at any time
> (max 43). I put a sniffer on a conversation and found that the
> connection lasted 205ms, ending in a TCP RESET from the client thus
> actively terminating the http session. When I looked at 'active http
> sessions' in JavaMelody a few moments ago, there were 32,700 alive
> sessions. All sessions had the same 'last access' and 'age'
> indicating to me that what I am seeing with a sniffer is correct - the
> client opens the session, does its thing, then terminates and never
> talks again on that connection.
>
> - what constitutes an http session to JavaMelody?
This is an http session as in JavaEE Servlet API:
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSession.html
Http sessions are created by your webapp, when one the two getSession
methods is called for an http request:
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getSession%28boolean%29

> - if a client actively disconnects a session with a TCP RESET, why
> would the session appear to remain alive in JavaMelody stats?
Http sessions in servlet api are invalidated by some logout action or by
a timeout (30 minutes typically), not by TCP RESET.

> - what terminates the reported session except time?
Except waiting for the timeout, your webapp can call invalidate on each
http session, or ... see next:
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSession.html#invalidate%28%29

> - is this discrepancy (50,000 alive sessions versus 32 TCP
> connections) a JavaMelody-ism or Tomcat-ism?
>
Neither of the two, your webapp should probably call
HttpSession.invalidate(), or better it should not create any http
session for stateless requests.
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "javamelody" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to javamelody+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


Reply all
Reply to author
Forward
0 new messages