Your application may be deployed to multiple data centers, either for disaster recovery or for geographical load balancing. In such cases, your application must use a distributed cache that supports WAN replication for high availability of data in case of disaster.
NCache provides a Bridge feature to handle WAN Replication between distributed caches. It performs asynchronous replication of data to avoid any performance degradation. Moreover, the bridge itself runs as a 2-node cluster for high availability.
You may have one active and one passive data center primarily for disaster recovery purposes. In this configuration, the active site contains the bridge and caches, while the passive contains only the caches. The active site asynchronously replicates the data through the bridge to the passive site, which acts as backup in case of disaster.
You can configure two active data centers for regional load balancing with built-in disaster recovery. One of the active sites contains the bridge and caches, while the other has caches only, similar to the active-passive configuration. However, the difference in this case is that both sites replicate data with one another as they are both actively serving client operations.
Apart from the aforementioned configurations, NCache also supports three or more data centers. In this case, one of the sites is a bridge site which contains the bridge and caches. The other sites only contain caches. All the non-bridge sites are connected to the bridge site, so data is replicated to all sites simultaneously. You can also create a backup bridge on any of these sites to ensure high availability in case the bridge site goes down. For more details on this configuration, you can head over to the blog Understanding Multi-Datacenter WAN Replication.
When you have multiple active sites, there is a chance that the same data could be updated simultaneously on each of those sites. By default, the conflict is resolved in NCache using the "last-update-wins" logic. However, you can also specify a custom conflict resolution handler that resolves the conflict by analyzing the data based on your logic.
The following code snippet shows a simplified implementation of the conflict resolver which is implemented on the cache:
public class Resolver : IBridgeConflictResolver
{
public void Init(System.Collections.IDictionary parameters) {. . .}
public ConflictResolution Resolve(ProviderBridgeItem oldEntry, ProviderBridgeItem newEntry)
{
var conflictResolution = new ConflictResolution();
switch (oldEntry.BridgeItemVersion)
{
case BridgeItemVersion.OLD: { /* Replace Item with New Entry */ }
break;
case BridgeItemVersion.LATEST: { /* Keep Old Entry */ }
break;
case BridgeItemVersion.SAME: { /* Your custom logic */ }
break;
}
return conflictResolution;
// Configure this implementation on cache
}
public void Dispose() {. . .}
}
For more details on conflict resolution, you can refer to Conflict Resolution Docs.
Replication across regionally distributed data centers can result in performance degradation because of latency. NCache Bridge replicates data asynchronously across all data centers, ensuring no application downtime.
Moreover, the bridge also sends multiple data items as a single bulk request to the other site, drastically reducing network trips across the WAN. As an add-on, the bridge has built-in replication as well: it is a 2-node cluster which self-replicates so it is highly available itself. For more details on NCache bridge behavior, you can refer to the NCache Bridge Architecture Docs.
NCache seamlessly handles disaster situations in each of the aforementioned data center configurations.
The following cases might occur:
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.