Terracotta is an infrastructure that allows you to pretty much transparently cluster any code in a jvm. We’ve already successfully used it to cluster the channels in Jetty’s Bayeux (aka Cometd) implementation, so we thought it was high time we used it to cluster HTTP sessions.

Jetty already has a WADI-based solution for HTTP session clustering, so providing a terracotta-based solution provides an alternative for users to be able to choose the most appropriate solution for their needs.

The code is hot-off-the-press, so thus requires a little more polishing and testing, however it’s ready to try out, so give it a spin. Here’s the instructions:

Building

  1. There are some changes to Jetty that have not yet been incorporated into trunk, so first you’ll need to check out this branch:

    https://svn.codehaus.org/jetty/jetty/branches/terracotta.
    

    Build it with:

    mvn clean install
    

    I’ll refer to the location where you’ve done the checkout as $JETTY-BRANCH.

  2. Check out the session clustering code from the jetty-contrib repo at:

    https://svn.codehaus.org/jetty-contrib/jetty/trunk/extras/terracotta. 

    Build it with:

    mvn clean install
    
    I'll refer to the location where you've done the checkout as $TC_EXTRAS.
    

  3. Copy the terracotta-sessions-6.1-SNAPSHOT.jar you just built into $JETTY-BRANCH/lib/ext.

  4. Check out terracotta trunk from:
    http://svn.terracotta.org/svn/tc/dso/trunk
    

    Follow the instructions on the terracotta site to build it and produce a bootjar. I'll refer to the root of the build results (usually in code/base/build/) as $TC-BUILD.

Configuration

  1. You can setup all your webapps to use terracotta-based session clustering by copying the example jetty config file in $TC-EXTRAS/src/main/resources/jetty.xml to your $JETTY-BRANCH/etc/ directory.
  2. You might want to copy the example webapps from $TC-BUILD/dist/terracotta-trunk/samples/sessions into $JETTY-BRANCH/webapps to play with.

Running

Start the terracotta server:

$TC-BUILD/dist/terracotta-trunk/bin/start-tc-server.sh
-f $TC-EXTRAS/src/main/resources/tc-config-jetty.xml

Start jetty:

cd $JETTY-BRANCH
java -Dtc.install-root=$TC_BUILD/dist/terracotta-trunk/
-Xbootclasspath/p:[path to your boot jar]
-Dtc.config=$TC-EXTRAS/src/main/resources/tc-config-jetty.xml
-jar start.jar
etc/jetty.xml

Job done!

Any webapps you deployed should have their session instances clustered. Don't forget, you'll need to start more than one jetty instance in order to see session clustering actually happening 🙂

Many thanks are due to the guys at Terracotta for their expert help in the integration, in particular Tim Eck who was outstandingly helpful - thanks Tim!

Java One

If you're attending Java One, we'll be hanging out and demo-ing the session clustering at the Terracotta booth (booth #828) so drop by, eyeball the demo and come and have a chat to us.

Jetty Session Clustering with Terracotta

5 thoughts on “Jetty Session Clustering with Terracotta

  • May 1, 2007 at 6:20 pm
    Permalink

    It has been a real pleasure working with both the Jetty product and the Jetty team! Terracotta and Jetty have common goals of developing lightweight, efficient, and easy to use products and to me they feel like a natural fit. We are looking forward to JavaOne and beyond.
    Cheers,
    Steve

  • May 11, 2007 at 4:04 pm
    Permalink

    It was great meeting you on Thursday at the Jetty-Terracotta booth.  I am sold on Jetty, and will be working it into future architecture designs and current deployments.  Thanks for the cool shirt!

  • December 10, 2007 at 7:24 am
    Permalink

    Hi jan

    Greetings to you,

    Even though i am going to use this great tool, i am really worriying about my bad knowledge both on jetty as well as terracota,

    now we use jetty 6.1.5 on the prod, since we need to bring up the clustered session management i was recommending terracota in place, but when they ask me to show the demo, i couldnt succeed?

    I wanted to use the SessionIDManager which our developers had done as clustered env.

    how to go about? can anyone there pls help me?

  • December 16, 2007 at 11:08 pm
    Permalink

    Hi Madhan,

    All the info is on the wiki page at http://docs.codehaus.org/display/JETTY/Session+Clustering+with+Terracotta

    The Terracotta guys have recently been doing a bit of work to make integration even easier, so stay tuned for some new announcements in this area soon.

    If you’ve followed all of the instructions on the wiki page and still having trouble, then you could either try the jetty community mailing lists at jetty-support@lists.sourceforge.net or contact Webtide at info@webtide.com for private commercial support.

    best regards
    Jan

Comments are closed.