Monitoring SharePoint Distributed Cache Service for Scale-Up (memory) or Scale-Out (add cache host)


What are recommended procedures for monitoring the Distributed Cache Service on SharePoint 2013 for scale-up (memory) or scale-out (add cache host) to handle increasing load?  I’ve done some initial research, and learned this isn’t an exact science.  I’ve provided some initial information I collected in this post.

The Distributed Cache Service provides in-memory caching services to several features in SharePoint Server 2013, and should be monitored for memory management, resiliency, and availability issues.  So, you might want to start by getting a pattern of usage (non-peak versus peak).  Note: I believe “load” as RPS (requests per second) would be driven by total users and number of concurrent users.  In a nutshell, the goal of the AppFabric service is to maintain the memory a cache host uses to store cached items between the low watermark and high watermark configured for that cache host.

To view common configuration details for individual caches, run the following command:

Use-CacheCluster
Get-AFCache | % {Get-AFCacheConfiguration -CacheName $_.CacheName}

You may want to know how many items are stored and how much memory is in use for individual caches. For specific stats about each cache, run this command:

Use-CacheCluster
Get-AFCache | % {
    $CacheName = $_.CacheName
    Get-AFCacheStatistics -CacheName $CacheName | Add-Member -MemberType NoteProperty -Name 'CacheName' -Value $CacheName -PassThru
}

You could pipe the output from this command to Export-Csv to create a short report. Typical output is shown here:

CacheName         : DistributedLogonTokenCache_f3bd4763-f482-4bb8-a5a5-f40806460bdd
Size              : 36864
ItemCount         : 6
RegionCount       : 6
RequestCount      : 55
ReadRequestCount  : 26
WriteRequestCount : 14
MissCount         : 32
IncomingBandwidth : 96924
OutgoingBandwidth : 880

Cache Statistics

Since the current amount of memory in use by the cache is so important, you’ll be interested in the commands which return a snapshot of current usage.  You have a couple options for retrieving information about all servers in the cluster, one using the Get-AFCacheHostStatus to iterate through all hosts, and one by finding all configured service instances in SharePoint. They are as follows:

Get-AFCacheHostStatus | % {
    $ServerName = $_.HostName
    Get-AFCacheStatistics -ComputerName $_.HostName -CachePort $_.PortNo | Add-Member -MemberType NoteProperty -Name 'ServerName' -Value $ServerName -PassThru
} | Format-List -Property *

**OR**

$SPDCServers = Get-SPServer | ? {($_.ServiceInstances | % TypeName) -contains 'Distributed Cache'} | % Address
$SPDCServers | % {
    $ServerName = $_
    Get-AFCacheStatistics -ComputerName $_ -CachePort 22233 | Add-Member -MemberType NoteProperty -Name 'ServerName' -Value $ServerName -PassThru
}

And typical output looks like this:

ServerName      : SERVER09
Size            : 51200
ItemCount       : 18
RegionCount     : 13
NamedCacheCount : 10
RequestCount    : 393
MissCount       : 66

From…
AppFabric Caching (and SharePoint): Configuration and Deployment (Part 2)

The Distributed Cache can be monitored using below performance counters in Perfmon:

SharePoint Distributed Cache Counters
• 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

Additionally, there are three groups of ‘AppFabric’ counters available. Note there are multiple instances – indicating the different caches present in the Distributed Cache.

• AppFabric Caching:Cache
• AppFabric Caching:Host
• AppFabric Caching:Secondary Host

Note: If “Cache Miss Count” should to rise significantly higher than expected (based on usage patterns), I think that might warrant some deeper investigation.

From…
SharePoint 2013 Distributed Cache service

General capacity planning and tuning guidance for Distributed Cache Service:

Plan for feeds and the Distributed Cache service in SharePoint Server 2013
See topics:
• Capacity planning for the Distributed Cache service
• Memory Allocation

Manage the Distributed Cache service in SharePoint Server 2013
See topic:
• Fine-tune the Distributed Cache service by using a Windows PowerShell script

How to check the existing memory allocation for the Distributed Cache service on a server:

Run the following command at the SharePoint Management Shell command prompt:

Use-CacheCluster
Get-AFCacheHostConfiguration -ComputerName ComputerName -CachePort "22233"

Where:
• ComputerName is the computer name of the server that you are running the SharePoint Management Shell cmdlet on.

How to modify the memory allocation of the Distributed Cache:

Update-SPDistributedCacheSize -CacheSizeInMB CacheSize

Notes:
• 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.

Warning About Using Cmdlets Add/Remove-SPDistributedCacheServiceInstance:

If you uninstall and reinstall the Distributed Cache Service Instance on a server (i.e. by running Remove-SPDistributedCacheServiceInstance and then Add-SPDistributedCacheServiceInstance) the cache host size will be reset to the default (5% of physical memory at time of installation). If removing and adding the cache service instance is part of your maintenance cycles, make sure to also modify the cache size afterwards if needed.

Comments (1)

  1. Hi,

    Higher Cache misses can be expected in certain scenarios, so it depends, it is not necessarily a reason for concern.
    Just make sure that the number of cache misses stabilizes to normal levels.

    A common misconception is that what you configure as maximum memory size will be the maximum "total" memory used by Distributed Cache, the service itself can add 100% extra memory (overhead).

    Also don't forget to set the account again when adding/removing a host in case you don't use the Farm account, not just the memory size.

Skip to main content