Support for storing sessions in memcache/redis

Bug #785469 reported by François Marier
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Wishlist
Son Nguyen

Bug Description

On a busy cluster, storing sessions on an NFS mount creates lot of contention on the locks.

A better solution would be to store sessions in memcache or redis.

tags: added: scalability
Changed in mahara:
assignee: nobody → Christopher Tombleson (christopher-k)
Changed in mahara:
milestone: none → 1.7.0
assignee: Christopher Tombleson (christopher-k) → nobody
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Here's a partial implementation of memcache sessions by Darrin at Catalyst Australia. This is just the session.php code switched to use memcache instead of file; a full implementation will require an admin interface (or at least a $cfg variable) to let the user switch between them.

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Actually, yeah, a $cfg variable would probably be more appropriate for this than an admin screen. Especially since, if you change your session handler, your session is immediately killed and you're force-logged out.

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.7.0 → 1.8.0
importance: Wishlist → Medium
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.8rc1 → 1.8.0
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.8.0 → 1.9.0
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Here's a branch on my personal gitorious repo that has this implementation: https://gitorious.org/mahara/agwells-mahara/source/79bda3f3d2da7b9b45333bf1d449eff5f94059d5:

That's 1.8_STABLE, with the initial memcache patch and a further commit that fixes a bug with session.gc_maxlifetime in that initial patch. We've been using these two patches on several production sites for the past couple of months without any problems.

As mentioned above, what we need in order to be able to upstream this, is a $cfg variable to allow the site admin to specify whether to use standard filesystem sessions, or memcache. Ideally, this would be a pluggable system to allow for further session types to be implemented, but at the minimum it'd be fine to just have it hard-coded to memcache or filesystem.

Revision history for this message
Son Nguyen (ngson2000) wrote :

Hi Aaron;
Yes, It would be good to have session plugins. +1 for this

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.9.0 → 1.10.0
Changed in mahara:
milestone: 1.10.0 → none
importance: Medium → Wishlist
Revision history for this message
Aaron Wells (u-aaronw) wrote :

I've moved the "official" source of this patch to the Catalyst Github account. There are branches ending in "-memcache" for each Mahara version I've needed to port it to so far: https://github.com/catalyst/mahara/tree/mh1504-memcache

Son Nguyen (ngson2000)
Changed in mahara:
assignee: nobody → Son Nguyen (ngson2000)
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/5378

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5378
Committed: https://git.mahara.org/mahara/mahara/commit/bbd333b7a68cc727041762f5362612220caeaa19
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit bbd333b7a68cc727041762f5362612220caeaa19
Author: Robert Lyon <email address hidden>
Date: Fri Dec 23 11:36:07 2016 +1300

Bug 785469: Add support for memcached session save handler

Introduce new global setting:
$cfg->sessionhandler

behatnotneeded

Change-Id: I386c94c4d1ab06fbde110c705789f9dcfaaead67
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: Triaged → Fix Committed
milestone: none → 18.04.0
tags: added: nominatedfeature
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

For Redis see bug #1747297

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.