Share via


SharePoint 2013: Distributed Cache (AppFabrikCache) part 2/2

Hi,

A few weeks ago I wrote an article about AppFabric Cache aka Distributed Cache. It’s time to continue about AppFabric Cache. If you didn’t read the previous article please hit the following link: https://gokanx.wordpress.com/2013/06/15/distributed-cache-appfabrikcache-on-sharepoint-server-2013-part-12/

A little reminder about AppFabric Cache: This new way of caching was originally based on the “Cloud” of Microsoft (Azure) but has been integrated on the On Premise systems of Microsoft. The Distributed Cache can be deployed on 2 different ways

  • Dedicated Mode
  • Collocated Mode

On the dedicated mode only this service is running on the application server and all other services are stopped who is hosting the AppFabric Cache Service.

On The Collocated mode the Distributed Cache is running with all other Service Applications on the Application Server. This is the recommended mode for deploying Distributed Cache.

Debug of Cache

Via Central Administration:

  • Open Central Administration and hit Application Management
  • From Service Applications, hit Manage Services on Server
  • Select Distributed Cache Service
  • Hit START or STOP to start or stop your service

Via PowerShell:

At the Windows PowerShell command prompt, run the following command:

$instanceName = “SPDistributedCacheService Name = AppFabricCachingService” 
$serviceInstance = Get-SPServiceInstance | ? {( $_.service.tostring()) –eq $instanceName –and ($_.server.name) –eq $env:computername 
$serviceInstance.Provision() 

OR

$serviceInstance.Unprovision() 

 

Allocate Memory on Distributed Cache Service

When SharePoint Server 2013 is installed, 10% of the total physical memory is allocated. The Distributed Cache service use 50% of this memory as storage and the other to manage the memory.

This cache size can be increased when:

  • You add more memory on the Server
    • Be aware; when you add memory to the server, the Distributed Cache isn’t updating by himself. You need to reconfigure the Cache Size.
  • If you have a dedicated caching server
    • You should calculate it so :
      • Determine the total sum of physical memory. Let’s take the example that your server has 16GB of memory.
      • You have to book 2GB of memory for other processes. So this means 16GB – 2GB = 14GB
      • Now we have to take the half of this amount and that size is our AppFabric Cache Size : 14GB / 2 = 7GB
      • Again, as said on the previous post ; the total size of memory should never be more than 16GB

Change the Memory allocation

Use this procedure to reconfigure the memory allocation of Cache Size

Use-CacheCluster 
Get-APCacheHostConfiguration –ComputerName –CachePort « 22233 »

Or

  • Stop the service via Central Administration
  • Update-SPDistributedCacheSize –CacheSizeInMB CacheSize
    • If we take our example ; you have to fill 7000 MB for a server who has 16GB or RAM
  • Start the service via Central Administration

Add or Delete a server on a Distributed Cache Cluster

When you want to delete an AppFabric Server from the cluster, be aware that the service is stopped from the Central Administration and then execute the folling commands via PowerShell:

Adding: Add-SPDistributedCacheServiceInstance 
Deleting: Remove- SPDistributedCacheServiceInstance 

 

Graceful shutdown of the Distributed Cache Service

In SharePoint 2013, a cluster cache exists when one or many machines are running the Distributed Cache Service.

When you have to do maintenance on your platform, the possibility exists that you have to remove a server from the Distributed Cache Cluster.

You have to run the following command (graceful) on the server that you want to remove.

Stop-SPDistributedCacheServiceInstance – Graceful 
Remove-SPDistributedCacheServiceInstance 

This operation can take more than 15 minutes. The graceful option will prevent losing any data.

Change the Managed Account

When SharePoint Server 2013 is installed the Managed Account of Distributed Cache is the same as the Installation Account (PEGASUS\SPInstall_GA). You can change this with Powershell commands:

 

$farm = Get-SPFarm 
$cacheService = $farm.Services | where {$_.Name –eq “AppFabricCachingService”} 
$account = Get-SPManagedAccount –Identity Pegasus\USER_NAME 
$cacheService.ProcessIdentity.CurrentIdentityType = “USER” 
$cacheService.ProcessIdentity.ManagedAccount = $account 
$cacheService.ProcessIdentity.Update() 
$CacheService.ProcessIdentity.Deploy() 

 

 

Repair a Cache host

After an installation or maintenance of your cluster, the Distributed Cache can be non-operational. You can repair this again with PowerShell:

$Get-SPServiceInstance 
$var = Get-SPServiceInstance GUID OF APPFABRICK 
$var.delete() 
Add-SPDistributedCacheServiceInstance 

What you need to retain? (Summary)

  • Do not give more than 16GB for you Distributed Cache Service and not more than 16 machines for your cluster
  • Pray attention when changing anything and use the Graceful option to prevent data loss
  • Never give Dynamic memory but always static memory
  • Never ignore alerts in Health Analyzer

Please read here the part 1: http://social.technet.microsoft.com/wiki/contents/articles/17900.sharepoint-2013-distributed-cache-appfabrikcache-part-12.aspx