Archive

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 (http://blogs.msdn.com/b/appfabric/archive/2015/06/19/appfabric-1-1-for-windows-server-support-lifecycle-extension-4-11-2017.aspx)

 

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
    image
  3. Click on the dropdown and select connectionStrings
    image
  4. Click on “..”
    image
  5. Select the 2 AppFabric ConnectionStrings and remove them
    image
  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

Advertisements
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″

receiveTimeout=”600000″/>

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" />

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

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

 

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" />

 

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

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

Categories: AppFabric

Setting up AppFabric on Windows 2012R2

February 12, 2015 1 comment

As an update to https://jefferytay.wordpress.com/2014/01/07/appfabric-on-windows-server-2012-r2/, 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
image

 

Preflight Check

  1. AppFabric 1.1: Download from http://www.microsoft.com/en-sg/download/details.aspx?id=27115
  2. AppFabric 1.1 CU 5: Download from http://www.microsoft.com/en-sg/download/details.aspx?id=42281
  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!"
    return;
}

$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
    $Updates.Save()
    $Updates.Refresh()
    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
    image
  3. Decide whether you want to help Microsoft with the setup experience and then click Next
    image
  4. Just click Next
    image
  5. To be on the safe side, checkbox everything and click Next
    image
  6. Click install and wait for the installation to be completed
  7. Once it is done, uncheck Launch configuration tool and click Finish
    image
  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

image

 

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

image

 

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

image

Get-CacheClusterHealth, gets the health of the Cache Cluster

image

 

Get-CacheHostConfig, gets the host configuration

image

 

Get-CacheConfig [cachename], gets the cache configuration

image

image

 

Setting

Description

CacheName

The name of the cache.

TimeToLive

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

CacheType

The type of cache. This is always Partitioned.

Secondaries

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

IsExpirable

Indicates whether objects in the cache can expire.

EvictionType

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

NotificationsEnabled

Indicates whether notifications are enabled for this cache.

Taken from http://msdn.microsoft.com/en-us/library/ff921029(v=azure.10).aspx

Some other useful URLs

http://msdn.microsoft.com/en-us/library/ff921010(v=azure.10).aspx

http://msdn.microsoft.com/en-us/library/ff921023(v=azure.10).aspx

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

 

image

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

image

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

use-cachecluster

start-cachehost -hostname $computer -cacheport 22233

 

Then add a scheduled task with the following settings

General

image

 

Triggers

image

Actions

image

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 http://wp.me/pBjCs-am 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 http://support.microsoft.com/kb/2800726/en-us. 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