Add Server Node to a Cluster
NCache cluster is dynamic and supports adding server nodes to a running cache cluster. When the new cache server is started, it automatically joins the existing cache cluster. Cache clients that are already connected to the cache cluster which is up and running, automatically connect with the new cache server if the caching topology requires it.
Add Node to Cache
Using the NCache Management Center
Launch the NCache Management Center by browsing to http://localhost:8251 or
<server-ip>:8251
on Windows and Linux.In the left navigation bar, click on Clustered Caches. This opens up a new page at
<server-ip>:8251/
. The page shows any existing Local or Clustered Caches and additional details like Server and Server Platform.Against the cache name, click on View Details.
This opens up the detailed configuration page for the cache. The Server Nodes tab displays a list and status of the existing server nodes of the cache.
Click on the button and specify the server node IP. A success notification will be displayed.
- The newly added node is displayed in the Server nodes list.
Using Command Line Tools
Add-Node enables adding a new server node to the existing clustered cache on the specified server. It also enables users to have multiple server nodes in a clustered cache.
This command adds a new node 20.200.20.40 to the cache named demoClusteredCache existing on server node 20.200.20.39.
Add-Node -CacheName demoClusteredCache -ExistingServer 20.200.20.39 -NewServer 20.200.20.40
In order to ensure that the new node joins the cluster, you need to start the cache using the Start-Cache tool:
Start-Cache -Name demoClusteredCache
For more properties of these cmdlets, you can refer to NCache Command Line Reference.
Verify Successful Addition of Node
To verify the successful addition of the server node, open the Command Line and use the Get-Caches cmdlet (shipped with NCache) with the -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 the 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.
Get-Caches -Detail
Topology Wise Behavior
Topology-specific behavior on adding a new cache server to a running cache cluster is described below.
Partitioned Cache
State Transfer:
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.
Client Connectivity:
In a 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 HashMap
is generated. Then, the HashMap
change event is raised and all running cache clients are notified through it. They then automatically establish a connection with this new cache server and start sending requests to it as well.
Replicated Cache
State Transfer:
In a Replicated Cache, each cache server holds the entire cache and therefore the same set of data. So when a new cache server joins the cluster, it obtains another copy of the entire cache from existing cache servers through state transfer.
Client Connectivity:
In a Replicated Cache, each client is connected to only one cache server 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 the load balancing of the clients in the client configuration client.ncconf file or by specifying CacheConnectionOptions.LoadBalance
flag to false in the GetCache method.
When a new cache server joins the cache cluster in Replicated Cache and if load-balancing is configured to be "true", then each of the 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.