WhatIs.com

write-through

By Stephen J. Bigelow

What is write-through in storage?

Write-through is a storage method in which data is written into the cache and the corresponding main memory location at the same time.

With write-through caching, the computer's central processing unit writes data to its local processor cache and holds off on executing the corresponding application until the same data is also successfully written to the associated storage resource, which is usually main memory -- RAM -- or disk storage. The processor maintains high-speed access to cached data, while ensuring complete consistency between cache and data storage.

How does write-through cache work?

The concept of caching is well established in computer design as a means of accelerating processor and computer performance by placing frequently used data in a small amount of extremely fast memory -- the cache -- which is placed adjacent to the processor. This allows the processor to find often-used data much faster than accessing the same data from disk or even from much faster main memory. Modern processors frequently work with several levels of cache, such as first-level, or L1, cache or second-level, or L2, cache.

When a processor writes or outputs data, that data is first placed in a cache. The cache contents are then written to main memory or disk using any of the following three major algorithms or policies:

What is write-through cache used for?

Write-through cache is a caching technique or policy that controls how a processor and its local cache interact with other principal storage assets within the computer, such as RAM or disk -- whether solid-state drive or traditional hard disk drive -- and some storage-centric enterprise applications such as Structured Query Language, or SQL.

Write-through cache, as the name implies, writes data to the processor's local cache first and then immediately writes that cached data through to the final storage target in memory or disk. The application's execution halts until the data is successfully written to the final storage asset.

The purpose of write-through cache is to achieve data consistency between the processor's cache and application storage. Write-through caching ensures data in cache and storage is always identical, so there's no chance of data loss or corruption if the application crashes or the computer system fails before cache is written, which might happen with write-back caching. Write-through caching is often the preferred technique for critical computing tasks that can't tolerate the risk of data loss.

However, write-through caching holds application execution until new cache data is committed to storage. This can impose a slight penalty on effective or apparent application performance.

Write-through vs. write-back

Both write-through and write-back caching policies define the way that data is moved from the cache to major storage such as memory or disk.

Write-through cache immediately copies new cache data to corresponding storage in main memory or disk. This ensures data is always consistent between cache and storage before application execution is allowed to continue. Write-through cache is considered the safest form of caching because no data is lost or corrupted if the application or system fails. But this comes at the expense of application performance.

By comparison, write-back cache allows application execution to continue before cached data is committed to storage. Cached data is copied to storage at certain intervals or as a background task. This allows for better application performance, but it also poses a risk of data loss or corruption if the application or system should fail before cached data is committed to storage.

What are the benefits and disadvantages of write-through cache?

As a general concept, processor cache often helps to enhance application performance by allowing a processor to access recent data from cache far faster than it could access that same data from other storage resources such as main memory or disk. However, for cache to be helpful, the application needs the processor to read the same cached data often -- otherwise there's no need for cache.

Write-through cache provides this processor performance benefit by writing data to a cache first. However, the new data placed into the cache is also committed or copied to the corresponding location in main memory or disk before the application's execution is allowed to continue. This ensures the data in cache and storage is always consistent and there's no data lost or corrupted if the application fails for any reason. Write-through cache is usually a preferred technique for important applications that can't tolerate the risk of data loss.

However, the write-through process must halt application execution until the data is fully committed to storage. While this might only take a matter of milliseconds, frequent caching results in frequent pauses, and this can reduce the application's apparent performance. Human users typically won't be able to discern any impact of caching policies on application performance, but performance-centric applications might not be appropriate for write-through caching.

Learn how cloud storage caching works and the different types of caching appliances.

08 Sep 2023

All Rights Reserved, Copyright 1999 - 2024, TechTarget | Read our Privacy Statement