Caching the moodledata directory

Caching the moodledata directory

by Roland Chapin -
Number of replies: 3

I am trying to determine the best way to configure and optimize a large scale Moodle Deployment that will be accessed by users across large geographic areas.

My thought is to have a centralized server and store the moodledata on a local NAS.  Then replicate the contents of the NAS across as many as 3-4 other NASes at geographically different locations.   Each of these other locations might be a small campus for example.  The idea behind this configuration would be to have users authenticate versus a central Moodle server, however pull the media heavy content from a local NAS which maintains a replica of the moodledata directory.  This in essence would become a CDN (Content Distribution Network), managed by DNS.

I understand that this could be done by manually managing the location of media files and NOT replicating the moodledata directory, however is it feasible that this can be done with the entire moodledata directory to simplify the administrative burden?

I'm really only interested understanding how Moodle will work with the replicated copies of the moodledata directory and if this is possible from that perspective.  The engineering on the rest of the setup is very basic.  Thank you for your time and consideration.

Average of ratings: -
In reply to Roland Chapin

Re: Caching the moodledata directory

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Roland,

You may not be aware, but in Moodle 3.3 we introduced a new feature in the File System API.

This is pretty new, but I think that there's potentially a solution to your problem there.

I'd recommend not using soemthing like NFS or a NAS because the latency will be far too high. I would recommend something like an object store such as S3.

I wonder whether this Moodle plugin may be of help to you: https://github.com/catalyst/moodle-tool_objectfs

Andrew

Average of ratings: Useful (1)
In reply to Andrew Lyons

Re: Caching the moodledata directory

by Roland Chapin -

Andrew,


Thank you very much for the reply.  I was not aware of the new API and I will definitely look into that to see if I can somehow take advantage of that help resolve my problem.

I apologize that I did not explain the reason for wanting to do this; the countries where I will be installing this solution have very poor internet.  We might be lucky to have a reliable 1 Mb connection that might have to serve 20 users for example.  That is the reason we are trying to find a way to serve the 'multimedia-heavy' content over a LAN as opposed to pulling it from the internet.  That is why S3 is not a viable solution for us.

I also understand that is might be simpler to install a series of small Moodle servers at each location, however we are trying to centralize student progress and authentication in the central server.

Any ideas are appreciated.  To give a little more details, our main server is a robust HP DL380 Gen 9 with 10 SSDs plus a Synology NAS for housing the multimedia content (or the entire moodledata directory - depending on the final solution).  The remote caching servers are additional Synology NASes.  The Synology servers are basically Linux boxes with their own OS to simplify management.


Thanks again for suggestions.  

In reply to Roland Chapin

Re: Caching the moodledata directory

by Jeff White -

Roland, 

We have had good results with using Galera clusters with having multiple master DB servers which sounds like what you would need to do in your situation. I don't think Galera clusters are 100% supported by Moodle.org but I have not had any problems of collisions or corruptions. 

I would recommend considering Andrew's suggestion further as it might be a solution for you as you can localize as much content as possible with caching (redis cluster?), localcachedir, moodle directory, opcache, etc while keeping the content that must be in a shared location for Moodle to use AWS. AWS does have solutions to distribute your data across the world and keep it in sync with their back-end methods. 

I hope someone can correct me if I am wrong on the logic with MUC but think how your environment would work with AWS and properly configured caching and directories.

  1. 1st End user requests Content
  2. Moodle checks to see if it has a cache of the content
  3. If not, go to AWS to retrieve the content
  4. Moodle then makes a cache of the content
  5. Moodle delivers the content to the 1st end user
  6. 2nd user requests the same content
  7. Moodle checks to see if it has a cache of the content
  8. Moodle finds it has a cache of the content 
  9. Moodle delivers it to the 2nd end user. 
  10. 2nd user gets the content at near local speeds because it was already cached. 

Question for our Moodle experts. Is there a way to tell Moodle to generate a cache everything in the environment?