0

We have developed an application where after a successful request, session has to be destroyed. This is working fine, when we have a single tomcat.

But, this is not happening when we use multiple tomcats under Apache simple load balancer (We are using Load Balancer, for balancing the requests between two tomcats, which are hosting the same application).

The SessionID that is created and have processed successfully, can be used for one more transaction, after which it is getting killed.

Moreover, the SessionID value is being appended with either 'n1' or 'n2' (SessionID-n1). I am not sure of why is this happening.

Please help me to resolve this issue.

We have a configuration setup as below:

         Load Balancer
        /           \
    Cluster1      Cluster2
       |             |
    Tomcat1       Tomcat2

Thanks, Sandeep

user3119077
  • 189
  • 1
  • 1
  • 5

1 Answers1

0

If you have configured each Tomcat node to have a "jvmRoute", then the string you specify there will be appended to the session identifier. This can help your load-balancer determine which back-end server should be used to serve a particular request. It sounds like this is exactly what you have done. Check your CATALINA_BASE/conf/server.xml file for the word "jvmRoute" to confirm.

If you only use a session for a single transaction, why are you bothering to create the session in the first place? Is a request == transaction?

If you are sure you are terminating the session when the transaction is complete, you should be okay even if the client wants to try to make a new request with the same session id. It will no longer be valid and therefore useless to the client.

It's not clear from your question whether there is an actual problem with the session because you claim it is "getting killed" which sounds like what you want it to do. If you provide more detail on the session expiration thing, I'll modify my answer accordingly.

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77