Manage the Distributed Cache service in SharePoint Server 2013

SharePoint 2013

Applies to: SharePoint Server 2013

Topic Last Modified: 2015-06-02

Summary: Learn how to configure and manage the Distributed Cache service in SharePoint Server 2013.

To perform management and operational tasks on the Distributed Cache service in SharePoint Server 2013, an administrator must perform specific, ordered procedures. This article describes how to conduct several management and operational tasks on the Distributed Cache service.

Important:

The Distributed Cache service can end up in a nonfunctioning or unrecoverable state if you do not follow the procedures that are listed in this article. In extreme scenarios, you might have to rebuild the server farm. The Distributed Cache depends on Windows Server AppFabric as a prerequisite. Do not administer the AppFabric Caching Service from the Services window in Administrative Tools in Control Panel. Do not use the applications in the folder named AppFabric for Windows Server on the Start menu.

An administrator that performs maintenance and operational tasks might need to start and stop the Distributed Cache service. Some of these tasks include the following:

Changing the default configuration of the server farm at installation time. The Distributed Cache service is started on all SharePoint servers at installation time. An administrator might want to stop the Distributed Cache service on some servers in the farm.

Updating the server and there is only one Distributed Cache server in the SharePoint Server 2013 farm.

Stopping the cache results in partial data loss. The Feed Cache depends on the Distributed Cache service. Tags and document activities are saved only to the Feed Cache. Tags and document activities are not persisted to content databases. When the Distributed Cache service is stopped, tags and document activities are lost. When the Distributed Cache service is started, repopulation occurs when the feed cache repopulation timer job runs. For more information, see Manage Feed Cache and Last Modified Time Cache repopulation in SharePoint Server 2013. One way to maintain the tags and document activities is to use the method described in Graceful shutdown of the Distributed Cache service later in this article. When the graceful shutdown of the Distributed Cache service method is used, all cache data is moved from one server to another server before the Distributed Cache service is stopped.

If the Distributed Cache service is started and you want to stop the service, under Action, click Stop. If the Distributed Cache service is stopped and you want to start the service, under Action, click Start.

When SharePoint Server 2013 is installed, it assigns the Distributed Cache service 10 percent of the total physical memory on the server. The Distributed Cache service uses half of that memory allocation for data storage (also known as cache size), and the other half of that memory allocation is used for memory management overhead. When the cached data grows, the Distributed Cache service uses the entire 10 percent of the allocated memory.

You should increase the memory allocation of the Distributed Cache service in these scenarios:

When you add physical memory to the server. The Distributed Cache service does not automatically recalculate the 10% memory allocation, so when you increase the total physical memory on the server, you have to manually increase the Distributed Cache service's memory allocation.

When your server farm has a dedicated Distributed Cache server. Use the following method to calculate how much memory can be assigned to the Distributed Cache service:

Determine the total physical memory on the server. For this example, we will use 16 GB as the total physical memory available on the server.

Reserve 2 GB of memory for other processes and services that are running on the cache host. For example, 16 GB – 2 GB = 14 GB. This remaining memory is allocated to the Distributed Cache service.

Take half of the remaining memory, and convert it to MB. For example, 14 GB/2 = 7 GB or 7168 MB. This is the cache size of the Distributed Cache service.

Use the following procedure to update the memory allocation accordingly.

ComputerName is the computer name of the server that you are running the SharePoint Management Shell cmdlet on.

Stop the Distributed Cache service on all cache hosts. To stop the Distributed Cache service, go to Services on Server in Central Administration, and Stop the Distributed Cache service on all cache hosts in the farm.

To reconfigure the cache size of the Distributed Cache service, run the following command one time only on any cache host at the SharePoint Management Shell command prompt:

CacheSize is the cache size's memory allocation assignment in MB. In the previous example, the cache size was calculated at 7168 MB for a server with 16 GB of total memory.

Restart the Distributed Cache service on all cache hosts. To restart the Distributed Cache service, go to Services on Server in Central Administration, and Start the Distributed Cache service on all cache hosts in the farm.

An administrator can add or remove a server to a cache cluster, or might want to remove a server from the cache cluster, perform some operational or maintenance tasks on the server, and then rejoin or add the server to the cache cluster. When removing the server, the Distributed Cache service is stopped, then unregistered from the server. Unregistering the Distributed Cache service means that an administrator will not see the Distributed Cache service listed on the Services on Server page in Central Administration. Similarly, when a server is added, the Distributed Cache service is registered and then is started on the server. Registering the Distributed Cache service means that an administrator will see the Distributed Cache service listed on the Services on Server page in Central Administration.

Use the following procedures to add and remove a server from a cache cluster. These SharePoint Management Shell cmdlets are run on the server being added or removed.

In a SharePoint Server 2013 farm, a cache cluster exists when one or more cache hosts run the Distributed Cache service. In a SharePoint Server 2013 farm, one cache exists, and the cache spans the cache cluster. An administrator may need to move the cached contents to another cache host when applying updates to the server. To prevent data loss associated with moving the cached contents you need to perform a graceful shutdown of the server using the Windows PowerShell script in the following procedure. The graceful shutdown procedure transfers all cached data from the cache host on which the graceful shutdown procedure is being run on to another cache host in the farm. The transfer process takes 15 minutes or more to run depending on how many items exist in the cache.

Use the following Windows PowerShell script to perform a graceful shutdown of the Distributed Cache server in order to move the cached contents to another cache host. Ensure that you specify the correct node to shutdown and change the script as needed to name the correct parameters for your organization.

Note:

There is no need to remove the cache host from a cache cluster if you use the Windows PowerShell script in the following procedure to perform a graceful shutdown.

When the server farm is first configured, the server farm account is set as the service account of the AppFabric Caching service. The Distributed Cache service depends on the AppFabric Caching service. To change the service account of the AppFabric Caching service to a managed account:

The Distributed Cache service setting for MaxConnectionsToServer is often tuned based on the number of CPUs that are used in the host computer. If, for instance you use multiple cores and then set the MaxConnectionsToServer setting to the same number of CPUs then the computer often uses too much memory and freezes. Similar issues happen when tuning the DistributedLogonTokenCache and DistributedViewStateCache settings. The default setting is 20ms but often exceptions are found when the token caching doesn't happen in the 20ms setting. Use the following Windows PowerShell script to change the settings for max connections and timeouts.

To fine-tune the Distributed Cache service by using a Windows PowerShell script

During installation, configuration, or maintenance activities, the Distributed Cache service might enter a non-functioning state. Evidence of a malfunctioning Distributed Cache service will appear in Health Rules in Central Administration, or when users use features in SharePoint Server 2013 that rely on the Distributed Cache. For example, the Newsfeed on a user's My Site will start reporting errors. Also, administrators might receive the error message "cacheHostInfo is
null
" when they run SharePoint Management Shell cmdlets to manage the Distributed Cache service.

Use the following procedure to restore a non-functioning Distributed Cache host.

At the SharePoint Management Shell command prompt, run the Get-SPServiceInstance cmdlet to list all services on all servers in the server farm. Make note of the GUID in the ID property of the Distributed Cache service on the server that you are repairing. The Get-SPServiceInstance cmdlet lists all services on all servers in the server farm. Ensure that you note the correct GUID from the server that you are repairing.

At the SharePoint Management Shell command prompt, run the following command: