SharePoint 2013/2016 Distributed Cache Settings
Just some notes about the SharePoint 2013/2016 Distributed Cache configuration from the field.
1. Where to run the Distributed Cache (in case the SharePoint farm has multiple SharePoint servers)
Run the Distributed Cache on at least (and no more) 2 SharePoint servers
Preferably do not run the Distributed Cache on SharePoint servers which also run SharePoint Search
For maximum performance and availability the Distributed Cache is run on dedicated Cache servers
The Windows PowerShell commands for Distributed Cache diagnoses and configuration must be run at a SharePoint Cache Host.
2. Print the Cache Host summary
Use-CacheCluster
Get-CacheHost
Output:
HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
sp01.sigylon.nl:22233 AppFabricCachingService UP 3 [3,3][1,3]
sp02.sigylon.nl:22233 AppFabricCachingService UP 3 [3,3][1,3]
Make sure the Service Status of both Cache Hosts is UP.
3. Print the Cache Host basic settings
Use-CacheCluster
Get-CacheHost | ForEach-Object {
Get-CacheHostConfig –ComputerName $_.HostName -CachePort 22233
}
Output:
HostName : sp01.sigylon.nl
ClusterPort : 22234
CachePort : 22233
ArbitrationPort : 22235
ReplicationPort : 22236
Size : 819 MB
ServiceName : AppFabricCachingService
HighWatermark : 99%
LowWatermark : 90%
IsLeadHost : True
HostName : sp02.sigylon.nl
ClusterPort : 22234
CachePort : 22233
ArbitrationPort : 22235
ReplicationPort : 22236
Size : 819 MB
ServiceName : AppFabricCachingService
HighWatermark : 99%
LowWatermark : 90%
IsLeadHost : True
4. Print the Cache Cluster Health details
Use-CacheCluster
Get-CacheClusterHealth
Too much output, just see it for yourself.
5. Distributed Cache tuning
The Distributed Cache has 10 container types which can be configured:
DistributedLogonTokenCache
DistributedViewStateCache
DistributedAccessCache
DistributedActivityFeedCache
DistributedActivityFeedLMTCache
DistributedBouncerCache
DistributedDefaultCache
DistributedSearchCache
DistributedSecurityTrimmingCache
DistributedServerToAppServerAccessTokenCache
The properties of interest are:
MaxConnectionsToServer
RequestTimeout
ChannelOpenTimeOut
Use the Windows PowerShell code below to list the default configuration:
Add-PSSnapin Microsoft.SharePoint.PowerShell
# Create the list of Distributed Cache Container Types.
$spDistributedCacheContainerTypes = @()
$spDistributedCacheContainerTypes += "DistributedLogonTokenCache"
$spDistributedCacheContainerTypes += "DistributedViewStateCache"
$spDistributedCacheContainerTypes += "DistributedAccessCache"
$spDistributedCacheContainerTypes += "DistributedActivityFeedCache"
$spDistributedCacheContainerTypes += "DistributedActivityFeedLMTCache"
$spDistributedCacheContainerTypes += "DistributedBouncerCache"
$spDistributedCacheContainerTypes += "DistributedDefaultCache"
$spDistributedCacheContainerTypes += "DistributedSearchCache"
$spDistributedCacheContainerTypes += "DistributedSecurityTrimmingCache"
$spDistributedCacheContainerTypes += "DistributedServerToAppServerAccessTokenCache"
# Print the current Distributed Cache Settings for each Container Type.
$spDistributedCacheSettings = @()
ForEach ($spDistributedCacheContainerType in $spDistributedCacheContainerTypes)
{
$spDistributedCacheSetting = Get-SPDistributedCacheClientSetting `
-ContainerType $spDistributedCacheContainerType
$spDistributedCacheInfo = [PSCustomObject] @{
ContainerType = $spDistributedCacheContainerType
MaxConnectionsToServer = $spDistributedCacheSetting.MaxConnectionsToServer
RequestTimeout = $spDistributedCacheSetting.RequestTimeout
ChannelOpenTimeOut = $spDistributedCacheSetting.ChannelOpenTimeOut
}
$spDistributedCacheSettings += $spDistributedCacheInfo
}
$spDistributedCacheSettings | Format-Table -AutoSize
Output
ContainerType MaxConnectionsToServer RequestTimeout ChannelOpenTimeOut
------------- ---------------------- -------------- ------------------
DistributedLogonTokenCache 8 20 20
DistributedViewStateCache 8 20 20
DistributedAccessCache 8 3000 3000
DistributedActivityFeedCache 8 3000 3000
DistributedActivityFeedLMTCache 8 3000 3000
DistributedBouncerCache 8 3000 3000
DistributedDefaultCache 8 3000 3000
DistributedSearchCache 8 3000 3000
DistributedSecurityTrimmingCache 8 3000 3000
DistributedServerToAppServerAccessTokenCache 8 3000 3000
Remarks
- The MaxConnectionsToServer for all Container Types is set to 8. This setting is based on the number of Logical Processors of the Cache Host Servers. This number is far too high for a SharePoint Distributed Cache Cluster and will put an unnecessary high load on the Cache Host servers. Preferably the MaxConnectionsToServer property is set 1.
- The Container Types DistributedLogonTokenCache and DistributedViewStateCache have both properties RequestTimeout and ChannelOpenTimeout configured to 20 ms. These Timeouts are too narrow and will cause many reconnection retries. Preferable the Timeouts for all Distributed Cache Container Types are configured to 3000 ms.
The preferred configuration is applied by the Windows PowerShell code:
Add-PSSnapin Microsoft.SharePoint.PowerShell
# Create the list of Distributed Cache Container Types.
$spDistributedCacheContainerTypes = @()
$spDistributedCacheContainerTypes += "DistributedLogonTokenCache"
$spDistributedCacheContainerTypes += "DistributedViewStateCache"
$spDistributedCacheContainerTypes += "DistributedAccessCache"
$spDistributedCacheContainerTypes += "DistributedActivityFeedCache"
$spDistributedCacheContainerTypes += "DistributedActivityFeedLMTCache"
$spDistributedCacheContainerTypes += "DistributedBouncerCache"
$spDistributedCacheContainerTypes += "DistributedDefaultCache"
$spDistributedCacheContainerTypes += "DistributedSearchCache"
$spDistributedCacheContainerTypes += "DistributedSecurityTrimmingCache"
$spDistributedCacheContainerTypes += "DistributedServerToAppServerAccessTokenCache"
# If needed change the Distributed Cache Settings.
ForEach ($spDistributedCacheContainerType in $spDistributedCacheContainerTypes)
{
$spDistributedCacheSetting = Get-SPDistributedCacheClientSetting `
-ContainerType $spDistributedCacheContainerType
$spDistributedCacheSetting.MaxConnectionsToServer = 1
$spDistributedCacheSetting.RequestTimeout = 3000
$spDistributedCacheSetting.ChannelOpenTimeOut = 3000
Set-SPDistributedCacheClientSetting `
-ContainerType $spDistributedCacheContainerType $spDistributedCacheSetting
}
List the configuration after the new settings are applied (Re-use the code to print the default configuration):
ContainerType MaxConnectionsToServer RequestTimeout ChannelOpenTimeOut
------------- ---------------------- -------------- ------------------
DistributedLogonTokenCache 1 3000 3000
DistributedViewStateCache 1 3000 3000
DistributedAccessCache 1 3000 3000
DistributedActivityFeedCache 1 3000 3000
DistributedActivityFeedLMTCache 1 3000 3000
DistributedBouncerCache 1 3000 3000
DistributedDefaultCache 1 3000 3000
DistributedSearchCache 1 3000 3000
DistributedSecurityTrimmingCache 1 3000 3000
DistributedServerToAppServerAccessTokenCache 1 3000 3000
Thank you for reading, I hope this blog post was informative or helpful for you.
Hans.