Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
Apache is on top of Apache? – mr.zog May 5 at 0:14

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

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

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

Your Answer


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.