1

I am working on a task in which I have to load-balance two tomcat-instances such that they share a common session also amongst themselves and when one goes down, the other one can handle the task.

The first task seems to work as when both the Tomcat versions are online, then there seems to be no problem.

I don't know how to detect which user is from which tomcat, so I can see if an user from other tomcat is live in chat, then session-id is properly shared.

The second problem I am facing is, if one tomcat goes down, the other tomcat instance should keep running and serve the requests being made, but that is not happening. As soon as any one Apache tomcat instance goes down, I get a 503, service not available. Kindly let me know how I can fix this problem and test which user is from which tomcat instance. Changes made : sites-enabled/000-default :

<Proxy balancer://mycluster>
    BalancerMember ajp://localhost:8010 route=jvmroute-first connectiontimeout=10
    BalancerMember ajp://localhost:8011 route=jvmroute-second connectiontimeout=10

   ProxySet stickysession=JSESSIONID

   Order Deny,Allow
   Deny from none
   Allow from all

</Proxy>

<VirtualHost *:80>
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
</VirtualHost>

First tomcat's server.xml :

<Connector port="8080" proxyPort="80" protocol="HTTP/1.1" compression="force" compressionMinSize="1024" 
               connectionTimeout="20000"
               redirectPort="443" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"/>


<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="200" compression="force"
              compressionMinSize="1024" scheme="https" secure="true" clientAuth="false"  sslProtocol="TLS"
                keystoreFile="keystore" keystorePass="password" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>

 <Connector port="8010" protocol="AJP/1.3" redirectPort="443" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvmroute-first">
// No modifications within Engine
</Engine>

Second tomcat instance :

<Connector port="8081" proxyPort="80" protocol="HTTP/1.1" compression="force" compressionMinSize="1024" 
               connectionTimeout="20000"
               redirectPort="443" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"/>


<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="200" compression="force"
              compressionMinSize="1024" scheme="https" secure="true" clientAuth="false"  sslProtocol="TLS"
                keystoreFile="keystore.jks" keystorePass="password" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>
<Connector port="8011" protocol="AJP/1.3" redirectPort="443" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>

Why is this happening. Any ideas, clues. Thanks a lot. :-)

Edit

There seems to be something wrong with load-balancer, as I get the Err after sometime, check the screenshot

enter image description here

0

This might happening because you do not have session replication enabled on Tomcat end. Since sticky session is enabled on Apache, Requests are always routed based on the check of JSESSIONID.

Implement clustering in Tomcat instances with Failover so that any failed request will be rerouted to second tomcat server upon failure.

8
  • Any thoughts on how I can add it in this one. Kindly let me know. Thank you. – We are Borg Dec 9 '15 at 12:48
  • What's your tomcat version?. There are many online howtos are available to do this. – serverliving.com Dec 9 '15 at 12:49
  • Tomcat 7.0.57. There is something wrong with load-balancer I guess, as the worker is in error. Can you check the screenshot I just added in main post. Thank you. – We are Borg Dec 9 '15 at 12:50
  • I agree, I am searching for such a thing, but I cannot find an integrated solution which fulfils the requriement, that's why. – We are Borg Dec 9 '15 at 12:52
  • I dont see Engine tag enabled on second tomcat instance. Have you added that second JvmRoute value?. – serverliving.com Dec 9 '15 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.