Skip to main content
Expanded the answer after clarifying the question
Source Link
Johannes
  • 740
  • 3
  • 11

Is a shared cache necessary?

Working withIn general a centralizedshared cache storage when running multiple Craft instances behindis not necessary because everything that is not in cache gets re-computed anyways. However, I would highly recommend a load balancershared cache to avoid numerous issues.

An example: Imagine you have a template cache tag, the related page has been cached on all servers. Now you edit the related entry and Craft tries to clear the template cache that corresponds to that entry. The cache clear job is indeedonly run on the server that you are using the control panel at this point in time. The other servers will still have the template cache of the previous entry revision. You would have to build something to run the clear cache job on all other servers as well.

This is only one possible challenge that you could face. I am sure there are more.

To avoid a good ideasingle point of failure for the cache component you could use a Redis cluster.

What to recommend?

Using Redis as cache storage type is perfectly fine. You would want to run it on a separate instance that is accessible by the multiple Craft servers. (It doesn't and shouldn't be exposed to the internet, neither directly nor via the load balancer.)

There are other possible cache storage type described in the Cache component docs.

Working with a centralized cache storage when running multiple Craft instances behind a load balancer is indeed a good idea.

Using Redis as cache storage type is perfectly fine. You would want to run it on a separate instance that is accessible by the multiple Craft servers. (It doesn't and shouldn't be exposed to the internet, neither directly nor via the load balancer.)

There are other possible cache storage type described in the Cache component docs.

Is a shared cache necessary?

In general a shared cache is not necessary because everything that is not in cache gets re-computed anyways. However, I would highly recommend a shared cache to avoid numerous issues.

An example: Imagine you have a template cache tag, the related page has been cached on all servers. Now you edit the related entry and Craft tries to clear the template cache that corresponds to that entry. The cache clear job is only run on the server that you are using the control panel at this point in time. The other servers will still have the template cache of the previous entry revision. You would have to build something to run the clear cache job on all other servers as well.

This is only one possible challenge that you could face. I am sure there are more.

To avoid a single point of failure for the cache component you could use a Redis cluster.

What to recommend?

Using Redis as cache storage type is perfectly fine. You would want to run it on a separate instance that is accessible by the multiple Craft servers. (It doesn't and shouldn't be exposed to the internet, neither directly nor via the load balancer.)

There are other possible cache storage type described in the Cache component docs.

Source Link
Johannes
  • 740
  • 3
  • 11

Working with a centralized cache storage when running multiple Craft instances behind a load balancer is indeed a good idea.

Using Redis as cache storage type is perfectly fine. You would want to run it on a separate instance that is accessible by the multiple Craft servers. (It doesn't and shouldn't be exposed to the internet, neither directly nor via the load balancer.)

There are other possible cache storage type described in the Cache component docs.