Can Redis Shared Application cache run on local nodes?

Can Redis Shared Application cache run on local nodes?

by Jan Derriks -
Number of replies: 5

Hi there,

I want to validate a setup with Redis caching in combination with multiple webservers.

The goal is to keep page load times below 15 secs with 600 users running a quiz simultaneously which worked with memcached but we had to switch to Redis.

We have a setup with 4 webservers running Apache and PHP-FPM 7.0 running RHEL6 with a shared document root on NFS. In front of the webservers there is a F5 loadbalancer configured with sticky sessions.

On every webserver there is an independent Redis instance. Due to the fact that we have sticky sessions configured on the loadbalancer the client will have her/his session on the same webserver with access to the Redis cache.

The Moodle docs say this is OK for session caches but is this a valid setup to use as Application cache?

What are the errors we should look for if a shared application cache is not working like it should? Is there a simple way to test it?

We have had it running like this for a while but switched back to session-cache only after some performance (php-fpm timeout errors) issues that could be unrelated. Running a single shared Redis cache is not the question here - I know that should work.


Thanks for any help on this topic.


Average of ratings: Useful (1)
In reply to Jan Derriks

Re: Can Redis Shared Application cache run on local nodes?

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

You might get away with it but why would you want to? The point of the shared cache is that this data only needs to be created once - or at least infrequently. 

In reply to Howard Miller

Re: Can Redis Shared Application cache run on local nodes?

by Jan Derriks -

Some think it will work, others have doubts. I want to be sure. "Might work" is not convincing.  Where and when will it go wrong?

Disadvantages of shared cache: single point of failure and adding nodes is more work. I think the replication features of Redis (Master-replica setup) could be the answer.

Still looking for a test scenario where using a not-completely-shared application cache will fail.


In reply to Jan Derriks

Re: Can Redis Shared Application cache run on local nodes?

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

It isn’t a single point of failure. 

You are proposing multiple single points of failure. 

If you are proposing a non-standard setup and you are determined then the answer is “well try it and let us know how you get on”

Average of ratings: Useful (1)
In reply to Jan Derriks

Re: Can Redis Shared Application cache run on local nodes?

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

Hi Jan,

Still looking for a test scenario where using a not-completely-shared application cache will fail

Every time the (shared) cache content will be invalidated, Moodle will fail w/ unpredictable results due to stale data: in Moodle, each local cache has a timestamp-based - i.e. incremental - fingerprint which is "easy" to be invalidated by the whole set of nodes, regardless the node being the trigger for an invalidation; there are several use cases where such a mechanism cannot be applied i.e. an actual shared cache is required.

Replication is the right way to get rid of your SPoF.

HTH,
Matteo

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

Re: Can Redis Shared Application cache run on local nodes?

by Jan Derriks -


Thanks everyone. So the answer to my question in this thread is definitively NO because Moodle needs SHARED caches for MOST of the application cache mappings.

"Unpredictable results" is a bad thing.

I did find there are some mapping in the application cache that CAN be mapped to local storage. A bit hard to find in the admin>plugins>configuration>known cache definitions. If you edit the  coursemodinfo application cache mapping it says:


This cache can be safely mapped to a store that is local to each webserver


And there are some more that can be mapped to a local RAMDISK without problems. With slow NFS it is still faster that a (remote) redis cache.


Average of ratings: Useful (1)