The distributed cache can be deployed in 2 different ways:
- Dedicated Mode
- Co-located Mode
Co-located Mode: The distributed cache runs along with all other service applications on the application server(s). This is the recommended mode for deploying Distributed Cache.
Notes on Memory used by Distributed Cache:
- By default 10% of the total physical memory is allocated to Distributed Cache.
- The memory size for the distributed cache on every server that has distributed cache enabled has to be the same size. [Be very aware of this because if the application servers have different sized RAM, this will require adjustment based on the default SharePoint 2013 installation behavior noted in the previous point).
- 50% of the memory for storage and the other 50% to manage the memory.
- Adding more memory to the server does not increase the memory that was initially allocated to the server on install and will require adjusting if more memory is required. Remember to do any adjustments on all servers running the distributed cache service.
- The memory allocated to distributed cache cannot exceed 16GB. Exceeding this size causes issues in the entire farm and is a known Microsoft issue. So if more memory is required, the only option is to add another server and run distributed cache on it. Also remember that if the server has 16GB of total memory to leave at least 2GB for other services in the dedicated mode and a judicious amount for the co-located mode.
Operations on Distributed Cache
Changing memory Allocation:
- Stop the service from Central Administration
- Using Power shell with the SP add-on : Update-SPDistributedCacheSize –CacheSizeInMB CacheSize
- Start the service via Central Admin
Change the service account
There are times when the distributed cache service account needs to be changed. This is easily accomplished in 2 steps.- Create the new account in SharePoint in Central Administration
- Using PowerShell, run the following script:
$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()
$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()
Graceful shutdown of the Distributed Cache Service
There are times when a server running in the distributed
cache cluster requires maintenance. If the service is shutdown, all the data in
the cache is lost. Gracefully shutting the service down ensures that any data
in the cache is moved to another cache host in the farm. (A stopped service can
be started at any time and has no pre-requisites other than the amount of
memory being allocated to the service is the same as other servers in the
distributed cache cluster)
At the Powershell prompt: Stop-SPDistributedCacheServiceInstance -Graceful
Repair a cache host
The Distributed Cache Service sometimes malfunctions. [Evidence of a malfunctioning distributed cache will appear in the Health Rules or users will notice when Newsfeeds start reporting errors].Start Powershell with the SharePoint addons.
Get-SPServiceInstance [Note the GUID in the ID property of the server being repaired]
$s = Get-SPServiceInstance GUID
$s.delete()
Add-SPDistributedCacheServiceInstance (to reinstall and start the distributed cache service)
Monitoring Distributed Cache
The distributed cache can be monitored using PerfMon. The SharePoint Distributed Cache Counters are:Cache Data Transferred Per Sec
Cache Hit Count
Cache Hit Ratio
Cache Miss Count
Cache Read Requests per sec
Cache Write Requests per sec
Total Cache Read Requests
Total Cache Write Requests
If you know of anymore must haves for Distributed Cache please let me know or put them in the comments.
This blog was originally posted in July 2014 on http://www.bigapplesharepoint.com/pages/View-An-Insight.aspx?BlogID=44