CACHE settings (Redis or Memcached) for Tutor Plugins

@regis This question is in regards to configuring the CACHES for tutor plugins for edX IDAs. Should we setup the plugin to use Redis instead of memcached. When we setup our edX IDA using the cookiecutter repo mentioned below we had LocMemCache Django CACHE setting and separate memcache Docker container setup. It seems like the IDA should be pointing to django_redis.cache.RedisCache for CACHES Django setting based on what I’m seeing with how the LMS is configured within Tutor. Please advise.

Also I don’t see anywhere in Tutor documentation to use external services like AWS ElasticCache for Redis. Not sure if we’re supposed to use that seeing that Tutor sets up redis and redis-permissions Docker containers. I realize you have the RUN_REDIS condition so you don’t have to install Redis in a container if you don’t want to. The question is what will happen if you don’t and use AWS ElasticCache for Redis instead? Have you tried this out?

{% if RUN_REDIS %}
  redis:
    image: {{ DOCKER_IMAGE_REDIS }}
    working_dir: /openedx/redis/data
    user: "1000:1000"
    volumes:
      - ../apps/redis/redis.conf:/openedx/redis/config/redis.conf:ro
      - ../../data/redis:/openedx/redis/data
    command: redis-server /openedx/redis/config/redis.conf
    restart: unless-stopped
    depends_on:
      - redis-permissions
  redis-permissions:
    image: {{ DOCKER_IMAGE_PERMISSIONS }}
    command: ["1000", "/openedx/redis/data"]
    restart: on-failure
    volumes:
      - ../../data/redis:/openedx/redis/data
  {% endif %}

Looking at Tutor configuration for the LMS platform it uses Redis mostly with the exception of the staticfiles_lms.

The platform code uses MemcachedCache mostly for maple.


When we setup our IDA it comes by default setup based on the cookiecutter configuration.

Django CACHE settings use LocMemCache.

# https://github.com/openedx/edx-cookiecutters/blob/master/cookiecutter-django-ida/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.project_name%7D%7D/settings/local.py#L5-L12

# CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    }
}
# END CACHE CONFIGURATION

Docker Container Memcache setup:

# https://github.com/openedx/edx-cookiecutters/blob/master/cookiecutter-django-ida/%7B%7Bcookiecutter.repo_name%7D%7D/docker-compose.yml#L14-L16

  memcache:
    image: memcached:1.4.24
    container_name: {{cookiecutter.project_name}}.memcache

Hi @ztraboo ,I have not used AWS ElasticCache before, is it compatible with Redis interface? if the answer is yes, you should be able to use it instead of running a Redis container. You have to configure REIDIS_HOST/REDIS_PORT/REDIS_USERNAME/REDIS_PASSWORD properly.

1 Like

@pcliu It seems that it’s open source Redis with scalability. I haven’t dug into configuration on AWS ElasticCache or MemoryDB.

I guess that we also need to be concerned with message broker replacement of RabbitMQ with Redis as Tutor uses I think. AWS ElasticCache does that too.

Tutor does not run Memcache out of the box. If you wish to add it to your stack, then you should include the service in your plugin.
I have no reason to believe that Tutor does not work with ElasticCache, although I never tried to use it myself. However, I was once told that ElasticCache does not offer on-disk persistence, which means that you would lose all scheduled tasks in the case of an AWS crash: see this conversation from one year ago on Slack.

1 Like