-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jeffrey,

On 7/22/13 10:00 AM, Jeffrey Janner wrote:
>> -----Original Message----- From: vi...@thepenguin.org
>> [mailto:vi...@thepenguin.org] Sent: Saturday, July 20, 2013 7:25
>> AM To: Tomcat Users List Subject: Enable session persistence
>> between two tomcat nodes behind load balancer
>> 
>> Hello:
>> 
>> I have been searching for an answer to how to set this up. I find
>> a lot of posts on session persistence but none seem to describe
>> how to set it up. Is there a simple explanation out there that
>> tells me how I go about setting up session persistence (with
>> Apache, I would just set up memcached on the db server and
>> configure the memcache module on each Apache instance to point to
>> the memcached and it works). I don't need opcode persistence. I
>> just want the tomcats to either a) direct all session traffic to
>> a single node or b) make the two tomcats aware of all sessions.
>> Can someone point me in the right direction? I am not a java
>> coder, but if code changes need to be made, I can work through
>> it.
>> 
>> Thanks,
>> 
>> Vicki
>> 
>> 
> 
> Vicki - I think you've got your terms a little mixed up here, but
> not much. From your description what you are really looking for is
> session "replication". You are in luck, because the default
> server.xml has a commented out section on how to set up replication
> right there (at least up to Tomcat 6.x). You also want to review
> the documentation on replication on the Tomcat website for your
> release (http://tomcat.apache.org). I said "not much" above,
> because replication relies on persistence-ability, meaning they
> both need the same basic setup in order to work. As I recall from
> looking into it (but not setting up a production setup), you must
> declare your sessions persistable in your code for either function
> to work properly. Jeff p.s. In case you're wondering why not
> production, turns out our initial dev team put way too much info in
> the session to make replication a feasible option for us at the
> time.  I think we've been whittling it away over time, but haven't
> tried it since the first effort.

I've written (but not actually used - it was just a proof-of-concept)
a Filter and HttpSession wrapper that can wrap session data in an
object wrapper whose only member is a transient Object reference[1].
This will allow you to throw "huge" objects into the session that
won't be sent across the wire (only their empty wrappers will be sent).

If your application will tolerate a session attribute "suddenly" being
null, and can recover from that by re-building the necessary data, you
could use the same trick to enable Tomcat's session persistence.

- -chris

[1] You can also do something similar with WeakReference objects,
which allows you to keep huge amounts of data cached in your sessions
but allow the garbage collector to discard some of that cached data if
it's getting low on memory.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJR7bXpAAoJEBzwKT+lPKRYJPoP/jvUj8pKElRmVfXgPGOtXRBs
nhZ/6QDlOnRRpXZStLhShDXTawGUhQ/Sbpene88ytcJ1Y0Ap5D7ZMfI0HNBmZ0Oh
UvTnzcIVjJHmhHfnMzOoVvK/+cvliUVpR0Uy2M8560xShE9nCyIEzHfFUyOWUgeC
ipqvvx88+i+BYqyuWbbjrWjIY1ALjNIgmaaSy+Is3HRKvyNGnANgGvs0bDjybu/k
lVIhRPmjKmKxS/+zDRcsPtvhvywLQUV73x2KljEPppyqf1GM7sNH8HzR0uc8cEby
Lu1TYio0XYNrY7chu1zJWFRGLgS/3QoU6xmS+vT7/4JldB8gG67yynjfxmNjPGKz
+gQi5Bgcp1QW7ecNp5PDtdHseRE5c7PKaJG34MnCe4sn62TT2M7LUd5HV/xhm1IR
+0Y9weApILQoMnmDyn/jvdeWRjQRToBcTMmwgzNleLpQYrzAr2e6bZaxpcuh0djK
77bIhBv95EfWpVkD/3BVtkY3lFndMcM8hjObTQaq8QvDVKq9AWT+pF8NL8soOcoO
GD5QpTAjA9ipnjrTAfD2+QIGbgVE7znpD4nCpZgsWqQkegxMD9VXbx6cIhEj/Pfm
l/BjwuKmCRbsUlnVh1HpqWghwEWEuGz2OTpRpckWMzwjqFhQCXAI6lJABdoSstt6
yeON50P8VPkup5cmemo8
=d83r
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to