$CFG->localcachedir set to TMPFS?

$CFG->localcachedir set to TMPFS?

by Jeff White -
Number of replies: 4

In a scenario where you have a VM lamp cluster that is limited on the performance in storage but have a reasonably large amount of RAM available has any admins tried experimenting have the localcachedir pushed to TMPFS?

Does Moodle control how large the localcachedir can get?

How long do the files remain in the local?

Since these files are read only I would think it would not be a big deal if this data is lost. I am experimenting with using a memcached server and using OPCache but wanted to see if setting localcachedir to TMPFS would see any major improvement as well. If you have OPCache (push to TMPFS) and memcached server would you even need to use localcache? 

What would be some of the ramifications of doing this? 

Average of ratings: Useful (1)
In reply to Jeff White

Re: $CFG->localcachedir set to TMPFS?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't know (having not tried it)... but my guess would be that you would be better in the long run going with memcached as that is designed for the job in hand.

I'm not sure if you are - but don't confuse opcache with memcached (a lot of people seem to). They are entirely different things. I'm not sure what you mean by "the files are read only", they are not. The point of a cache is that it is a good thing if the data you want is there but it can be recreated if it isn't. Unlike a database.

In reply to Howard Miller

Re: $CFG->localcachedir set to TMPFS?

by Jeff White -

I am 99.9% sure a memcached server will be in the new environment. Are you suggesting that if we have a memcached server we should not use localcachedir on the apache servers because almost all of the data that would be stored in localcachedir will be handled in the memcached server? 

In reply to Jeff White

Re: $CFG->localcachedir set to TMPFS?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Can I suggest you try it both ways, measure the difference, and report back wink

The tracker for this (MDL-40545) implies that you *should* set localcachedir in load balanced environments. Of course, this is fine if your local cache is actually fast (enough). That depends on all sorts of things and I wouldn't assume that memory-based disk is going to be faster than fast local physical disks. If you have fast, local disks that is (VM disk IO can be an order of magnitude slower than local disk). 

So... my inclination is to do some experimentation and see what works for you. 

Just for the avoidance of doubt, this was introduced in 2.6. 

In reply to Jeff White

Re: $CFG->localcachedir set to TMPFS?

by Andrea Bicciolo -

Hello Jeff,

even if you use memcached server (for example MUC and sessions), $CFG->localcachedir is a good candidate for caching contents such as themes, some js, and other stuff locally. At the beginning i started to think at tmpfs however since (to my knowledge) there is no control over the size of localcachedir folder (even if it does not appears so big), when dealing with several Moodle sites in the end I preferred to use local disks.  However your scenario may be different and for a single site I think you could benefit from using tmpfs. Remember localcachedir must exists in all clustered web servers.

Average of ratings: Useful (1)