Where to put moodledata SQL or web server?

Where to put moodledata SQL or web server?

by J L -
Number of replies: 6

Hi,

We've got 2 small moodle sites running on 2x webservers (apache),1x  Mysql (with slave replication to a backup DB server) and 1x fileserver for content (where moodledata folder currently sits)


I'm hoping to reduce the maintenance and single point of failure of this setup by removing this file server.


As I see it there are two options available but I'm not a moodle genius so not sure which one is best.


Option 1: Moodledata on the web servers and kept in sync with rsync (or similar) on a cron job. Sessions are stored in the db so I think this is possible.


Option 2: Moodledata is stored on the SQL server and kept in with rsync (as above) with the out of load replication server. This way only one moodledata folder is actually "live" at any one time but rsync keeping the folders in  sync means failing over the MYSQL server is no issue.


From a content perspective I would think closer to the student by being on the web server is best but (I believe) Moodle handles everything content related (file locations and completion status) therefore closer to MySQL is best.

Is there any real difference between these two options? 

Thanks

Average of ratings: -
In reply to J L

Re: Where to put moodledata SQL or web server?

by Ken Task -
Picture of Particularly helpful Moodlers

First, think it would be advised to give some further descriptions/explanations ... the goal is understandable, me thinks, but not the current setup.

Let's see if I understand ... 2 separate moodle sites by different FQDN's?  Moodle site A @ https://moodleA.somenet.net/  Moodle site B @ https://moodleB.somenet.net/

1 moodledata on another server for both instances of the Moodles?

The config file of MoodleA and MoodleB has the same moodledata mounted or however you are doing that right now?

Think it would make a difference in how one might suggest options.

'spirit of sharing', Ken

In reply to Ken Task

Re: Where to put moodledata SQL or web server?

by J L -
Hi Ken

I see I was not very clear with the current setup but you basically have it correct. There are two separate moodle instances (SiteA.com and SiteB.com) sharing the same physical resources but are otherwise separate.

So 2x apache servers are load balanced but both hosting both moodle instances, these connect to 1x live MySQL server (separate DBs) and 1x file server (with separate moodledata folders - around 40(ish) combined gigs). 

There aren't really any performance issues with this setup except that its a single point of failure and we're maintaining a whole server for 40gigs of files which could easily be accommodated by either the servers.

In reply to J L

Re: Where to put moodledata SQL or web server?

by Ken Task -
Picture of Particularly helpful Moodlers

Thanks for clarification ... for a minute or two there I was thinking ... 'how is that even working!!!'.

So if we are voting ... option 1 is the better choice me thinks.

Wouldn't consider option 2 *unless* there is a separate partition for the moodledata directories for each site ... like /data/ with /data/moodleAdata and /data/moodleBdata.

On one partition ... the databases live in /var/mysql/ or something like that ... if one experienced something like autobackups keep all *and* one of the moodledata directories filled up the drive, the DB server suffers ... no more room ... outta space ... and will lead to corruption of the DB's ... maybe to the point where they are un-recoverable + DB server can't even launch.

Option 1 with data directories on same as web would result in faster access for things like sessions ... if using files for sessions - which, I think is now the default for newer versions of Moodle.

'spirit of sharing', Ken

In reply to Ken Task

Re: Where to put moodledata SQL or web server?

by Mathew Gancarz -
Picture of Core developers

I would suggest Option 1 also. Much faster file access because the thing asking for the file isn't the SQL server, it's Apache/PHP. So putting files with the servers running Apache/PHP results in fastest response times, not just for session but for anything file content related (PDF files, images, hosted video/audio, SCORM files etc). As Ken mentioned also isolating the SQL server database file storage from the moodledata file storage helps avoid out of space issues and reduces chance of data corruption.

In reply to J L

Re: Where to put moodledata SQL or web server?

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Have you read https://docs.moodle.org/33/en/Server_cluster#Requirements? It says (about $CFG->dataroot): "This MUST be a shared directory where each cluster node is accessing the files directly"

So, option 2 is the only one worth considering - please don't try option 1 in production!

In reply to Michael Aherne

Re: Where to put moodledata SQL or web server?

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Sorry, I misunderstood what you were trying to do until you posted a reply above! If your webservers are operating independently for different Moodle sites there's no harm in option 1.