Thursday, March 5, 2015

Manage the Distributed Cache in SharePoint 2013

  • When SharePoint Server 2013 is installed, it assigns the Distributed Cache service 10% 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, 5% 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. In most cases, initial 5% cache size may not be enough and you may require to increase cache size to support various SharePoint features. e.g. when you install SharePoint 2013 on 8 GB RAM (8192 MB RAM), it would allocate 410 MB (5% of 8GB RAM) to the Distributed Cache size. This may not be enough to support 50 concurrent user’s My Site activities and it may require to increase the Distributed Cache size

MetricSmall FarmMedium FarmLarge Farm
Number of usersLess than 10KLess than 100KLess than 500K
Cache size1GB2.5GB12GB
Memory allocation2GB5GB24GB
ConfigurationCollocated or dedicatedDedicatedDedicated

Following commands are used to manage the Distributed cache in SharePoint 2013.

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


$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()






Update-SPDistributedCacheSize -CacheSizeInMB CacheSize 




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

Use-CacheCluster      :


Distributed cache use this command to enable cache administration via PowerShell

Get-CacheHost 

Use this command to determine the status of the cache service on each server in the cluster. You should get a listing of every server as well as the state of the service on that server.


Get-CacheHostConfig <HostName> <Port>


Use this command to get general configuration details about a specific host in the cache cluster. All Windows Server AppFabric cache hosts use TCP/IP to communicate with each other and support the cache cluster. The SharePoint distributed cache is an AppFabric cache behind the scenes and it uses the default AppFabric ports for server to server communication. These ports should be allowed through your firewalls for the cache service to function correctly.



Get-CacheAllowedClientAccounts
This command will tell you which accounts/groups have rights to connect to the cache cluster as clients. This seems to be the standard configuration in SharePoint 2013.


Get-Cache

Gets a listing of all the default caches in the farm. All caches have the Id (Guid) of the farm appended to the name.


Get-CacheConfig <CacheName>

Get details about a specific cache instance





Restart-CacheCluster

Restarts the distributed cache service on all servers in the cluster. It will also clear the contents of the cache.




Stop-SPDistributedCacheServiceInstance -Graceful

Stop the distributed cache service on an individual machine. The Graceful parameter will allow the cache service to migrate cached items to another host.

Remove-SPDistributedCacheServiceInstance

Removes a cache host from the cluster. It’s always a good idea to stop the cache service before you remove it.

Add-SPDistributedCacheServiceInstance

Adds a cache host back to the cluster. If there is more than one host in the cluster, it will take a few minutes for the service to start and for any cached items to be synchronized to the new host.


Error and solution URLS : 

http://netwovenblogs.com/2014/03/11/the-newsfeed-is-not-working-on-mysite-in-sharepoint-2013/

Ref Sites : 

http://almondlabs.com/blog/manage-the-distributed-cache/