WS2008 – Dynamic cache service for managing filesystem cache WS2008 and R2

Dynamic cache service is used for managing file system cache dynamically, this is required when we have situations where 80% of physical memory is consumed by file system cache and when this happens we might experience performance issues on servers like system hangs, application errors, app crash.. etc.

Memory management in Microsoft Windows operating systems uses a demand-based algorithm. If any process requests and uses a large amount of memory, the size of the working set (the number of memory pages in the physical RAM) of the process increases. If these requests are continuous and unchecked, the working set of the process will grow to consume all the physical RAM. In this situation, the working sets for all the other processes are paged out to the hard disk. This behavior decreases the performance of applications and services because the memory pages are continuously written to the hard disk and read from the hard disk.

This behavior also applies to the working set of the system file cache. If there is a continuous and high volume of cached read requests from any process or from any driver, the working set size of the system file cache will grow to meet this demand. The system file cache consumes the physical RAM. Therefore, sufficient amounts of physical RAM are not available for other processes.

On 64-bit versions of Windows operating systems, the size of the virtual address range is typically larger than the physical RAM. In this situation, the working set for the system file cache can increase to consume most of the physical RAM.

To work around this issue, use the GetSystemFileCacheSize API function and the SetSystemFileCacheSize API function to set the maximum or minimum size value for the working sets of the system file cache. The use of these functions is the only supported method to restrict the consumption of physical memory by the system file cache.

The Microsoft Windows Dynamic Cache Service is a sample service that demonstrates one strategy to use these APIs to minimize the effects of this issue.

The memory management algorithms in Windows Server 2008 R2 operating systems were updated to address many file caching problems that were found in earlier versions of Windows. There are only certain unique situations in which you have to implement this service on computers that are running Windows Server 2008 R2.

Dynamic cache service is only applicable for Windows 2008 and Windows 2008 R2 versions of operating systems, initially Dynamic cache service was released only for Windows 2008 and later this year Microsoft released a latest version of Dynamic cache service which is supported on Windows 2008 R2.

I had a scenario where a Windows 2008 file server cluster node had 32 GB of physical memory and the file system cache was consuming 22 GB of server’s physical memory causing server to have hang issues, deadlock condition to the cluster resources and then there were countless unexpected failover of cluster resources causing downtime to the file share resources.

Usage of RamMap.exe tool revealed most of memory was consumed by MetaFile and that was File system cache, to fix this issue I had configured Dynamic cache service to limit file system cache to 2GB and that reduced overall cache usage by 20GB. After I had configured the Dynamic cache service there were no unexpected failover or downtime to file share resources and high memory utilization by file system cache issue was fixed..(see my previous post on how to use RamMap.exe)

The parameters I used to limit file system cache are mentioned below:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters
MaxSystemCacheMBytes: 2048
MinSystemCacheMBytes: 100

Latest version of Dynamic cache can be downloaded from : http://www.microsoft.com/en-us/download/details.aspx?id=9258

How to configure Dynamic Cache service on Windows 2008 or 2008 R2

1) Copy DynCache.exe to %SystemRoot%\System32.
2) From a command prompt, run: sc create DynCache binpath= %SystemRoot%\System32\DynCache.exe start= auto type= own DisplayName= “Dynamic Cache Service”
3) Import the DynCache.reg registry file.  This registry file contains default settings that you will probably want to modify.
4) Dynamic cache service will monitor the changes made its parameters in registry and any changes made will not require to reboot the server.

To uninstall this service, execute the following commands:
sc stop DynCache
sc delete DynCache

About asifkhandevadi

Hello, I have been working on windows since 9 years and currently working as windows, VMware and MS clustering SME at IBM. Whenever I get free time I participate in Microsoft forums and write some blogs to enhance my technical and communication skills through knowledge sharing. Please contact me on FB or Linkedin if you need any assistance on troubleshooting, implementation and virtualizaton.
This entry was posted in Dynamic cache service, Windows, Windows Troubleshooting and tagged , , . Bookmark the permalink.

4 Responses to WS2008 – Dynamic cache service for managing filesystem cache WS2008 and R2

  1. Jim says:

    So I tried setting up the Dynamic Cache service because my “Mapped File grows until the system becomes non-responsive. I have two apps running that I thought might cause this issue. The first is Mercury Mail server and the second in Blue Iris security recording software. Below is how I have the service configured but the system keeps consuming cache until it is non-operational/non-responsive. Any ideas?

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache]
    “Type”=dword:00000010
    “Start”=dword:00000002
    “ErrorControl”=dword:00000001
    “ImagePath”=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,\
    5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,79,00,6e,\
    00,43,00,61,00,63,00,68,00,65,00,2e,00,65,00,78,00,65,00,00,00
    “DisplayName”=”Dynamic Cache Service”
    “ObjectName”=”LocalSystem”

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters]
    “BackOffMBytesOnLowMemory”=dword:000001f4
    “MaxSystemCacheMBytes”=dword:0000001e
    “MinSystemCacheMBytes”=dword:00000064
    “SampleIntervalSecs”=dword:0000001e
    “CacheUpdateThresholdMBytes”=dword:00000064

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters\blueiris.exe]
    “AdditionalBackoffMBytes”=dword:000003e8

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters\mercury.exe]
    “AdditionalBackoffMBytes”=dword:000003e8

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters\Notepad]
    “AdditionalBackoffMBytes”=dword:0000000a

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters\sqlservr]
    “AdditionalBackOffCounter”=”\\SQLServer:Memory Manager\\Total Server Memory (KB)”

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DynCache\Parameters\System]
    “AdditionalBackoffMBytes”=dword:000003e8

    Like

    • Helllo Jim, Sorrry I couldnt reply you I was busy with my work and other assignments.
      What is the OS version you are using?
      its Physical or virtual machines?
      What is the size of the physical memory?

      Here is the dynamic cache service parameters config which I had used on our file servers which had high system cache usage. save this to .reg file and import it on the server which has problems. Also before importing these settings make sure you save the existing settings to a reg file.

      contents of reg file
      ———
      Windows Registry Editor Version 5.00

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache]
      “Type”=dword:00000010
      “Start”=dword:00000002
      “ErrorControl”=dword:00000001
      “ImagePath”=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,\
      5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,79,00,6e,\
      00,43,00,61,00,63,00,68,00,65,00,2e,00,65,00,78,00,65,00,00,00
      “DisplayName”=”Dynamic Cache Service”
      “ObjectName”=”LocalSystem”

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters]
      “BackOffMBytesOnLowMemory”=dword:000001f4
      “MaxSystemCacheMBytes”=dword:00000800
      “MinSystemCacheMBytes”=dword:00000064
      “SampleIntervalSecs”=dword:0000003c
      “CacheUpdateThresholdMBytes”=dword:00000064

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\Notepad]
      “AdditionalBackoffMBytes”=dword:0000000a

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\sqlservr]
      “AdditionalBackOffCounter”=”\\SQLServer:Memory Manager\\Total Server Memory (KB)”

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\System]
      ———————
      mail me at asifkhandevadi@gmail.com if you need the reg file

      Like

  2. Abdul Khaliq says:

    The values should be in Decimal or Hex, I have set the memory limit to 2 GB, But Still it grows

    MaxSystemCacheMBytes: 2048
    MinSystemCacheMBytes: 100

    Like

    • Hello Abdul,

      What is the os version you are using?

      You can use the below .reg file contents to configure your dynamic cache service

      —–
      Windows Registry Editor Version 5.00

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache]
      “Type”=dword:00000010
      “Start”=dword:00000002
      “ErrorControl”=dword:00000001
      “ImagePath”=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,\
      5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,79,00,6e,\
      00,43,00,61,00,63,00,68,00,65,00,2e,00,65,00,78,00,65,00,00,00
      “DisplayName”=”Dynamic Cache Service”
      “ObjectName”=”LocalSystem”

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters]
      “BackOffMBytesOnLowMemory”=dword:000001f4
      “MaxSystemCacheMBytes”=dword:00000800
      “MinSystemCacheMBytes”=dword:00000064
      “SampleIntervalSecs”=dword:0000003c
      “CacheUpdateThresholdMBytes”=dword:00000064

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\Notepad]
      “AdditionalBackoffMBytes”=dword:0000000a

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\sqlservr]
      “AdditionalBackOffCounter”=”\\SQLServer:Memory Manager\\Total Server Memory (KB)”

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DynCache\Parameters\System]


      mail me at asifkhandevadi@gmail.com if you need the reg file

      Like

Leave a comment