I have a cluster of web servers each one running the same java web application. All these instances of web application share the same database (for data storage) and the same network file storage (where they keep some required files).
I need to be able to synchronize instances of web applications. For example, one of the application instances receives a certain request from client, it does some recalculations and updates its internal cache. At this point I need to update internal caches for all other web applications in a cluster, so that each one of them operate on the same dataset.
What would be the best way to achieve such functionality? For sure I can implement some custom component that will periodically poll shared resource (flag in the database table or a file on file store) and initiate required processing once the condition is met. But maybe there's some already existing library/component/app that I can use?
Basically, server side script is used with a help of such a utility as lsyncd together with cron. Lsyncd is a light-weight, live mirror solution used to synchronize app servers. Being wisely coupled with inotify, lsyncd initiates file sync only if it has detected any actual changes in the system.
Only 1 Sync node is deployed within a GWS Cluster. Each data center must have a dedicated list of Genesys servers, such as Configuration Servers, Stat Servers, and T-Servers.
Synchronization: Moving the changes to master configuration through node local configuration if any changes are made in master configuration node agent will push all those changes to all Application Sever nodes configuration. By Default Auto-synchronization is enabled as you can see below screenshot.
There are a lot of existing libraries and components. You can google about cache coherence.
There are different ready-to-use solutions, Jboss cache, Oracle coherence, GridGain etc.
If you want to write hand-written code, there are few approach, how can be done. Every node in your cluster should know about others node (in simplest case). Data can be replicated in different ways.
Synchronous replication Writes occur in local cache only when writes submit to other nodes.
Asynchronous replication. Writes occurs in local node and later replicate on other nodes.
Cache invalidation. When data is changed, all nodes receive signal, invalidate their data and re-read it from database.
It could be quit tricky to implement it yourself, you need special protocol(you can use JGroups
), which your nodes will use to exchange data. I suggest you to find ready solution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With