Add Server Node to Clustered Cache
NCache cluster is dynamic and supports adding server nodes to a running cache cluster at runtime. When the new cache server is started, it automatically joins the existing cache cluster. Cache clients that are already connected to the cache cluster up and running automatically connect with the new cache server if the caching topology requires it.
Add Node to Cache
Add-Node PowerShell cmdlet enables adding a new server node to the existing clustered cache on specified server. It also enables users to have multiple server nodes in a clustered cache.
This command adds a new node 22.214.171.124 to the cache named demoClusteredCache existing on server node 126.96.36.199.
Add-Node -CacheName demoClusteredCache -ExistingServer 188.8.131.52 -NewServer 184.108.40.206
In order to ensure that the new node joins the cluster, you need to start the cache using Start-Cache cmdlet in Windows PowerShell:
Start-Cache -Name demoClusteredCache
For more properties of these cmdlets you can refer to NCache PowerShell Reference.
Verify Successful Addition of Node
To verify successful addition of the server node, open Windows PowerShell and use Get-Caches cmdlet (shipped with NCache) with
-Detail parameter which gives a detailed status of all caches registered on the cache server.
For example, in this case you should see that demoClusteredCache has a Cluster-size of 2 with IP address of each cache server listed with it. The node which has been added will exist in the list now. The output also displays additional cache information like Item Count and Status.
Topology Wise Behavior
Topology specific behavior on adding a new cache server to a running cache cluster is described below.
State transfer in NCache means automatically moving or copying data from one cache server to another. In Partitioned cache, data is partitioned among the running cache servers. So when a new cache server joins the cluster, a new partition is automatically created and data distribution is changed accordingly. And then this cache server gets its share of data through state transfer. So, if there are 2 cache servers in the cluster and each cache server has 1GB of cache data in its partition then upon a new cache server joining the cluster and after the corresponding state transfer is completed, every cache server now holds approximately 600MB of data.
In Partitioned cache, data is partitioned among all the running cache servers. Therefore cache clients are connected with every cache server so they can access all data in one hop. When a new cache server joins the cluster, the data distribution map changes and a new
HashMapis generated. Then,
HashMapchange event is raised and all running cache clients are notified through it. They then automatically establish connection with this new cache server and start sending requests to it as well.
In Replicated Cache, each cache server holds the entire cache and therefore the same set of data. So when a new cache sever joins the cluster, it obtains another copy of the entire cache from existing cache servers through state transfer.
In Replicated Cache, each client is connected to only one cache sever since it has the entire cache. Cache clients are load-balanced among all the running cache servers to equally distribute the request load to them. You can turn off load balancing of the clients in the client configuration file (client.ncconf) or by specifying
CacheInitParam.LoadBalanceflag to false in
When a new cache server joins the cache cluster in Replicated Cache and if load-balancing is configured to be "true", then each of existing cache servers asks some of its clients to move to the newly joining cache server. In this way, the clients are rebalanced among all cache servers. If load-balancing is configured to be "false" then none of this happens and the clients stay connected to their previous cache servers.
A server node can be added to a clustered cache at any time.