Grails httpsession
Is it possible to store Grails session in Database? After starting a load balancer my app randomly asks users to login (almost on every other webpage redirection). I know I can enable sticky sessions but I have seen it with rails th开发者_StackOverflow社区at sessions can be saved in db so there would be no problems in multi server environments.
Typically the database is the hardest part of an app to scale. It's pretty easy to horizontally scale by adding more web servers, but you usually vertically scale the database. So it doesn't make much sense to add more work to your database by storing sessions there in addition to your real application data.
See this blog post for a simple way to cluster Grails in multiple Tomcat servers and enable session replication: http://www.tomcatexpert.com/blog/2010/07/20/basic-tomcat-clustering-grails-applications
Terracotta might allow you do that (I haven't used it so I don't know it's mechanism for sharing between servers). There is a Terracotta plugin for Grails, which is suggested here.
精彩评论