Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a setup of several Tomcat servers distributed between a few servers, all running the same thing. Apache is on top of Apache and a loadbalancer in front of the Apache servers. I want to cluster the Tomcats using Shared Session to minimize downtime and user interruption while deploying apps.

I know clustering works within the same server but is it possible to setup Tomcat in a way that it shares sessions between servers on different machines?

=> Server 1
==> Apache 1
===> Tomcat 1

=> Server 2
==> Apache 2
===> Tomcat 2

When Server/Tomcat 1 would be taken down, users and their sessions would transfer over to Server/Tomcat 2 and vice versa.

share|improve this question
add comment

3 Answers 3

You can save sessions in memcached, which is shared between both servers. This should give better performance and scalability than using shared sessions in a database, or a shared directory between n servers.

share|improve this answer
add comment

Take a look at Teracotta for web sessions.

Use Terracotta's fast, reliable web sessions plugin to get the scalability benefits of a stateless web architecture without overloading your database or rewriting your application. Terracotta for Sessions works with your favorite web framework and your own custom session objects.

The web sessions tutorial lists five simple steps for you to make in order to evaluate the product ( FOSS ).

share|improve this answer
    
Last time I looked.. Terracotta was damn expensive.. At least memcached is free. –  Tom O'Connor Aug 1 '10 at 22:55
    
@Tom : as stated in my answer, there is a FOSS version of Teracotta. If that does not suite your needs, you might want to look into the commercial version. But it's not mandatory. –  Robert Munteanu Aug 2 '10 at 20:28
    
I've looked into Terracotta before, Last time, the FOSS version didn't have the required product. –  Tom O'Connor Aug 2 '10 at 22:03
add comment

You can save sessions in database, so they are accesible from both tomcats. Or store them over a shared directory between tomcats.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.