Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Server clustering improvements proposal

From MoodleDocs

Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.

This is a base for discussion about potential server clustering improvements in Moodle 2.6

config.php settings

Each node in cluster may use local set of php files including config.php, these may be synchronised via git for example, rsync, etc.

$CFG->wwwroot

It must be the same on all nodes, it must be the public facing URL. It can not be dynamic.

$CFG->sslproxy = true

Enable if you have https:// wwwroot but the SSL is not done by Apache.

$CFG->reverseproxy = true

Enable if your nodes are accessed via different URL. Please note that it is not compatible with $CFG->loginhttps.

$CFG->dirroot

It is strongly recommended that $CFG->dirroot (which is set on the file via realpath()) contains the same path on all nodes. It does not need to point to the same shared directory though. The reason is that some some low level code may use the dirroot value for cache invalidation.

The simplest solution is to have the same directory structure on each cluster node and synchronise these during each upgrade.

The dirroot should be always read/only because otherwise built in add-on installation and plugin deinstallation would get the nodes out of sync.

$CFG->dataroot

This must be a shared directory where each cluster note uses it directly. It must be very reliable, data must not be manipulated directly there.

Locking support is not required, if any code tries to use file locks in dataroot outside of cachedir or tempdir it is a bug.

$CFG->tempdir

It is recommended to use separate ram disks on each node. Scripts may use this directory during one request only. The contents of this directory may be deleted if there is no pending HTTP request, otherwise delete only files with older timestamps.

Always purge this directory when starting cluster node.

If any script tries to use files that were not created during current request it is a bug that needs to be fixed.

$CFG->cachedir

This MUST be a shared directory. The existing caching code is not designed to deal with local node cache dirs, the code is not going to be changed to hack around it. Instead we should create new MUC backends that are clustering aware.

Installation procedure

  • Install Moodle fist without any clustering.
  • The dirroot must contain the same PHP files on all nodes, config.php is probably the only reasonable exception.

TODO: describe possible setups for distribution of HTTP requests, failovers, etc.

Update procedure

Database clustering

Component cache

See MDL-40475

Theme caching

Javascript caching

Language customisations

MUC and clustering