Pages

22 Jun 2018

Determine if SharePoint has enough memory allocated to the distributed cache service

After reading half a dozen articles explaining how to eyeball and calculate the distributed cache size I was wondering: Why no one suggests just to check the current consumption before changing anything? Here is a scary thought: What if we have a ton of memory and we don't need to add any more? I know, this sounds revolutionary.

This is a quick script that I've slapped together to show 1) maximum allocated memory for  the Distributed cache. 2) current usage for all AppFabric caches on the current server.

So, before bumping the Distributed cache, test the current consumption with the script below.


###### DETERMINE IF YOU HAVE ENOUGH MEMORY ALLOCATED TO DISTRIBUTED CACHE:
Add-PSSnapin Microsoft.SharePoint.Powershell
Use-CacheCluster
$hostname = hostname
$configuration = Get-AFCacheHostConfiguration -ComputerName $hostname -CachePort "22233"
Write-host Maximum Size: $($configuration.size)MB HostName: $($configuration.HostName) -ForegroundColor Blue
# Get-AFCache | % {Get-AFCacheConfiguration -CacheName $_.CacheName}
$caches = Get-AFCache | % {Get-AFCacheConfiguration -CacheName $_.CacheName}

 foreach($cache in $caches){
  $stats = Get-AFCacheStatistics $cache.CacheName
  Write-host $cache.CacheName -ForegroundColor Green Cache.
  Write-host Usage: $($stats.Size / 1MB) MB
  Write-host
 }

###### DETERMINE IF YOU HAVE ENOUGH MEMORY ALLOCATED TO DISTRIBUTED CACHE END

Here is the sample result:


No comments:

Post a Comment