Memcache user sessions

Memcache user sessions

by Albert Ramsbottom -
Number of replies: 10

Hi

I need to revisit this as its still not overly clear.  In M2.6 the recommendations are to use a MemcacheD server to store user sessions.

We are using a shared disk on a SAN using OCFS2 as a clustering file system. Here comes the confusion as its not clear whether we would have to set up a separate MemcacheD server and share this ,also using OCFS2 for user sessions, MUC etc or have a local instance of MemcacheD on each web node to store user sessions. In which case I would imagine that unless we have session affinity on the load balancers (which we would do), the user will lose session data as they are moved around the separate web nodes.

Make sense, probably not!

So hows it done then? I think the recommendations here appear to be based on hardware rather VMs, which to me is a little narrow. We all know that hardware with directly attached disks out performs VM and San based disks but it is the future and we cannot avoid it.  The last three companies I have worked for have gone entirely virtual. But thats another argument

So

1. Put memcacheD on both web nodes and employ session affinity on LB's for user sessions?

2. Or create a central MemcacheD server and store user sessions on that? OCFS2 anyone?

3. Forget MemcacheD for user sessions and use the database to store them (also set as default by Moodle since 2.5)

4. Kill ones self?

5. Start a Moodle committee to get this nonsense cleared up forever?

6. Go away

Albert

 

 

Average of ratings: -
In reply to Albert Ramsbottom

Re: Memcache user sessions

by J S -

Modified #2.  Memcached is an in memory service.  Install it somewhere and point your site at it. 

Average of ratings: Useful (1)
In reply to Albert Ramsbottom

Re: Memcache user sessions

by Andrea Bicciolo -
Hello Albert,

although it should be possible to install a memcache server on each web server front end to store sessions and let the load balancer employ persistence, there is at least one scenario that does not work with this setup, for example a Jmeter load testing from a given client. There could also be other, so I usually prefer to use dedicated memcache server for sessions task and using balancers without persistence. Of course memcache servers must be available to all front ends and secured from unwanted access.

If you are running a 2.6 Moodle version, once memcache is installed and reachable, you need to add the lines available in the Moodle docs to your config.php, adapting accordingly: http://docs.moodle.org/26/en/Session_handling#Memcached. However you could also use database for storing session but I'm pretty sure memcache will be faster.
Average of ratings: Useful (1)
In reply to Andrea Bicciolo

Re: Memcache user sessions

by Albert Ramsbottom -

Yes that is why I put (which we would do), in brackets

As in any form of testing it wouldnt work, generally I tent to set the LB's on Round Robin in testing as then I can prove that each web node is working.  Once session affinity is employed say through IP hash from the LBs, traiffic from a particular IP will always be sent to the same node

Thanks

Albert

In reply to Albert Ramsbottom

Re: Memcache user sessions

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

The OU system is basically (2) - single shared memcache server for sessions.

That works OK for sessions - we also have local memcache servers which are used for some of the MUC caches, particularly language strings, as these are really slow if it has to do a network round-trip (0.5ms on our network) for each request. Be careful if you're doing that as you will find there is no way to flush the caches from within Moodle and it has to be done manually, e.g. during Moodle upgrade. A solution to this problem is the 'clustered memcache' plugin - see MDL-42071 - although for some reason we seemed to find in testing that this was slower than just pointing memcache at localhost. Somebody from MoodleRooms recently mentioned a redis plugin for MUC which might help in this regard too - that could be worth considering if you are setting up new infrastructure, we have not yet investigated it locally. Don't think you can use redis for sessions, though.

--sam

 

 

 

 

Average of ratings: Useful (1)
In reply to sam marshall

Re: Memcache user sessions

by Albert Ramsbottom -

Hi

Thanks Sam, Once of our team has mentioned Redis but I will have to do some investigation with regards to how it works

And whether it can be used for user sessions

I think for now I might just go for a central memcacheD server for sessions and as you said set up individual MemcacheD servers on the front ends, and remember to flush caches on upgrades.

Then test, then try the plugin and compare.

This really needs to be sorted, I mean the whole server clustering thing as its getting right out of control. There needs to be a clearly defined method of doing this and Moodle HQ need to document it in one place.

For me this is a blocker and needs the whole community to get together and solve

 

Albert

In reply to sam marshall

Re: Memcache user sessions

by Albert Ramsbottom -

Sorry one more question regarding your [Sam] statement

"we also have local memcache servers which are used for some of the MUC caches, particularly language strings"

What other MUC caches can I use local MemcacheD servers for?

I ask as I intend to point the localcachedir and tempdir to local disks (well on same VMs)

 

Cheers

Albert

In reply to Albert Ramsbottom

Re: Memcache user sessions

by Andrea Bicciolo -
Hi Albert,

I recall from some past tests that a local memcache may be used for very few MUC mappings, so my consideration was that those very few mappings were not worth the extra configuration and management needed in addition to a shared memcache for MUC, thus preferring only a shared memcache. Usually I configure memcache servers shared among front ends, running two instances of memcached on different ports, one instance dedicated to sessions and one instance to MUC. Of course you can also configure localcachedir and tempdir on fast local disks in addition to a shared cache.

In reply to Andrea Bicciolo

Re: Memcache user sessions

by Albert Ramsbottom -

Thanks for that Andrea I will consider these responses when building our platform

 

Thanks again

In reply to sam marshall

Re: Memcache user sessions

by Adam Durana -

Here's the Redis cache store plugin you mentioned, https://github.com/durana/moodle-cachestore_redis

The plugin lets you use Redis as a store for MUC. It does not let you use Redis for sessions storage.

Moodle 2.6 supports files, database and memcached for session storage. If you look in config-dist.php, you can find more details about configuring and using the different session stores.

In reply to Adam Durana

Re: Memcache user sessions

by Rodrigo Carte -

Hi Adam,

In our company we use Moodle 2.6 and my idea is to implement Redis, the question is, I is supported on Moodle 2.6+ (Build: 20131205), if possible what would be the steps of installation used for Moodle Acknowledge storage cache on Redis.

I hope you can help my.

Regards.