Centralized cache and Distributed cache are two different caching strategies that are used for different reasons. Here's a comprehensive comparison between them:
In a centralized cache, there is a single cache storage that all instances of an application connect to. This setup is very useful for synchronizing data across all instances because if one instance puts something into the cache then all other instances would be able to retrieve it.
An example of a centralized cache is Memcached, which allows different instances of your application to use a single machine (or perhaps several, in a failover configuration) as a cache server.
In contrast to a centralized cache, a distributed cache spreads its data out over multiple nodes. Each node only stores a subset of the cache data. This approach can provide high availability and data redundancy by replicating the cache data over multiple nodes.
Redis Cluster is a well-known example of a distributed cache.
Choosing between these two types of caching largely depends on your specific application requirements, such as the amount of traffic you expect, the scale at which your application operates, the complexity of implementation you can handle, and the level of fault-tolerance required.