简体   繁体   中英

To use apache as load balancer with sticky session - Need sticky session based load balancing

I am using apache as LB with sticky session handling (using 2 tomcats as balancer member).

Below are config. done by me at apache level -

<Proxy balancer://mycluster>
    (...)
    ProxySet stickysession=JSESSIONID
    BalancerMember http://{ip/hostname of tomcat1 backed:port} route=tomcat1
    BalancerMember http://{ip/hostname of tomcat2 backed:port} route=tomcat2
</Proxy>

ProxyPass        /     “balancer://mycluster”
PorxyPassReverse /     “balancer://mycluster”

Defining jvm route at tomcat level -

(...)
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">         ##where the jvmroute should be the route value set at apache config.
(...)

same is been defined for tomcat 2 also

(...)
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">         ##where the jvmroute should be the route value set at apache config.
    (...)

Everything works fine, but the main drawback of this setup is if tomcat1 goes down then session sticked to tomcat1 also dies and doesn't route to tomcat2.

Is there any way to replicate sticky session to tomcat2 also, or simply if tomcat1 dies then session is been transferred to tomcat2 & vice-versa?

Use of "sticky sessions" is only a mechanism to ensure that all requests for the same session go to the same node when multiple nodes could possibly be used. If you want session fail-over, you need Clustering .

There are many guides for how to do clustering with Tomcat. There are also several presentations on Tomcat's Presentations Page for background on how clustering works and how to configure it.

Note that you may have to make some changes to your application in order for clustering to work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM