NCache is a powerful performance optimization solution that ensures high availability and scalability. It provides various caching topologies, each designed to meet different needs. These topologies not only provide linear scalability but also maintain data consistency and reliability. Each topology is tailored for specific use cases—for instance, one may be ideal for smaller environments with just two cache servers, while the other is better suited for large-scale cache clusters involving hundreds of servers. This blog explores the characteristics of the different caching topologies that NCache offers.
Mirrored Cache Topology
In the Mirrored Cache topology, client nodes only connect to the active server node in the cluster, for all read and write operations. If the active server node goes down, the client applications automatically connect with the previously passive node. This failover support ensures that the Mirrored Cache is always up and running. This topology offers asynchronous mirroring for write operations, improving performance by processing multiple write operations in bulk on the passive server.
How Mirrored Cache Topology Works?
In the Mirrored Cache topology, the client nodes only connect to the active server node in the cluster, for all read and write operations. If the active server node goes down, the client applications automatically connect with the previously passive node. This failover support ensures that the Mirrored Cache is always up and running. The topology offers async mirroring for write operations that helps in improving application’s performance as multiple writes are performed as a BULK operation on the passive server node.
Replicated Cache
This topology ensures data reliability through data replication on multiple cache servers. The Replicated Cache topology is extremely fast and scalable for read operations. Unfortunately, it is not very scalable for write operations, as these operations are synchronous to all servers in the cluster. Essentially, every time a write operation (such as adding or updating data) is performed, it must be synchronously applied to all servers in the cluster. Therefore, this topology is intended for smaller caching environments where the number of read operations is higher than write operations.
How Replicated Cache Topology Works?
The Replicated Cache topology offers high data availability and reliability, as every server node in the cluster has a complete copy of the cache data. Moreover, it supports dynamic server addition and removal at runtime preventing any data loss.
Each client application connects to just one server node. This connection is based on a load-balancing algorithm determined by the cache servers. When the server connected to a specific client goes down, the client application connects to the next available server.
Partitioned Cache
The Partitioned Cache topology is equally efficient for both read and write operations. It is among the fastest and most scalable caching topologies offered by NCache. Moreover, it allows for linear scalability by letting users add servers to the cluster without stopping it. However, it does not support data replication resulting in potential irrecoverable data loss if a server goes down.
How Partitioned Cache Topology Works?
In the Partitioned Cache topology, the cache is divided into partitions at runtime with a single partition in each cache server. These partitions collectively make a clustered cache consisting of 1000 buckets that are evenly distributed across the servers. Once the server nodes are added, the cluster creates a Distribution Map that contains the division and location, i.e., the mapping of buckets in different partitions. This map ensures efficient communication between the client and server nodes by providing clients with essential information about the cache’s internal organization.
This topology also provides high data availability by connecting all the client applications to cache servers. So that application can get the data they require even if the server connected to goes down, by requesting it from other servers in the cluster
Partition-Replica Cache Topology
This is the most popular caching topology in NCache. It provides users with both linear scalability and high data reliability. This topology is nearly as scalable as the Partitioned topology and provides a performance boost and high data availability similar to the Replicated topology.
How Partition-Replica Cache Topology Works?
Along with the creation of dynamic partitions, this topology also creates dynamic replicas of these partitions on different server nodes – which serve as backups during connection failures or node downtime. In such cases, NCache gets data from the replica node and redistributes it.
However, these replicas limit cluster scalability, as every server node added will be divided into active and replica partitions.
This topology offers two replication modes; synchronized and asynchronized. With asynchronized replication, all replicas are created in the background, resulting in zero performance lags. Unfortunately, this might entail a slight chance of data loss when the replica node is down, as the cache data in the partition might not reach it in time. To avoid any such data loss, synchronized replication ensures all replicas are created at runtime and every operation that fails on the replica will be considered as failed on the partition as well. Not to mention, this topology provides full server connectivity to ensure high data availability.
Client Cache Topology
In the Client Cache topology, or the “cache on top of cache” resides very close to your application and lets you quickly cache data already present in your cluster. The Client Cache is suitable for read-intensive applications, but if your application performs an equal number of read and write operations, then it will work slower, because write operations will require updating the data in two places.
Although, the Client Cache is local, it is not a stand-alone, as it is always synchronized with the clustered cache. This synchronization ensures that data in the Client Cache is always updated. The following is an overview of the main characteristics of the Client Cache topology.
How Client Cache Topology Works?
The Client Cache exists as either InProc (inside your process) or OutProc (local to web/app server). In both cases, it improves your application performance by caching objects locally. The InProc mode delivers unmatched speed by storing data on the application heap, requiring no code changes.
This topology offers both Optimistic and Pessimistic data synchronization. The default Client Cache synchronization is Optimistic, where the NCache client assumes that the data in the Client Cache is up-to-date. In Pessimistic synchronization, the Cache Client first checks the Clustered Cache to see whether it has a newer version of a cached item. If it does, then the client fetches it, puts it in the Client Cache, and returns it to the client application.
Conclusion
NCache provides a range of distributed, scalable, and reliable caching topologies to meet a diverse set of business needs. Whether your requirements involve large data sizes, specific operation types, or high transaction volumes, NCache offers suitable options. To explore more about these topologies, do not hesitate to download NCache today!