Working with load balancer (2 or 3 servers) issues

Working with load balancer (2 or 3 servers) issues

by Raphael Goldman -
Number of replies: 6

Hi,

We wanted to work with load balancer for our moodle site,

We have defined the modeldata directory to be on an external server so both servers work with the same storage,

Since we have start working like that we noticed that the site works really slow, we got an advice from some expert that the problem 

is because the cache is external and it should me in the local server moodledata.

I have 2 questions:

1 - Is it possible to define only the cache to be locally and all the other moodledata to be externally?

2 - Will it casue problem if we do so? If for example a teacher is updating something in server A and at the same time a student is being in server B 

    Maybe some problems will appear because of they are working on different cache?

Thanks!

Average of ratings: -
In reply to Raphael Goldman

Re: Working with load balancer (2 or 3 servers) issues

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Raphael,
at the moment some parts of the caches included into the moodledata need to be shared. The only available option is to use a fast shared cache store like memcached or one of its drop-in replacements.

In Moodle 2.6, there is a local cache too and you can benefit of it but, at this time, it is limited in what it covers: http://docs.moodle.org/26/en/Caching#Other_performance_advice_for_load-balanced_web_servers and http://docs.moodle.org/dev/Server_clustering_improvements_proposal#New_.24CFG-.3Elocalcachedir.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

תשובה ל: Re: Working with load balancer (2 or 3 servers) issues

by Raphael Goldman -

Ok, Thanks. What is exactly memcached?

Is it the solution that is used when working with load balancer?

Can you give me an example why the cache need to be shared?

 

Thanks!

In reply to Raphael Goldman

Re: Working with load balancer (2 or 3 servers) issues

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Raphael,
memcached is a daemon able to store Key/Value pair data, find more about it here: http://en.wikipedia.org/wiki/Memcached, http://memcached.org/.

An example? Consistency of what stored into the cache.
If you need to update/delete an Item, Item1, from Moodle being routed by the Load balancer on Node1, then you need to invalidate all the cache entries where Item1 has been set. If you're using a shared cache you simply update/remove those entries and all the Nodes will see the same data while if you are using a local cache for each Node, you should then contact all the other Nodes too to update/invalidate the locally updated/removed entries, to be all the Nodes aligned about the cached Items otherwise unpredictable results will happen.

That being said, the future goal of the Moodle Cache infrastructure - the so called MUC - will be to move as much as possible from share to local cache.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Raphael Goldman

תשובה ל: Re: Working with load balancer (2 or 3 servers) issues

by Raphael Goldman -

where the session is being save?

in the DB or in moodeldata?

 

 

In reply to Raphael Goldman

Re: תשובה ל: Re: Working with load balancer (2 or 3 servers) issues

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Raphael,
it depends on how the Moodle session backend is configured: 2.6 onwards uses file based session backend while you can still move it to the Database, http://docs.moodle.org/26/en/Session_handling#Session_drivers.
File based session backend is stored into $CFG->dataroot/sessions/.

Please, do not confuse PHP sessions with Moodle Cache infrastructure: they are different things and even if you'll use the database backend for sessions, you'll still need a shared cache store. No way to relax this constraint, being it by design.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

תשובה ל: Re: תשובה ל: Re: Working with load balancer (2 or 3 servers) issues

by Raphael Goldman -

Thanks a lot!