Consider a typical webapplication which runs on an application or web server in clustering mode. Let us say we have 3 nodes in the cluster and the application is running on these 3 nodes and serving all the user requests. There are some property values that are stored in database and instead of going to database every single time this application maintains a cache at server side, at node level, and stores these property values in the cache and serves the values from the cache.

Now we update on of the property value in the database. How do we ensure that this updated value gets reflected in cache across all the nodes?


2 ways to do it I think. Either the cache become at the cluster level or you have to broadcast the invalidation of an entry to each server.

I would say there is a 3rd way which could be a centralized database where each invalid key is kept and the server check that database to ensure the key is still valid (but it's a little bit more complex to implement)

So cache level at the cluster is certainly the easiest but it really depends on why you have the cache server in place (if it's just a replication of the main database then this solution is not valid).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy