The difference between Write-through and write-back in HDD cache write mechanism

Source: Internet
Author: User
Tags advantage

Write-through-write is do synchronously both to the cache and to the backing store.

Write-back (or Write-behind) –writing is done with the cache. A modified cache block was written back to the store and just before it is replaced.

Write-through (direct write mode) writes cached cache and back-end storage while data is being updated. The advantage of this pattern is that it is easy to operate, and the disadvantage is that data modifications need to be written to storage at the same time, and data writes slowly.

Write-back (write-back mode) writes cache caching only when data is updated. Cached data that is modified is written to the back-end store only when the data is replaced with the cache. The advantage of this pattern is that the data is written faster because there is no need for write storage; The disadvantage is that once the updated data is not written to storage, the system will lose power and the data cannot be recovered.

How to deal with write-misses write missing

For a write operation, there is a situation where the write cache missing data is present, and there are two ways to handle it:

Write Allocate (aka Fetch on Write) –datum at the Missed-write location are loaded to cache, followed by a write-hit opera tion. In the approach, write misses are similar to read-misses.

No-write Allocate (aka Write-no-allocate, write around) –datum at the Missed-write location are not loaded to cache, and I s written directly to the backing store. In this approach, actually only system reads are being cached.

Write allocate reads the write location into the cache and then takes a write-hit (cache hit write) operation. Write-missing operations are similar to read-missing operations.

The No-write allocate does not read the write location into the cache, but writes the data directly to the store. In this way, only read operations are cached.

Either Write-through or write-back can use one of the two ways of writing missing. It is usually write-back to use the Write allocate method, and Write-through no-write allocate; Because write allocate with Write-back can improve performance when writing to the same cache multiple times , but for Write-through it doesn't help.

Process flowchart

Write-through Mode processing process:

A Write-through cache with No-write allocation

Write-back Mode processing process:

A Write-back cache with Write allocation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.