Beware Windows Disk Caching

Millennia Blog - DiskCaching 1

This is a problem that is probably as old as Windows but still catches a surprising amount of people out, and can be incredibly troublesome – especially to any system that uses constant logging, such as databases or journalling file systems.

The default option in every version of Windows to date is to switch disk caching on, which means a performance boost when disk writes are acknowledged to an application before committing to disk, but can also put your data at risk if an outage occurs before that data is secured on disk.

This outage may even be a simple as high latency, as the cache is relatively small so in a busy system may be overrun when faced with large storage system latency, potentially leading to corruption of data – particularly in things like SQL Server logs. The corruption is unlikely to be severe in this case, but can lead to situations where the log needs to be reset (by flipping to simple mode, back again, and running a differential backup), and this then leads to loss of point in time recovery options.

In my opinion where data integrity is crucial, as in database systems, it should be standard practice to switch windows caching off – thereby ensuring that data is always committed to the storage system before acknowledging to the application. The performance change is today’s systems is unlikely to be that noticeable, but the increase in data integrity is more than worth it in any case.

This procedure is performed on the Windows server in Computer Management, and by going to Disk Management, right-clicking the disks and selecting Properties the caching configuration can be altered in Policies (below).


Notice how write caching is the default?

Select the option that disables this (needs a reboot to bring this in) and you will then have a much more secure environment for critical data.

Quite why this remains a default, and how many people think to even look at this option until one day hit by a spurious data corruption problem I don’t know, but I certainly am making it a standard practice in all my managed environments.