Add Server Node to a Cluster
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 which is up and running, automatically connect with the new cache server if the caching topology requires it.
Add Node to Cache
Using NCache Web Manager
Launch NCache Web Manager by browsing to
http://localhost:8251
(Windows) or<server-ip>:8251
(Windows + 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. Click on + to add it to the cache. A success notification will be displayed.
Note
You might get prompted with a dialog box upon these changes, asking whether to reload or overwrite the cache config file. For more detail on maintaining data integrity, refer to this chapter.
- The newly added node is displayed in the Server nodes list.
Using PowerShell
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 20.200.20.30 to the cache named demoClusteredCache existing on server node 20.200.20.29.
Add-Node -CacheName demoClusteredCache -ExistingServer 20.200.20.29 -NewServer 20.200.20.30
In order to ensure that the new node joins the cluster, you need to start the cache using Start-Cache cmdlet in 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 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.
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 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,HashMap
change 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.
Replicated Cache
State Transfer:
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.
Client Connectivity:
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
CacheConnectionOptions.LoadBalance
flag to false in 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 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.