Thursday, March 24, 2016

Distributed Cache on SharePoint Server 2013



Originally developed as the AppFabric Cache for the “Cloud” (Microsoft Azure), this product has been developed for the On=Premise systems of Microsoft SharePoint 2013 and called the distributed cache.

The distributed cache can be deployed in 2 different ways:

  • Dedicated Mode
  • Co-located Mode
Dedicated Mode: This involves running only this service on a SharePoint Application server and disabling all other services. If this mode is used, it is advisable to have at least two servers for distributed cache for redundancy purposes.
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:

  1. Stop the service from Central Administration
  2. Using Power shell with the SP add-on : Update-SPDistributedCacheSize –CacheSizeInMB CacheSize
  3. 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.
  1. Create the new account in SharePoint in Central Administration
  2. 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()

 

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

3 comments:

  1. Hi,

    thanks for that post. We have issues that our misscount is nearly at 100% item count. Do you have ideas to solve that?

    ReplyDelete
  2. It may due to a memory mismatch. Have you checked the following?
    - The Distributed Cache service, cache size should not exceed 16 GB
    - When more than one server is used for Distributed Cache in a cluster, all the servers must have the same cache size configured.

    ReplyDelete
  3. Thanks for the fast answer! We have 3 frontend servers with CacheHosts on each one. All 3 CacheHosts are having 1229 MB size.

    ReplyDelete