Search code examples
cachingarchitecturehigh-loaddata-consistencynosql

Data consistency for NoSQL + Distributed Cache in very concurrent environment


On the slide you can see very rough architecture of booking system. It's very concurrent environment, where many users at once may try to book the same hotel/room.

At bottom we have NoSQL database, for quick response/request there is distributed cache and application which requests data.

The idea of this slide is that when you use NoSQL + Distributed Cache you'll get sync problems, means data consistency problems. You need to sync distributed cache with NoSQL db.

Question: What the solutions/techniques already exists for such case besides IMDG? That could be both frameworks or/and best practices. Is there any specific distributed caches that solves this problem?

Question2[updated]: What are the reasons we do write to the NoSQL db instead of cache? Are that transactions, node fail possibility or anything else?

P.S. That's not my slide, and author claimed that is a great use case for IMDG.

enter image description here


Solution

  • Do you really need the distributed cache? NoSQL solutions are by nature very performant, approaching the performance of stand-alone caches (like memcached).

    I can get ~10ms access times out of Cassandra, which is not much slower than most caches.

    I'll bet that by the time you put in cache validation overhead, and network overhead of missed cache hits, you are going to be better off going straight to your database.

    You can still use caches for things that are less transient, like room types, prices, etc.