How to configure CKAN to store sessions somewhere other than disk (e.g. DB or memcached)?

StackOverflow https://stackoverflow.com/questions/13781023

  •  05-12-2021
  •  | 
  •  

Question

CKAN uses Pylons and hence Beaker. It therefore appears to stores session info (and other cache info) on disk. Is there a way to configure CKAN to store session information somewhere else than disk e.g. DB or memcached?

I'm asking particularly because a) you can run into issues storing sessions on disk (if you have a lot of sessions) b) I would like to run CKAN on something like Heroku where having sessions on disk causes issues (esp if you have more than 1 process)

Was it helpful?

Solution

Install memcached with:

sudo apt-get install memcached

Default config should have settings to listen to localhost on port 11211. /etc/memcached.conf:

-l 127.0.0.1
-p 11211

For CKAN/Beaker to talk to it, you'll need Python module pylibmc and libmemcached. Install libmemcached2 first and see which version comes with your distro:

sudo apt-get install libmemcached2

Lucid comes with v0.31-1 which needs pylibmc no later than version 0.9. If you have 0.32 then you can use a more recent pylibmc. Now install pylibmc:

pip install pylibmc==0.9

Then in your ckan config you set up Beaker to talk to it like this:

beaker.session.type = ext:memcached
beaker.session.url = 127.0.0.1:11211

Once you restart you should be using Beaker, instead of creating those files that eventually completely fill your disk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top