Working with Distributed Cache

“The Distributed Cache service provides in-memory caching services to several features in SharePoint Server 2013. Some of the features that use the Distributed Cache service include:

 

Newsfeeds

Authentication

OneNote client access

Security Trimming

Page load performance

 

These features use the Distributed Cache for quick data retrieval. The Distributed Cache service stores data in memory and does not have a dependency on databases in SharePoint Server 2013. However, some SharePoint features may store data in both the Distributed Cache and databases.

This model describes the planning process, installation steps, and configuration tasks to perform and to implement the Distributed Cache service in your SharePoint Server 2013 farm. You must do this to ensure that the Distributed Cache service is healthy and supports dependent services as required. Use this model together with other TechNet content to plan and implement your deployment of the Distributed Cache service. ” – Planning and Using the distributed cache service – visio click here to dowload.

Join the first Distributed cache server into the farm and set the cache size, as follows:

 

Use-Cachecluster

Get-CacheHost

Get-CacheHostConfig< HostName> <CachePortNumber>

Update-SpDistributedCacheSize -CachesizeInMb 8192

 

I’ve had good results with setting the cache to 40% of the installed ram.

Join the next distributed cache server in, and check the cache size in MB, if not same as first machine, stop the cache service on that machine and set it on the second machine.  You can stop the distributed cache service on a server by running (Get-SpServiceInstance | ?{$_.typename -like “Dist*”}).unprovision() while logged into that server. Or, you can open central admin and switch to the services on that server and stop it.  When working with a 2016 farm, make sure that auto-provision is not enabled on that service on server page for the server you’re working with.

 

I like to run remove-spdistributedcacheserviceinstance on all servers except one, then get that one server least privileged and sized correctly, and then just run add-spdistributedcacheserviceinstance for each of the other servers in the distributed cache service cluster, since it seems to work better sometimes when only one server is in play.

After you have the instance running on just one server, and the app fabric service shows running, open a powershell and run this bad boy!

Set the service to run on a least privileged account, by running the commands below after changing the purple text:

 

$farm = Get-SPFarm
$cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"}
$accnt = Get-SPManagedAccount -Identity domain_name\user_name
$cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser"
$cacheService.ProcessIdentity.ManagedAccount = $accnt
$cacheService.ProcessIdentity.Update()
$cacheService.ProcessIdentity.Deploy()