strugglejl / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

Support redis a backend storage #222

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is an enhancement.

We used https://github.com/jcoleman/tomcat-redis-session-manager as a redis 
tomcat session manager. 

Unfortunately we had some legacy parts using session heavily and there were 
racing conditions. The reason is that two ajax requests will deerialize from 
redis and have a copy of session, when finishing, they two will write to redis 
and the later one win and override the earlier one.

Your session persistence strategy seems to fit our need, but look at the codes 
I don't know how to change it to support redis.

If I understand correctly, it should be trivial to switch backend storage if 
designed well.

Please have a look whether it is possible to support redis as an external 
storage.

Original issue reported on code.google.com by ryang....@gmail.com on 16 Dec 2014 at 4:01

GoogleCodeExporter commented 8 years ago
There was once a pull request 
(https://github.com/magro/memcached-session-manager/pull/18) from which I 
created a branch 
(https://github.com/magro/memcached-session-manager/tree/pluggable-storage-pull1
8). While working on this I ran into issues with integration tests and redis 
failover tests, I just couldn't get them to work. If you'd like to pick up the 
work on this I could see if I've everything pushed or if I have still some work 
in progress locally.

Cheers,
Martin

Original comment by martin.grotzke on 17 Dec 2014 at 8:41

GoogleCodeExporter commented 8 years ago
Hi,

I am interested, please help to push all related changes to a separate branch 
and I'll have a look.

By the way, I think the session manager shouldn't concern about the failover of 
the storage. In redis, you could use Redis Sentinel to manage redis nodes and 
failover stuff. So the session manager only need to know the sentinel nodes. 
Sentinel nodes will manage the rest nodes for you. That way the session manager 
should be simpler.

Personally I think the responsibility of session manager is just purely 
persistence.

Cheers,
Rui

Original comment by ryang....@gmail.com on 17 Dec 2014 at 11:02

GoogleCodeExporter commented 8 years ago
Hi Rui, 

great that you're interested! I'll check tomorrow when I'm back at my pc if 
everything's pushed.

Basically I agree with you that msm *should* not be concerned with the backend 
high availability / failover, but this implies that you need a HA backend and a 
driver that manages HA transparently for msm. Because I started msm with 
memcached, there was no such a solution. Later, when membase was available and 
mature, I added membase support, where in fact the driver manages HA 
transparently. AFAICS for redis sentinel you'd need 
https://github.com/hamsterready/jedis-sentinel-pool, or is there a better 
solution?

Cheers, 
Martin

Original comment by martin.grotzke on 17 Dec 2014 at 11:45

GoogleCodeExporter commented 8 years ago
Alternatively redis cluster + Jedis Cluster might be an option. Have you used 
this already, what do you think?

Original comment by martin.grotzke on 17 Dec 2014 at 11:58

GoogleCodeExporter commented 8 years ago
Hi,

Sorry, with redis sentinels, you may also need two sentinels nodes for 
redundancy. So the session manager does need to manage a node list.

Cheers,
Rui

Original comment by ryang....@gmail.com on 18 Dec 2014 at 12:13

GoogleCodeExporter commented 8 years ago
basically we set up two redis nodes and two sentinels nodes. we passed 
sentinels nodes to tomcat-redis-session-manager. And looking at its codes, it 
is using jedis JedisSentinelPool to manage connection pool.

Cheers,
Rui 

Original comment by ryang....@gmail.com on 18 Dec 2014 at 1:03

GoogleCodeExporter commented 8 years ago
Hi Rui,

I just checked it, the branch "pluggable-storage-pull18" on github is up to 
date. At that time I tried to setup a redis sentinel integration test based on 
embedded-redis but there were issues in test mode (while redis sentinel worked 
when testing manually), I just pushed my stuff to 
https://github.com/magro/embedded-redis (the main repo is newer, so my version 
is outdated, perhaps the new upstream stuff already improves things).

Cheers,
Martin

Original comment by martin.grotzke on 18 Dec 2014 at 8:47

GoogleCodeExporter commented 8 years ago
Hi Martin,

Thanks. I will play with it once I have the time.

Cheers,
Rui

Original comment by ryang....@gmail.com on 18 Dec 2014 at 9:55

GoogleCodeExporter commented 8 years ago
Hi Martin,

try to generate idea project using:
mvn idea:idea

got dependency exception:
Failed to execute goal on project memcached-session-manager-tc6: Could not 
resolve dependencies for project 
de.javakaffee.msm:memcached-session-manager-tc6:jar:1.6.3-SNAPSHOT: The 
following artifacts could not be resolved: 
de.javakaffee.msm:memcached-session-manager:jar:1.6.3-SNAPSHOT, 
de.javakaffee.msm:memcached-session-manager:jar:tests:1.6.3-SNAPSHOT: Could not 
transfer artifact 
de.javakaffee.msm:memcached-session-manager:jar:1.6.3-SNAPSHOT from/to 
jmemcached (http://thimbleware.com/maven): thimbleware.com: Unknown host 
thimbleware.com -> [Help 1]

I know buildr. But I am a basic mvn user. I am guessing that I need to do local 
publish. any idea how I can quickly workaround this? 

Cheers,
Rui

Original comment by ryang....@gmail.com on 9 Jan 2015 at 12:11

GoogleCodeExporter commented 8 years ago
Hi Rui,

I just removed the thimbleware.com/maven repository in pom.xml, because the 
artifacts are now available in maven central.

https://github.com/magro/memcached-session-manager/commit/da265b91

Cheers,
Martin

Original comment by martin.grotzke on 9 Jan 2015 at 8:16

GoogleCodeExporter commented 8 years ago
Issues are moved to github, this one is now 
https://github.com/magro/memcached-session-manager/issues/261

Original comment by martin.grotzke on 24 Aug 2015 at 3:11