In-memory cache VS. centralized cache in a distributed system

前端 未结 3 1669
生来不讨喜
生来不讨喜 2021-02-05 22:41

We\'re currently looking for the most suitable solution for accessing critical data on a distributed system, and we\'re considering whether to use in memory caching, versus a ce

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 23:37

    I don't find any problem in going for a centralized cache using Redis.

    1. Anyway you are going to have a cluster setup so if a master fails slave will take up the position.
    2. If cache is flushed for some reason then you have to build the cache, in the mean time requests will get data from the primary source (DB)
    3. You can enable persistence and load the data persisted in the disk and can get the data in seconds(plug and play). If you think you will have inconsistency then follow the below method.

    Even if cache is not available system should work (with delayed time obviously). Meaning app logic should check for cache in redis if it's not there or system itself is not available it should get the value from dB and then populate it to redis and then serve to the client.

    In this way even if your redis master and slave are down your application will work fine but with a delay. And also your cache will be up to date.

    Hope this helps.

提交回复
热议问题