Trying to setup msm

88 views
Skip to first unread message

Bisente

unread,
Jul 14, 2010, 7:33:53 AM7/14/10
to memcached-session-manager
Hi

I'm trying to setup msm 1.3.0 on a two-node cluster, but can't get it
to work. I'm using Tomcat 6.0.26-3~bpo50+1 from Debian Backports and
an nginx server acting as a web/proxy doing a round robin load
balance.

This is what I have on server.xml:

<Host>
...
<Context path="/">
<Manager
className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:10.0.0.5:11211
n2:10.0.0.7:11211"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|
js)$"
/>
</Context>
</Host>

When restarting Tomcat, I get this on catalina.out:

14-jul-2010 10:26:49
de.javakaffee.web.msm.MemcachedBackupSessionManager init
INFO: MemcachedBackupSessionManager starts initialization...
(configured nodes definition n1:10.0.0.5:11211 n2:10.0.0.7:11211,
failover nodes null)
14-jul-2010 10:26:49 de.javakaffee.web.msm.SessionTrackerValve <init>
INFO: Setting ignorePattern to .*\.(png|gif|jpg|css|js)$
2010-07-14 10:26:49.264 INFO net.spy.memcached.MemcachedConnection:
Added {QA sa=/10.0.0.5:11211, #Rops=0, #Wops=0, #iq=0, topRop=null,
topWop=null,
2010-07-14 10:26:49.266 INFO net.spy.memcached.MemcachedConnection:
Added {QA sa=/10.0.0.7:11211, #Rops=0, #Wops=0, #iq=0, topRop=null,
topWop=null,
2010-07-14 10:26:49.276 INFO net.spy.memcached.MemcachedConnection:
Connection state changed for sun.nio.ch.SelectionKeyImpl@57ac3379
2010-07-14 10:26:49.277 INFO net.spy.memcached.MemcachedConnection:
Connection state changed for sun.nio.ch.SelectionKeyImpl@6a6779e6
14-jul-2010 10:26:49
de.javakaffee.web.msm.MemcachedBackupSessionManager
createTranscoderFactory
INFO: Starting with transcoder factory
de.javakaffee.web.msm.JavaSerializationTranscoderFactory
14-jul-2010 10:26:49
de.javakaffee.web.msm.MemcachedBackupSessionManager init
INFO: MemcachedBackupSessionManager finished initialization, have node
ids [n1, n2] and failover node ids []

So it seems msm is being initialized correctly.

However, it doesn't work. I'm not getting balanced sessions (if the
proxy balances to the other node, I'm not getting sessions), nothing's
being written to memcache (memcache.log empty, tcpdump shows no
attempt to access port 11211) and the JSESSIONID cookie is not being
appended with -n[12].

Where should I start digging? :)

Thanks

Martin Grotzke

unread,
Jul 14, 2010, 12:36:59 PM7/14/10
to memcached-se...@googlegroups.com
Hi,

do you see a Set-Cookie header in a response? If not your app simply
does not create a session.

You may also simplify your situation for analyzing this by accessing
tomcat(s) directly.

Cheers,
Martin

--
Martin Grotzke
http://www.javakaffee.de/blog/

Bisente

unread,
Jul 15, 2010, 6:17:42 AM7/15/10
to memcached-session-manager
Hi

> do you see a Set-Cookie header in a response? If not your app simply
> does not create a session.

Yes, but as I said the JSESSIONID is not appended with -nX.

Set-Cookie: JSESSIONID=A582C651BD68A0C5D7CF2BCE3AA85AC2; Path=/

And nothing is saved to memcached.

> You may also simplify your situation for analyzing this by accessing
> tomcat(s) directly.

Same thing, i get the session cookie without the -nX and there's no
connection to the memcached servers.

Regards

Martin Grotzke

unread,
Jul 15, 2010, 7:15:19 AM7/15/10
to memcached-se...@googlegroups.com
Can you change $CATALINA_HOME/conf/logging.properties and add these lines?

de.javakaffee.web.msm.MemcachedBackupSessionManager.level = FINEST
de.javakaffee.web.msm.SessionIdFormat.level = FINEST
de.javakaffee.web.msm.NodeAvailabilityCache.level = FINEST

Perhaps you have to change java.util.logging.ConsoleHandler.level to
FINE, not sure about that.

What urls do you request? Can you provide more logging output, so that
I can get an idea what's happening?

Alternatively, can you provide a very basic quickstart .war that shows
the described behaviour so that I can have a look at the issue
directly?
This would save lots of turnarounds probably :-)

Cheers,
Martin

--
Martin Grotzke
http://www.javakaffee.de/blog/

Vicente Aguilar

unread,
Jul 15, 2010, 8:45:50 AM7/15/10
to memcached-se...@googlegroups.com
HI

Can you change $CATALINA_HOME/conf/logging.properties and add these lines?

de.javakaffee.web.msm.MemcachedBackupSessionManager.level = FINEST
de.javakaffee.web.msm.SessionIdFormat.level = FINEST
de.javakaffee.web.msm.NodeAvailabilityCache.level = FINEST

Perhaps you have to change java.util.logging.ConsoleHandler.level to
FINE, not sure about that.

I've tried but I get exactly the same results. Some msm logging on Tomcat startup and absolutely nothing after that.

What urls do you request? Can you provide more logging output, so that
I can get an idea what's happening?

Nothing special. We have several in-house developed apps which use sessions. They all work OK when running on a single Tomcat server but when I move them to a cluster I'm setting up with msm sessions don't work.

Alternatively, can you provide a very basic quickstart .war that shows
the described behaviour so that I can have a look at the issue
directly?
This would save lots of turnarounds probably :-)

Right now I can't, I'm trying to deploy our apps in a development cluster I'm building where the only missing part is balancing sessions. 

I'm gonna try to reduce the problem by configuring a single Tomcat with msm and building a very simple login app, and see if I can reproduce the problem there. If I setup a single Tomcat server with msm using memcache on the same host, I should still get the sessions saved to memcached and the cookie appended with -nX, right? 

Regards

-- 

Martin Grotzke

unread,
Jul 15, 2010, 10:48:51 AM7/15/10
to memcached-se...@googlegroups.com
On Thu, Jul 15, 2010 at 2:45 PM, Vicente Aguilar <bis...@bisente.com> wrote:
> I'm gonna try to reduce the problem by configuring a single Tomcat with msm
> and building a very simple login app, and see if I can reproduce the problem
> there. If I setup a single Tomcat server with msm using memcache on the same
> host, I should still get the sessions saved to memcached and the cookie
> appended with -nX, right?
Correct.

There's an msm sample on github btw. (this is currently configured for
playing with non-sticky sessions IIRC):
http://github.com/magro/msm-sample-webapp

Perhaps this can help finding the issue...

Cheers,
Martin


PS: right now I have to approve your messages due to the google group
settings that shall prevent too much spam, if you don't mind it would
be easier if you sign up as member of the msm group...


> Regards
> --
>  Vicente Aguilar <bis...@bisente.com> | http://www.bisente.com
>

--
Martin Grotzke
http://www.javakaffee.de/blog/

Vicente Aguilar

unread,
Jul 15, 2010, 11:41:45 AM7/15/10
to memcached-se...@googlegroups.com
Hi

There's an msm sample on github btw. (this is currently configured for
playing with non-sticky sessions IIRC):
http://github.com/magro/msm-sample-webapp

Ok, after taking a look at the sample configuration I think I've got it. I had the <Manager ...> configuration on the server.xml file instead of the context.xml file. I've moved to context.xml and now I'm getting the -nX sessions and they're being saved to memcached.

Thanks Martin. :-)

BTW, I think the docs here are a little bit misleading when it says "Configure the appropriate context in your $CATALINA_HOME/conf/server.xml":


Regards,

Martin Grotzke

unread,
Jul 15, 2010, 6:54:24 PM7/15/10
to memcached-se...@googlegroups.com
Hi Vicente,

good that it's working for you now!

I just tested the sample app with the following configuration within
the server.xml:
<Context path="" docBase="ROOT">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211 n2:localhost:11212"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js|ico)$"
sessionBackupAsync="false"
sessionBackupTimeout="100"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
customConverter="de.javakaffee.web.msm.serializer.kryo.JodaDateTimeRegistration,de.javakaffee.web.msm.serializer.kryo.WicketSerializerFactory"
/>
</Context>

I also removed the context.xml, and with this config msm worked fine,
session got the -n* suffix.

I changed the SetupAndConfiguration page so that the Context element is
<Context path="" docBase="ROOT">
to be sure that this is working :-)

Cheers,
Martin

--
Martin Grotzke
http://www.javakaffee.de/blog/

Reply all
Reply to author
Forward
0 new messages