does the ELB stickyness work when you remove the msm configuration?
If it does the it's really likely that there's an issue
When you try to get some debug logging from msm you can follow
http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration#Configure_logging
You can post the msm log output from catalina.out (for startup and
requests) here so that I can have a look at it.
Just in the case you don't know: msm can also do non-sticky sessions,
just set sticky="false" in the config.
Cheers,
Martin
Can you please also post log output when msm starts?
Can you please configure sessionBackupAsync="false" and try + send logs
again?
Cheers,
Martin
E.g.
tomcat1:
memcachedNodes="n1:10.116.79.43:11211,n2:10.195.218.100:11211"
failoverNodes="n1"
tomcat2:
memcachedNodes="n1:10.116.79.43:11211,n2:10.195.218.100:11211"
failoverNodes="n2"
There also seems to be an issue with the stickyness configuration. The
first request was served by tomcat2, from catalina.out.2:
Oct 11, 2011 6:04:19 AM de.javakaffee.web.msm.SessionTrackerValve
logDebugResponseCookie
FINE: Request finished, with Set-Cookie header:
JSESSIONID=D81FCF8A0B8F939B7C359C8AF8481D49-n2; Path=/odd_admin; Secure
The next request was served by tomcat1, from catalina.out.1:
Oct 11, 2011 6:04:26 AM de.javakaffee.web.msm.MemcachedSessionService
loadFromMemcached
FINE: Loading session from memcached: D81FCF8A0B8F939B7C359C8AF8481D49-n2
For this request on tomcat1 a new session was created:
Oct 11, 2011 6:04:26 AM de.javakaffee.web.msm.SessionTrackerValve
logDebugResponseCookie
FINE: Request finished, with Set-Cookie header:
JSESSIONID=B943B81E6153A6B015FA65363689C6D8-n2; Path=/odd_admin; Secure
There's also one thing that looks somehow strange: the session cookie
that was sent to tomcat1 does not have the Path set (which was set as
you can see from the logged Set-Cookie header from tomcat2) and it was
not flagged as secure:
Oct 11, 2011 6:04:26 AM de.javakaffee.web.msm.SessionTrackerValve
logDebugRequestSessionCookie
FINE: Have request session cookie: domain=null, maxAge=-1, path=null,
value=D81FCF8A0B8F939B7C359C8AF8481D49-n2, version=0, secure=false
Not sure if this is a problem, but perhaps it indicates an issue related
to SSL/Non-SSL (see e.g.
https://forums.aws.amazon.com/message.jspa?messageID=201320)
Another thing that I noticed: you should exclude heartbeat from msm
tracking by adding it to the requestUriIgnorePattern (s.th. like
requestUriIgnorePattern="/heartbeat|.*\.(ico|png|gif|jpg|css|js)$").
Cheers,
Martin
Cheers,
Martin
> So I switched it back to ELB managed cookies then stickyness started
> working again. Then I tried both JDBC and memcached and both are
> working great.
Out of couriosity: how does ELB-managed differ from app-managed? Also in
ELB-managed mode I'd expect the app to set the JSESSIONID cookie when
it's needed, as ELB does not know when to set the cookie (and which value).
> Question: is there and advantage in this setup of using memcached
> instead of Tomcat clustering (I know I cant use multicast on EC2 but I
> found a way to force the IP for the clustering). What advantage does
> using memcached have over the builtin tomcat clustering ?
The advantage is better scalability. Tomcat session replication is an
all-to-all replication and thus is not very scalable. The backup session
replication is/was not recommended for production (now this is changed
to "Downside of the BackupManager: not quite as battle tested as the
delta manager", see [1]).
Cheers,
Martin
[1] http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
The failoverNodes of tomcat2 should be n2, not n1.
> I tried shutting down the active tomcat (sticky session) and it
> properly failed over to the other tomcat.
> Great. Then I started it up again and waited for it to stabilize.
>
> Then I shutdown both tomcat and memcached on the same system. This
> would simulate a host going down.
Right, the previous restart of tomcat1 was not really necessary for
simulating a server crash...
> Failover occured but not session information ! I had to login
> again ...
>
> My guess is that the state was
>
> Session -> Active on Tomcat1 , stored on Memcached 2
>
> When I kill the host (tomcat1 , memcached1 ) the load balencer hits
> Tomcat2 ... But tomcat2 was told to ignore Memcached 2 so it looks in
> Memcached1 and cant find the session !
msm only moves the session to another memcached if a memcached goes down
that should store a session.
The memcached nodeId is stored in the sessionId, so you can check for
each request in which memcached the session is stored.
> How do I arrange for this kind of failover to work ?
Actually it should work. You can send logs so that I can have a look at
what happened.
Cheers,
Martin
As I forgot: another advantage of msm is pluggable serialization, you're not restricted to java serialization (e.g. kryo is faster and you can provide custom serializers which is especially useful for 3rd party classes stored in the session).
Cheers,
Martin
Again, as written previously in a previous mail: It seems your
failoverNodes are wrong. The failoverNode should point to the memcached
running on the same machine. This also explains why your session was
lost on host crash.
It should be:
tomcat1:
memcachedNodes="n1:10.116.79.43:11211,n2:10.195.218.100:11211"
failoverNodes="n1"
tomcat2:
memcachedNodes="n1:10.116.79.43:11211,n2:10.195.218.100:11211"
failoverNodes="n2"
> ftp://lee.calldei.com/pub/catalina.out.1a
> ftp://lee.calldei.com/pub/catalina.out.2a
I'm getting "550 Failed to change directory.".
> As for what ELB differs between ELB sticky cookies and App specified
> cookies ?
> Here's the link ... but I cant get the App specified cookie
> (JSESSIONID) to actually work.
> http://stackoverflow.com/questions/5093309/amazon-load-balancer-sticky-sessions-configuration-for-jsessionid-in-url
Thanx, I'll read it later.
Cheers,
Martin
to which tomcat belongs catalina.out.1a? It says
configured nodes definition
n1:10.116.79.43:11211,n2:10.195.218.100:11211, failover nodes n2
and therefore should belong to tomcat2. Is this right?
Cheers,
Martin
--
Dennis Brakhane, Martin Grotzke und Ole Langbehn GbR
Breitenfelder Str. 13c, 20251 Hamburg
1) tomcat2: created session C57F53867C23BECF9EE0F566EB4594CB-n1 (n1 ->
stored in memcached1)
2) tomcat2: shutdown
3) tomcat1: take over C57F53867C23BECF9EE0F566EB4594CB-n1
4) tomcat1, memcached1: shutdown,
5) tomcat2: start, cannot connect to memcached1, says: "The node n1 is
not available, therefore C57F53867C23BECF9EE0F566EB4594CB-n1 cannot be
loaded from this memcached."
So you have created the (improbable?) situation that both the tomcat
holding a session and the memcached that keeps the backup go both down
at the same moment.
Even if you had a persistent store this would not have helped you in
this situation, if it were running on machine1. For this situation a
membase cluster with servers on machine1 and machine2 and replication
enabled would be the solution.
Cheers,
Martin
With "replication enabled" I referred to membase. It allows to configure replication per bucket.
Cheers,
Martin