Topology-Wise Behavior for Cache Operations
NCache provides various caching topologies which behave differently on performing cache operations on them. Given below are NCache topologies and their behaviors.
- Mirror Cache (Enterprise edition only)
- Replicated Cache
- Partitioned Cache
- Partitioned-Replica Cache (Enterprise edition only)
- Client Cache (Enterprise edition only)
Mirror Topology
Note
This feature is only available in NCache Enterprise Edition.
In mirror topology, the client only communicates with the active node, while passive node is the replica of active node and is used for backup.
Bulk operations are performed on the active node, where the application waits for the operations to be replicated to the passive node.
Asynchronous operations are also performed on the active node, but the control is returned immediately to the application so it does not wait for the operation to be performed on both nodes. If callback is registered, it will be triggered upon success or failure of the operation.
Replicated Topology
In replicated topology, the client is connected to one node at a time. Thus, the bulk/async operations are sent to the specific node where the client is connected. These operations are then replicated among the nodes synchronously, ensuring data consistency.
In case of bulk operations, the operations are sent to the specific node where the client is connected. The control is returned to the user after replication has occurred on all nodes of the cluster.
For asynchronous operations, the control is returned immediately to the application, without waiting for replication to occur. However, once replication occurs, the callback is triggered and returned to the client.
Partitioned Topology
In partitioned or partitioned-replica topology, a distribution map is maintained which is responsible for the data distribution across the cluster. Before we get into the detail of operations being performed, it is important to understand what a distribution map is. A distribution map is a key-value pair structure, in which keys represent the node identity and the value contains information of buckets (of data) residing on that node. This way a whole map is generated for the cache and is maintained at the server side. NCache lets the coordinator node decide the data distribution based on the map.
Note
The distribution map distributes all the data in case of a fully connected cluster (all nodes of the cluster are connected). In case a node gets disconnected from the cluster, NCache does not divide the data based on the distribution map any further and sends the data to the next connected node.
After getting the node address where bucket resides from distribution map operation is sent to the destination node. NCache keeps the distributed map on the client end so on performing the next operation on the key, the operation will be directly sent to the node where the data resides. This improves the performance as the operation directly gets sent to the node where data resides.
Assuming the data items 1-500 to be on N1 and 501-1000 to be on N2 (however, data is not divided in an order and is shuffled randomly) as per the distribution map. On any operation performed on bulk items, the operation will be sent to the respective node in a single call. The major ease of having the distribution map on the client side is faster performance because the operation will directly be performed on the data residing node. The control will be returned to the user (for any further operation) once the operation is performed in its entirety.
For asynchronous operations, once any write operation is performed, the call is immediately returned to you while the operation keeps executing on the background. NCache maintains a queue in the background that (does not affect your client operations) keeps track of the operations w.r.t. data. It gives a major comfort with extensive data sets where operations take very long to be performed.
Partitioned-Replica Topology
Note
This feature is only available in NCache Enterprise Edition.
In partitioned-replica topology, the client operation is performed on the assigned node at first, and then replicated to its replica either synchronously or asynchronously, as specified by the user.
In case of bulk operations, if in sync mode, the operations are performed on the assigned node and the application waits till replication occurs on the partition's replica. If in async mode, the control is returned to the application as soon the operation is performed on the partition node, and does not wait for replication as it is asynchronous.
In case of asynchronous operations, the operation is sent to the assigned partition node and the control is returned to the user immediately, irrespective of the specified sync mode.
Client Cache
Note
This feature is only available in NCache Enterprise Edition.
A Client Cache is a local cache synchronized with a remote clustered cache. This synchronization occurs through polling - if a clustered cache detects a change for any of its client caches after its default poll interval of 1 second, it informs the client cache to poll the changed data. Otherwise, after its default interval of 10 seconds, the client cache requests the clustered cache to provide the changed data, if any.
In case of write operations, each operation is performed on the client cache first, and then subsequently performed on the remote cache through an internal Write-Behind mechanism.
For bulk operations, the control is returned to the application once the operation is performed on both client cache and remote cache. In case of asynchronous operations, callbacks are returned to the client cache from the remote cache after the operation is performed on cache.
However, for read operations, the key is first searched in client cache; if not found, the client cache will fetch the key item from the remote cache and then return it to the client. This provides maximum boost in performance and scalability of application without compromising the data integrity.
See Also
Add Data to Cache
Update Existing Data in Cache
Retrieve Existing Cache Data
Remove Data from Cache