Configuring BranchCache on Windows Server

Enabling BranchCache on CM Distribution Points

In order for clients to be able to use BranchCache when downloading content from Configuration Manager distribution points (DPs), BranchCache must be enabled in Windows as well as Configuration Manager.

In the Configuration Manager console, open the Administration workspace and expand Site Configuration and select Servers and Site System Roles. Select which Distribution Points you want to enable and open the Distribution point Properties. Under the "General" tab, choose the option: Enable and configure BranchCache for this distribution point.

Enabling BranchCache on a distribution point will also install the feature in Windows. You can check the status of BranchCache on a given client by running the following PowerShell command:

Get-WindowsFeature | ? name -eq BranchCache

You can also enable BranchCache on a DP using PowerShell by connecting to PowerShell via the Configuration Manager Console and running the following command:

Set-CMDistributionPoint -EnableBranchCache $true -SiteSystemServerName <DistributionPointFQDN>

Note: If you are using more than one DP, the BranchCache 'Server Secret' is the same on each of them. The 'Server Secret' is stored in the registry:

HKLM:\Software\Microsoft\Windows NT\CurrentVersion\PeerDist\SecurityManager\Restricted

Value: Seed

If you have configured BranchCache functionality using the ConfigMgr UI then the same server secret will be automatically seeded across DPs.

Enabling BranchCache in Windows Server

BranchCache can be enabled in Windows by using the "Programs and Features" applet in Control Panel or by running the following PowerShell command:

Install-WindowsFeature -Name BranchCache

Modifying the Location of the BranchCache Folder

On a CM distribution point you might want to move the location of the local BranchCache cache folder. For example, to change the location of the local cache folder to D:\BranchCache\Localcache, create the folder structure and run the following command:

netsh br set localcache directory=D:\BranchCache\Localcache

Modifying the Size of the BranchCache Folder

To change the size of the local cache folder, see the following command:

netsh br set cachesize 
Usage: set cachesize [size=]{DEFAULT|<number in bytes>} [[percent=]{TRUE|FALSE}]
Examples:
      set cachesize DEFAULT
      set cachesize 20971520
      set cachesize size=20 percent=TRUE

Enabling Data Deduplication (Dedup)

At this point it is worth mentioning Data Deduplication and its interoperability with BranchCache. Data Deduplication is a server operating system feature that can help reduce redundant data and optimize free space. Dedup accomplishes this task by breaking files into chunks and then identifying unique chunks. While this is happening, a hash is created to act as a fingerprint for the chunks of data. Where this gets interesting is that dedup and BranchCache use the same hashing algorithm. This means that on a dedup enabled file server or Distribution Point, the CPU intensive file De-Duplication and chunk (segment) hash calculations are done by the dedup engine which runs on a scheduled basis. When a client requests the CI’s for a download the BranchCache engine can grab the Segment Hashes and only has to perform the Server Secret calculations before forwarding to the client. This helps to avoid time out issues and allows the CPU intensive workload to be scheduled outside core business hours.

Here at 2Pint Software we strongly recommend that customers enable Data Deduplication not just for the reasons given above but also for the core dedup efficiencies realized through reduced network traffic and storage requirements.

Step: Enable Deduplication on a Distribution Point

The following PowerShell script can be used to enable Dedup on a distribution point. Please note the $dedupVolume variable should be edited to match the drive letter specific to your DP.

#Set the drive letter
$dedupVolume = "E:"
Import-Module ServerManager
#Import-Module DeDuplication
Add-WindowsFeature -Name FS-Data-Deduplication
#Enable on volume
Enable-DedupVolume $dedupVolume
Set-DedupVolume -Volume $dedupVolume -MinimumFileAgeDays 0 -ExcludeFolder $dedupVolume\SMSPKG, $dedupVolume\SMSPKGSIG, $dedupVolume\SMSSIG$
Write-Output "Starting Dedup Jobs..."
$j = Start-DedupJob -Type Optimization -Memory 75 -Priority High -Volume $dedupVolume
$j = Start-DedupJob -Type GarbageCollection -Full -Memory 75 -Priority High -Volume $dedupVolume
$j = Start-DedupJob -Type Scrubbing -Full -Memory 75 -Priority High -Volume $dedupVolume
do
{
    Write-Output "Dedup jobs running.  Status:"
    $state = Get-DedupJob | Sort-Object StartTime -Descending
    $state | ft
    if ($state -eq $null) {Write-Output "Completing, please wait..."}
    sleep -s 5
} while ($state -ne $null)
#cls
Write-Output "Done DeDuping"
Get-DedupStatus | fl *

Last updated