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:
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