Setting the AppFabric Cache MaxBufferSize

AppFabric Cache has a max buffer size of 8MB. If you’re using the SQL Provider, you need to export and re-import the Xml configuration file to modify this. Here’s a powershell script to do it for you, building on the blog post from Javi.

Save this to UpdateAppFabricCacheBufferSize.ps1

Param([int]$maxBufferSize)

Import-Module DistributedCacheAdministration, DistributedCacheConfiguration

Function UpdateBufferSizeInConfig ([string]$configFilename, [int]$maxBufferSize)
{
	$xml = New-Object XML
	$xml.Load($configFilename)
	$transportProperties = $xml.configuration.dataCache.advancedProperties.transportProperties
	if ($transportProperties -eq $NULL) {
	  $transportProperties = $xml.CreateElement("transportProperties")
	}
	$transportProperties.SetAttribute("maxBufferSize", "$maxBufferSize")
	$xml.configuration.dataCache.advancedProperties.appendChild($transportProperties)
	$xml.Save($configFilename)
}

$tempConfigLocation = "c:config.xml"

Use-CacheCluster
Export-CacheClusterConfig -File $tempConfigLocation

UpdateBufferSizeInConfig $tempConfigLocation $maxBufferSize

Stop-CacheCluster 
Import-CacheClusterConfig -File $tempConfigLocation -Force 
Start-CacheCluster

To change your buffer size to 15MB:

powershell ./UpdateAppFabricCacheBufferSize.ps1 15000000
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s