1

I am using apache2 mod_proxy and mod_proxy_balancer to balance the load to 4 seperate tomcat8 instances on different servers. I am using different AJP ports for each tomcat instance and using jvmRoute directive in tomcat server.xml, like this: First instance:

<Connector port="[port1]" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

Second instance:

<Connector port="[port2]" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">

And so on.

In apache2 configuration, i define a cluster, like this:

<Proxy balancer://myCluster>
        BalancerMember ajp://[ip1]:[port1] route=tomcat1 loadfactor=1
        BalancerMember ajp://[ip2]:[port2] route=tomcat2 loadfactor=1
        BalancerMember ajp://[ip3]:[port3] route=tomcat3 loadfactor=1
        BalancerMember ajp://[ip4]:[port4] route=tomcat4 loadfactor=1

        ProxySet lbmethod=bybusyness
        ProxySet stickysession=JSESSIONID

        Order Deny,Allow
        Deny from none
        Allow from all
 </Proxy>

And the proxypass directives:

ProxyPass / balancer://myCluster/
ProxyPassReverse / balancer://myCluster/
...

It works as expected, does load balancing as it should, and if a Tomcat instance is down, load blaancer does not redirect to that instance. Everything is working well until this point.

But the problem is, when I trigger deployment on the tomcat instances, I stop them one by one, upload the new artifact and restart the instance. But the load balancer redirects the the tomcat instance even before web application artifacts get deployed, initialized and get ready. So, the user faces blank screen if he makes a request to an URL which is not ready yet.

How can I handle that situation to prevent redirection until web application is completely ready? How can I check the status of them?

Any help is much appreciated.

1

Probably the best approach is to build a kind of status servlet that knows how to check if your desired context (war) is fully operational and utilize failonstatus directive.

Another option is to use http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html#balancer_manager in your deployment. Steps being:

  • Disable a worker
  • deploy
  • Wait for it to be up/check
  • Enable worker
|improve this answer|||||

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.