An alternative to MongoDB

Hi there!

Our goal is to use openedx without any usage of mongodb (including the usage of GridFS) and leverage both s3 + cloudfront.

We found some solutions here and there but we were not sure if we were in the right direction.

We tried:

  1. Getting Started — edX Credentials 0.1 documentation
  2. 4.26. Enabling a CDN for Course Assets — Installing, Configuring, and Running the Open edX Platform documentation

What we found after several tries is that, s3 will be used as a backup but not as an alternative to mongo.

Can someone correct or confirm this statement and help us find what are we doing wrong.

We can also find the plugin below that we wrote in order to make things dynamic and pass the right environment variables for the goal we want to acheive.

Thanks for the help

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item((
    "openedx-common-settings",
    r"""
MEDIA_ROOT = "openedx/media"
STATIC_ROOT = "openedx/static"

INSTALLED_APPS = list(INSTALLED_APPS)
if "storages" not in INSTALLED_APPS:
    INSTALLED_APPS += ["storages"]

# Django-storages S3
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

# Inject Tutor config directly (no reliance on container env)
AWS_STORAGE_BUCKET_NAME = "{{ OPENEDX_AWS_STORAGE_BUCKET_NAME }}"
AWS_S3_REGION_NAME = "{{ OPENEDX_AWS_REGION_NAME }}"
AWS_ACCESS_KEY_ID = "{{ OPENEDX_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY = "{{ OPENEDX_AWS_SECRET_ACCESS_KEY }}"

AWS_S3_SIGNATURE_VERSION = "s3v4"
AWS_S3_ADDRESSING_STYLE = "virtual"
AWS_QUERYSTRING_AUTH = True
AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None

AWS_LOCATION = "openedx/media"

def _no_leading_slash(v):
    return v.lstrip("/") if isinstance(v, str) else v

for name in ("VIDEO_IMAGE_SETTINGS", "VIDEO_TRANSCRIPTS_SETTINGS", "GRADES_DOWNLOAD"):
    try:
        d = globals()[name]
        kwargs = d.setdefault("STORAGE_KWARGS", {})
        loc = kwargs.get("location", "openedx/media/")
        kwargs["location"] = _no_leading_slash(loc) or "openedx/media/"
        d["STORAGE_KWARGS"] = kwargs
        globals()[name] = d
    except Exception:
        pass

try:
    AWS_LOCATION = _no_leading_slash(AWS_LOCATION)
except Exception:
    pass
"""
))

I’m not sure if Open edX can be run without Mongo. @dave might be able to provide a bit more context.

@aa-perseus: @sarina is correct. Open edX can’t be run without MongoDB at this time, because all course content storage is still using MongoDB. @kmccormick, @braden, and I gave a talk at the last conference on how we plan to port course content over to the newer Learning Core backend that stores library content:

Unfortunately, we’re probably still a year away from being able to support course content in Learning Core, and likely longer to have full Studio support for it.