0

is it possible to replicate the mod_jk sticky session information to another apache for an failover setup?

the idea behind the question is to setup two apaches with sticky sessions in front off some tomcats. when one apaches fails, the other one should take over the mod_jk session information so he knows which requests to serve to what tomcat.

i know an alternative would be session replication at the tomcat level and not to use sticky sessions, but this is not possible at the moment.

Christian
  • 4,703
  • 2
  • 24
  • 27

2 Answers2

2

If your backend servers (tomcat) are clustered, they should replicate sessions too. In the event of an http failure, connections to 1 http node should go to another node. The jsessionid parameter should give the http / mod_jk enough info to know which node to route to (e.g. jsessionid=lkj234lkj2ljk234lj.jvmRoute1 will tell mod_jk that this session is due for the worker with name jvmRoute1). In the event that the specified worker is unavailable, mod_jk should route to the next worker, which should retrieve the sesison from the cache.

i.e. replication is not needed between httpd servers, as the client-side cookie or URL containing jsessionid contains the routing information.

Brett Cave
  • 36
  • 2
0

There should be no need to replicate anything between apache nodes, because mod_jk's session persistence is working stateless.

You need to set jvmRoute in Tomcat's server.xml and it has to match the name of your jk workers, used by the balancer in mod_jk.

powo
  • 356
  • 2
  • 6
  • how can it be stateless? there must be some type of storage for the information sessionid xyz goes to jvmRoute1 and sessionid abc goes to jvmRoute3 and so on. i want to replicate this information between apaches. so in the case of a failover the second apache knows where to send the clients. – Christian Jun 23 '10 at 08:51
  • Tomcat appends the configured jvmRoute (for example the node-name) to the JSESSIONID, so this information is sent within the cookie in each request. Apache/mod_jk extracts this information and sends the request to the right backend node. – powo Nov 23 '10 at 22:53