๐๐ก๐๐ฅ๐ฅ๐๐ง๐ ๐๐ฌ ๐จ๐ ๐๐ข๐ฌ๐ญ๐ซ๐ข๐๐ฎ๐ญ๐d ๐๐๐ญ๐ ๐๐ญ๐จ๐ซ๐๐ฌ
The need for distributed data storage, I.e. replicated data across multiple machines arises to address problems in performance scalability and reliability:
๐๐๐๐ฅ๐๐๐ข๐ฅ๐ข๐ญ๐ฒ: In certain cases, scaling one layer of architecture may not do much more than pass the bottleneck down to a lower level making the database the ultimate load limiting factor.
๐๐๐ซ๐๐จ๐ซ๐ฆ๐๐ง๐๐: Geographical distance between users becomes a latency factor unless services are in proximity to their users.
๐๐๐ฅ๐ข๐๐๐ข๐ฅ๐ข๐ญ๐ฒ: Availability is often achieved by means of replication to ensure that an entity continues to be available even if an instance of it has failed.
Horizontal scaling of databases may allow for increased load handling and address some of the problems above, however, it will create problems of its own, primarily around data consistency as multiple data stores must be kept in sync to maintain data integrity and consistency.
Thankfully, varying forms of caching can aid in addressing the problems of data store replication:
๐๐ง-๐๐๐ฆ๐จ๐ซ๐ฒ ๐๐๐ญ๐ ๐ ๐ซ๐ข๐๐ฌ remove the database bottleneck as node (a compute instance such as VM) within a system can have its own local copy of data on the same node as the application and existing data replication engines such as Hazelcast and Oracle Coherence ensures that data remains consistent in between nodes, eventually, data will be written to a database in an asynchronous fashion.
This can be especially useful when multiple nodes rely on the same data set to perform intensive operations as those operations can be performed in isolation of each other and concurrently which is not possible when directly communicating with a database.
Data conflict is potential when dealing with data replication however its impact can be mitigated by utilising conflict resolution through the implementation of consensus algorithms such as Raft and Paxos, one of the key features of Hazelcast is the application of Raft.
A diagram produced by Hazelcast captures in-memory data grids at a high level. Here each node hosting an application will have its own copy of cached data
๐๐ข๐ฌ๐ญ๐ซ๐ข๐๐ฎ๐ญ๐๐ ๐๐๐๐ก๐ข๐ง๐ : in-memory data grids are suitable when dealing with small amounts of memory (<100 MB) therefore when more memory is required then distributed caches are an alternative, in distributed caching the cache can be stored on a dedicated server which makes data consistency to be less of an issue however it does reduce performance as data access calls are to be performed remotely.
A diagram produced by Hazelcast capturing distributed caching at a high level. Here the cache can be shared by multiple applications and servers
๐๐๐๐ซ-๐๐๐๐ก๐๐ฌ: A hybrid caching model that utilises both in-memory data grids and distributed caches to address different scenarios for example in-memory data grids are used for frequently accessed data while a distributed cache is used to ensure availability.
Space-based architecture style leverages in-memory data grids at its core as highlighted by Mark Richards and Neal Ford in their book "Foundations of Software Architecture"