How to patch SharePoint Distributed Cache the proper way

SharePoint 2013 runs a service called the SharePoint Distributed Cache. The underlying application is Microsoft App Fabric. You may be running an old version of App Fabric and it needs your attention now!

An unpatched Distributed Cache may be the cause of a lot of your SharePoint farms performance issues.

The problem: A lot of blogs have misleading and wrong information on how to properly patch the SharePoint Distributed Cache. Following them will only cause you more issues down the track. Out of frustration, I have documented the steps on how to patch the SharePoint Distributed Cache the proper “manual” way with manual checks. If you follow these steps, you will have zero down time and hopefully a better performing SharePoint 2013 farm if you were on a very early App Fabric CU.

Which AppFabric / Distributed Cache CU do I install?
My advice is to generally update AppFabric with the latest providing it fixes issues that you are currently facing. Also, ensure that there are no obvious regressions with it by doing some research on the Internet. To determine the latest App Fabric Cumulative Update, http://www.jeremytaylor.net/tag/cumulative-updates+appfabric

 

Here are the steps on how to patch the SharePoint Distributed Cache:

1. Take stock of your Distributed Cache servers

Get-SPServiceInstance | ? {($_.service.tostring()) -eq "SPDistributedCacheService Name=AppFabricCachingService"} | select Server, Status

 

2. Ensure that Microsoft .NET Framework 4.5 is installed

Regedit: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full

Ensure the version contains “4.5.xxx”. E.g. 4.5.51209

 

3. Remove server from the load balancer if applicable.

4. Shutdown the service instance on one machine

Add-pssnapin Microsoft.SharePoint.PowerShell
Stop-SPDistributedCacheServiceInstance –Graceful
Remove-SPDistributedCacheServiceInstance

(wait for a few minutes after running this cmd)

5. Run this to check what SharePoint thinks the list of Distributed Cache servers are:

Get-SPServiceInstance | ? {($_.service.tostring()) -eq "SPDistributedCacheService Name=AppFabricCachingService"} | select Server, Status

Reference: http://blogs.msdn.com/b/sambetts/archive/2014/03/19/sharepoint-2013-distributed-cache-appfabric-troubleshooting.aspx

 

6. Patch AppFabric 1.1

Manually run the Cumulative update file. E.g. AppFabric-KB3042099-x64-ENU.exe

It should generate a log file here for troubleshooting purposes if required:

C:\ProgramData\Microsoft\E-Business Servers Updates\Updates\Uninstall<number>\Setup.log

 

7. Check version number

Running the below command should display the desired version level.

(Get-ItemProperty “C:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules\DistributedCacheConfiguration\Microsoft.ApplicationServer.Caching.Configuration.dll” -Name VersionInfo).VersionInfo.ProductVersion

 

8. Apply the Background Garbage collection fix

Skip this step only if the Background Garbage collection fix has been already configured on all SharePoint Distributed cache servers.

To enable the fix, go to the following folder:

%ProgramFiles%\AppFabric 1.1 for Windows Server\

Open notepad and edit DistributedCacheService.exe.config

Paste in the following between the  </configSections> and    <dataCacheConfig> settings in the file:

<appSettings>
<add key=”backgroundGC” value=”true”/>
</appSettings>

Example:

</configSections>

<appSettings>

<add key=”backgroundGC” value=”true”/>

</appSettings>

<dataCacheConfig>

DistributedCacheServiceGarbageCollection

Don’t try it any other way as you will have issues starting the Distributed Cache service.

 

9. Post-patch operations

1. Some additional checks:

  • The Distributed Cache service was stopped earlier

No need to restart AppFabric Caching Service in Windows Services as it should be in the disabled state – since we removed this CacheHost from the Cache Cluster.

 

2. Reset IIS by running: iisreset /noforce

3. Start the service instance

Run:

Add-pssnapin Microsoft.SharePoint.PowerShell
Add-SPDistributedCacheServiceInstance
  1. Verify if the SharePoint Distributed Cache Service has been started on the server:
Get-SPServiceInstance | ? {($_.service.tostring()) -eq "SPDistributedCacheService Name=AppFabricCachingService"} | select Server, Status
  1. Ensure that the Cache host is up and running:
Use-CacheCluster
Get-CacheHost

AppFabricServiceStatus

10. Add back the server in the load balancer

11. Restart from 1 on the next machine

12. Don’t forget the rest of your SharePoint farm has AppFabric installed by default (even though not running). AppFabric on those servers need to be updated too without stopping or starting any services.
For this, run steps 6, 7 & 8 above.

 

4 thoughts on “How to patch SharePoint Distributed Cache the proper way

  1. Hi,
    I was able to upgrade the version of AppFabric however, I could not get the DistributedCache service started.

    I did not get any error message while running the commands on separate lines:
    Add-pssnapin Microsoft.SharePoint.PowerShell
    Add-SPDistributedCacheServiceInstance

    Please help

Leave a Reply

Your email address will not be published. Required fields are marked *