0

Here is my problem: I have 3 Tomcat 7.0.x servers, and 2 Apache 2.2.x HTTPd servers, see the image. (All servers are running Linux Redhat 6.2.)

enter image description here

So I have load balancing setup between Tomcat 1/2, and house some small Micro-service on Tomcat 3, and not load balanced. At the Apaches I'm using round robin with sticky sessions, and mod_proxy_ajp to the Tomcat nodes.

<Virtual *:80>
   Header Add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

   <Proxy balancer://t-ha-cluster>
     ProxySet lbmethod=byrequest
     BalancerMember ajp://tomcat1:8109 route=jvm-tc-1 connectiontimeout=400ms retry=60 ping=5
     BalancerMember ajp://tomcat2:8109 route=jvm-tc-2 connectiontimeout=400ms retry=60 ping=5
     ProxySet stickysession=ROUTEID
   </Proxy>

   <Proxy balancer://t-micro-cluster>
     ProxySet lbmethod=byrequest
     BalancerMember ajp://tomcat3:8109 route=jvm-tc-3 connectiontimeout=400ms retry=60 ping=5
     ProxySet stickysession=ROUTEID
   </Proxy>

   <Location /app1>
     ProxyPass balancer://t-ha-cluster/myapp stickysession=ROUTEID
     ProxyPassReverse stickysession=ROUTEID
   </Location>

   <Location /app2>
     ProxyPass balancer://t-ha-cluster/myapp stickysession=ROUTEID
     ProxyPassReverse stickysession=ROUTEID
   </Location>

   <Location /search>
     ProxyPass balancer://t-micro-cluster/myapp stickysession=ROUTEID
     ProxyPassReverse stickysession=ROUTEID
   </Location>

</Virtual>

Now when I go to /app1 a ROUTEID=.jvm-tc-2 is created, and session is created on Tomcat 2 server. On the page load it fetches small search widget from /search on Tomcat 3, which changes my ROUTEID=.jvm-tc-3. Then the next request fetches resources from /app, I get ROUTEID=.jvm-tc-1. So now a new session is created on Tomcat 1 node. Is there a better way of writing my Apache configuration, so that the user stays on Tomcat 2 the entire time? And is there a way to make it reusable for other applications as we expand our app stack?

I would rather not keep ROUTEIDs per /appx context, since that would start to be maintenance nightmare.

3
  • Do you really need the routeid for the third tomcat ? As it's only a single server, I don't think it's really relevant to keep it (or maybe you're planning to add more later). Actually a sticky session is not required in that case I think because it will always reach server tomcat3 for the /search, you don't need the balancer. Dec 11, 2015 at 15:42
  • @pat That's interesting. I guess I didn't look at it that way. I was so focused on solving the problem with the ROUTEID. Let me prove that out. Thanks
    – jtoepfer
    Dec 11, 2015 at 16:05
  • so ? what happened ? Dec 14, 2015 at 20:30

0

You must log in to answer this question.

Browse other questions tagged .