Archive for the ‘AppFabric’ Category

AppFabric–Unable to change database stores

January 25, 2016 Leave a comment

*Bear in mind that AppFabric is no longer supported and will EOL in 2017 (


Because AppFabric depends on IIS, sometimes Windows Update can cause it to fail unexpectedly and the only way to get it fixed seems to be to remove and recreate the entire cache cluster.

Remove SQL connection strings

  1. Run IIS Manager
  2. Click on Configuration Editor
  3. Click on the dropdown and select connectionStrings
  4. Click on “..”
  5. Select the 2 AppFabric ConnectionStrings and remove them
  6. Click Apply

Removing Cache Cluster

In each of the cache server

  1. run Caching Administration Window Powershell as Administrator
  2. run Unregister-CacheHost
  3. run Remove-CacheHost

Now delete the actual database that is storing the AppFabric Caching service data


You can now proceed to recreate the entire cache cluster

Categories: AppFabric

Optimizing AppFabric 1.1 for Session State

February 24, 2015 Leave a comment

Amazingly although there are a lot of resources on using AppFabric for SessionState, there is no single site that attempts to give you all the necessary settings in order to run Appfabric for session state properly


Here are some of the settings which you need to use in order to optimize AppFabric

<td valign="top" Type
Parent Setting Reason
AppFabric Settings > Advancedproperties <transportProperties maxBufferPoolSize=”2147483647″ maxBufferSize=”2147483647″ /> Session states might be big (imagine those with huge gridviews) so putting it as a bigger size is necessary in order not to encounter errors with too small size to store viewstate
AppFabric Settings > Advancedproperties <partitionStoreConnectionSettings leadHostManagement=”false” /> If you are using a HADRON setup for SQL Server, you might want to set leadhostmanagement to false so that SQL manages the cache cluster rather than lead hosts, this way as long as SQL is up, your caching service is always up.

If you use lead hosts, make sure that there is always at least 2 lead host active else the ENTIRE cluster will go down

For more details refer to here

AppFabric Powershell Set-CacheConfig -CacheName Web-Session -Eviction None Make sure the Eviction property for the session cache is set to none instead of LRU else some weird things may happen during eviction
AppFabric Powershell
new-cache MyCache -Secondaries 1
Enable secondaries for the session state, you don’t want things to go missing just because a server went down
Application Ensure you are running the latest cumulative update for AppFabric (as of writing CU5)
Infrastructure Appfabric is designed for scale out rather than scale up, so 4 servers with 32gb of ram is better than 2 servers with 64 gb of ram. In fact the more servers the merrier.

Additionally the more servers there are, the better the performance since more servers can respond to the requests

Infrastructure For high availability and best performance, use SQL server rather than file server
web.config Ensure you are running the latest DLL for AppFabric
web.config sessionState Ensure you are using Microsoft [dot] Web [dot] DistributedCache [dot] DistributedCacheSessionStateStoreProvider as the Session provider
web.config sessionState useBlobMode=”false” Set useblobmode = false so that the web server only grabs what it needs rather than the entire session. However if your application generally uses everything in session, then set this to true instead so that lesser round trips are needed
web.config dataCacheClients <transportProperties connectionBufferSize=”131072″ maxBufferPoolSize=”104857600″

maxBufferSize=”104857600″ maxOutputDelay=”2″ channelInitializationTimeout=”60000″


update the transport properties to be the same as appfabric settings (or lesser) so that appfabric can optimize the connections
web.config dataCacheClients <localCache isEnabled=”true” sync=”TimeoutBased” objectCount=”1000″ ttlValue=”600″ /> Enable localcache so that some items can be stored locally instead of constantly grabbing from the server
Categories: AppFabric

Changes in web.config between AppFabric 1.1 vs AppFabric 1.1 CU [x]

February 12, 2015 Leave a comment

If you are using AppFabric 1.1 (without any cumulative updates), you will need the following DLLs inside the bin folder

  1. Microsoft.WindowsFabric.Common.dll
  2. Microsoft.WindowsFabric.Data.Common.dll
  3. Microsoft.ApplicationServer.Caching.Client.dll
  4. Microsoft.ApplicationServer.Caching.Core.dll

and you will be using the following code segments

<section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />

   <localCache isEnabled="true" sync="TimeoutBased" objectCount="1000" ttlValue="600" />
     <host name="host01" cachePort="22233" />
     <host name="host02" cachePort="22233" />

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
     <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="cacheName" sharedId="sharedID" />


If you upgrade to any CU (currently at CU5), note that there are a few changes made to appfabric client configuration (changes in red)

You will need the following DLLs inside the bin folder

  1. Microsoft.WindowsFabric.Common.dll
  2. Microsoft.WindowsFabric.Data.Common.dll
  3. Microsoft.ApplicationServer.Caching.Client.dll
  4. Microsoft.ApplicationServer.Caching.Core.dll
  5. Microsoft.Web.DistributedCache.dll


Code segments have also been modified

<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />


  <dataCacheClient name="default">
    <localCache isEnabled="true" sync="TimeoutBased" objectCount="1000" ttlValue="600" />
      <host name="host01" cachePort="22233" />
      <host name="host02" cachePort="22233" />

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
    <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="cacheName" useBlobMode="false" applicationName ="sharedID" />

Categories: AppFabric

Setting up AppFabric on Windows 2012R2

February 12, 2015 1 comment

As an update to, here are the steps to install AppFabric on a CLEAN install of Win2012R2


Not the first time?

Goto Groups Management and delete the AS_Administrators and AS_Observers groups


Preflight Check

  1. AppFabric 1.1: Download from
  2. AppFabric 1.1 CU 5: Download from
  3. Windows Server 2012R2 DVD mounted on D Drive


Setting up AppFabric Pre-Requisites

Use the following powershell script to setup all the necessary pre-requisites for AppFabric

#ensures running as admin
$RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")

if (!$RunningAsAdmin)
    Write-Warning "Must be executed in Administrator level shell."
    Write-Warning "Script Cancelled!"

$Updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings

if ($Updates.ReadOnly -eq $True) { Write-Error "Cannot update Windows Update settings due to GPO restrictions." }

else {
    $Updates.NotificationLevel = 4 #Enable
    $Updates.ScheduledInstallationDay  = 0
    Write-Output "Automatic Windows Updates enabled."
Install-WindowsFeature Web-WebServer, Web-Mgmt-Console, NET-Framework-Core,Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors,Web-Static-Content, Web-Http-Logging, Web-Stat-Compression, Web-Filtering -IncludeManagementTools -Source D:\Sources\Sxs

Installing AppFabric

  1. Run the AppFabric Installer WindowsServerAppFabricSetup_x64.exe
  2. Accept the license agreement and click Next
  3. Decide whether you want to help Microsoft with the setup experience and then click Next
  4. Just click Next
  5. To be on the safe side, checkbox everything and click Next
  6. Click install and wait for the installation to be completed
  7. Once it is done, uncheck Launch configuration tool and click Finish
  8. Now double click on AppFabric1.1-KB2932678-x64-ENU and install AppFabric 1.1 CU5
Categories: AppFabric

Commonly used AppFabric cmdlets

January 7, 2014 Leave a comment

Note, all cmdlets must run in administrator mode powershell preferable from the Caching Administration shortcut, else in any normal powershell, run

import-module DistributedCacheAdministration



An easy way to get all the commands available in the module is to run the following powershell

Get-Command -module DistributedCacheAdministration | Sort-Object > C:\AppFabric.txt


Get-AFCacheHostStatus, gets the status of the cache hosts in the cluster



Get-CacheStatistics [cachename], gets statistics about the cache


Get-CacheClusterHealth, gets the health of the Cache Cluster



Get-CacheHostConfig, gets the host configuration



Get-CacheConfig [cachename], gets the cache configuration







The name of the cache.


The default time that items reside in the cache before expiring.


The type of cache. This is always Partitioned.


A value of 1 indicates that the cache uses the high availability feature.


Indicates whether objects in the cache can expire.


Specifies an eviction type of Least-Recently-Used (LRU) or None.


Indicates whether notifications are enabled for this cache.

Taken from

Some other useful URLs

Categories: AppFabric

AppFabric 1.1–Auto Start on computer start up

January 7, 2014 2 comments

One of the things about AppFabric is that you cannot run it directly via services



NEVER and I mean NEVER set this to automatic, you will pay dearly for this


The recommended way is to run the Caching Administration Powershell shortcut


and then run Start-CacheHost


HOWEVER, there is a way for AppFabric to automatically start upon computer start up, what you need to do is to create the following powershell script and save it somewhere, e.g c:\appfabric.ps1


import-module DistributedCacheAdministration

$computer = gc env:computername


start-cachehost -hostname $computer -cacheport 22233


Then add a scheduled task with the following settings








Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Arguments: C:\appfabric.ps1


Reboot the computer and watch AppFabric automagically startup on boot, enjoy!

Categories: AppFabric

AppFabric on Windows Server 2012 R2

January 7, 2014 2 comments

If you are using Windows Server 2012R2, following the steps in will get it working.

HOWEVER if you need cache secondaries i.e

New-Cache Cache1 –Secondaries 1

You will realize that cache redundancy is not working at all, this is because AppFabric is looking for an enterprise version of windows, which is non-existent in Windows Server 2012R2


What you need to do is to download AppFabric 1.1 CU 4 found at This enables the High Availability feature in Windows Server 2012 Standard SKU and above


For safety, please down your entire caching service before applying this CU, the CU does attempt to stop the cache host, but always err on the safe side

Categories: AppFabric