I am using apache2
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:
<Connector port="[port1]" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<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.