Reputation: 56912
I'm deploying my Grails (2.3.6) app with the Grails Standalone App Runner plugin, like so:
grails -Dgrails.env=prod build-standalone myapp.jar --tomcat
Then, my CI build places myapp.jar
onto my app server, say, myapp01
.
I now want to cluster app sessions when myapp
is running on multiple nodes. So if myapp
gets deployed to myapp01
, myapp02
and myapp03
, and one of those instances starts a new session with a user, I want all 3 to be aware of the same session. This is obviously so I can put all the nodes behind a load balanced URL (http://myapp.example.com
, etc.) and it doesn't matter what node you get routed to: all nodes share the same sessions.
I googled "grails session clustering" and see a bunch of articles that seem to require terracotta, but I also heard that Grails has built-in session clustering facilities. But any searches I do come back empty-handed.
So I ask: How can I achieve this kind of session clustering with an embedded Tomcat?
Upvotes: 0
Views: 1827
Reputation: 11
You could achieve this by using the tomcat build-in functionality. Tomcat instance node could replicate session from others, then all the session get shared between nodes. You can do this in at least three ways:
Reference:
http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html http://khaidoan.wikidot.com/tomcat-cluster-session-replication
Upvotes: 0
Reputation: 111
Besides the seesion-cookie plugin that @injecteer proposed, there are several other plugins allowing to keep sessions in a shared storage (DB, mongodb, redis, memcached) that can be accessed by any of your tomcat instances. Take a look at these:
Upvotes: 2
Reputation: 20699
I never heard of something like this out-of-box. I would give 2 options a try:
Upvotes: 1