Your application may be deployed to multiple data centers either for disaster recovery or for geographical load balancing of traffic. If your application is high traffic, it must use a distributed cache. In these situations, you need to ensure that your distributed cache can do WAN replication for high availability of data in case of disaster.
NCache provides Bridge to handle WAN replication of distributed caches. It forms a bridge in-between the distributed data centers and performs asynchronous replication of data so there is no performance degradation. Moreover, the bridge itself is a cluster of two servers for high availability purposes.
You may have one active and one passive datacenter primarily for disaster recovery purposes. In this configuration, one 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 may have two active datacenters for a combination of regional load balancing and an implied disaster recovery purpose. One of the active sites contains the bridge and caches while one contains the 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 provides handling of 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 the 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 detail 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 detail on conflict resolution, you can refer to Conflict Resolution Docs.
Replication across regionally distributed data centers can result in performance degradation because of latency. Hence, NCache bridge performs asynchronous WAN replication in parallel across all datacenters so your application doesn’t experience any downtime while waiting for the operations to be replicated.
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 detail on NCache bridge behavior, you can refer to NCache Bridge Architecture Docs.
NCache seamlessly handles disaster situations in each of the aforementioned data center configurations.
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.