Wednesday, May 30, 2012

Code: How to Change AppFabric Cache Size on a Host

By default AppFabric will allocate 50% of the RAM on a machine for the cache.  If you want to change the available amount of memory for AppFabric cache on a host you'll need to stop the cluster and then run Set-CacheHostConfig

PS F:\> stop-cachecluster

HostName : CachePort      Service Name            Service Status Version Info
--------------------      ------------            -------------- ------------
MACHINE1:22233            AppFabricCachingService DOWN           1 [1,1][1,1]
MACHINE2:22233            AppFabricCachingService DOWN           1 [1,1][1,1]


PS F:\> set-cachehostconfig -HostName MACHINE1 -CachePort 22233 -CacheSize 2048


HostName        : MACHINE1
ClusterPort     : 22234
CachePort       : 22233
ArbitrationPort : 22235
ReplicationPort : 22236
Size            : 2048 MB
ServiceName     : AppFabricCachingService
HighWatermark   : 90%
LowWatermark    : 70%
IsLeadHost      : False



PS F:\> start-cachecluster

HostName : CachePort      Service Name            Service Status Version Info
--------------------      ------------            -------------- ------------
MACHINE1:22233            AppFabricCachingService UP             1 [1,1][1,1]
MACHINE2:22233            AppFabricCachingService UP             1 [1,1][1,1]