Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between Write-through and Write-back

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the difference between Write-through and Write-back". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Write Through and Write Back

Write Through and Write Back are two ways to use the array card Cache, also known as overwrite and writeback. When write through is selected, the write disk operation of the system does not use the Cache of the array card, but directly interacts with the data of the disk. The write Back mode uses the array Cache as the setter between the system and the disk. The system first gives the data to the Cache, and then the Cache transmits the data to the disk.

When configuring the array, if it is not very clear, the default is fine, and the system will default according to the disk type.

The configuration in the production environment should be configured according to the specific business type and environment, for example: if there is an external UPS power supply, select Write Back, if there is no external power supply, and the data security requirements are very high, do not require too high performance, choose Write Through.

Write caching or write-through

Write-through means that writes do not use caching at all. Data is always written directly to disk. Turn off the write cache to free the cache for read operations. (cache is shared by read and write operations)

Write caching can improve the performance of write operations. The data is not written directly to disk; it is written to the cache. From an application point of view, it is much faster than waiting for a disk write operation to complete. Therefore, write performance can be improved. The data not written to the disk in the cache is written to the disk by the controller. On the surface, the read and write performance of Write cache mode is better than that of write-through mode, but it also depends on the disk access mode and disk load.

The write-back (write cache) method is usually faster when the disk load is light. When the load is heavy, whenever the data is written to the cache, it is immediately written to the disk to release the cache to save the new data to be written. At this time, if the data is written directly to the disk, the controller will run faster. Therefore, when the load is heavy, writing data to the cache first reduces throughput.

Starting and stopping cache flushing levels

These two settings affect how the controller handles data in the cache that is not written to disk and takes effect only in write-back cache mode. Writing data to disk in the cache is called flushing. You can configure the Starting and stopping cache flushing levels value, which represents the percentage of the entire cache size. When the data in the cache that is not written to disk reaches starting flushing value, the controller starts flushing (written to disk by cache). The flushing process stops when the amount of unwritten disk data in the cache is less than stop flush value. The controller always flush the old cache data first. The unwritten data in the cache is automatically flushing after staying for more than 20 seconds.

The typical start flushing level is 80%. Typically, stop flushing level is also set to 80%. In other words, the controller does not allow more than 80% of the cache to be used for write-back cache, but maintains this proportion as much as possible. If you use this setting, you can have more unwritten data in cache memory. This improves the performance of write operations, but at the expense of data protection. If you want data protection, you can use a lower start and stop values. You can adjust the read and write performance of the cache by setting these two parameters. The test shows that the performance is better when using similar start and stop flushing levels. If the stop level value is much lower than the start value, it will cause disk congestion during flushing.

Cache block size

This value refers to the size of the cache allocation unit, which can be 4K or 16K. Choosing the appropriate value can significantly improve the cache performance.

If the application accesses data less than 8K more often, and the cache block size is set to 16K, only part of the cache block is used for each access. Data of 8K or less is always stored in 16K cache block, which means that only 50% of the cache capacity is effectively used, resulting in performance degradation. 4K is suitable for the transmission of random Icano and small data blocks. On the other hand, if it is a continuous Imax O and uses a large segment size, it is best to choose 16K. A large cache block size means a small number of cache block and reduces cache consumption latency. In addition, for data of the same size, the cache block size is larger and the amount of cached data transfer is smaller.

Other relevant instructions:

Protect the data in memory

The function of the backup battery is to ensure that the data in the memory is not lost in case of a main power failure or a sudden power outage, so how to ensure the normal operation of the backup battery is particularly important. Backup battery in 2 cases, the system is considered to be unable to operate properly to protect the data in memory. First, when it is broken, the LED light on the back panel will turn on a red light. First, when the battery is charged, the LED light on the back panel will turn on yellow. The service life of the backup battery varies according to the number of charges and the cycle of power release, which depends on the user's own use of the disk array. In general, we recommend that it is best to replace the spare battery module (BBU) after 12 months of use. The backup battery is 3.5V when it is fully charged under normal circumstances, and it will automatically enter the charging state when its power drops to 2.7V. At this time, the system automatically switches the data writing to "Write-Through" mode because the power to protect memory data does not disappear. When the battery is fully charged, it automatically switches back to "Write-Back" mode. This action is performed by the event initiator (Event Trigger) function, which manages the backup battery with the initial value turned on (Enable) when the management software is installed. If you have not changed the initial settings, then the above actions will work properly. If the backup battery is broken and the data in the memory cannot be protected properly, and the management of the backup battery by the event initiator is set to the off state, we recommend that you manually change the data write mode to "Write-Through" mode to prevent data from being written into memory without power protection and the data being written will be lost when the main power failure or sudden power outage.

Reduce delay

When the memory "Write-Back" function is turned off, it enters the "Write-Through" mode, when the host data is not written to memory but directly to the hard disk. In "Write-Through" mode, all hard drives will access data blocks in an appropriate manner by their associated hosts, and most of the time the hard drives will be in a state of accepting write commands. At this time, as long as the disk array receives the write command from the host, the read and write head of the hard disk will look for the location of the read and write and wait for the hard disk to be in a writable state. This waiting phenomenon is the so-called Latency Time, while the hard disk is often in the state of waiting for writing, which increases the delay time, which not only shortens the service life of the hard disk, but also consumes more power. When the "Write-Back" function of memory is turned on, the data written to the hard disk from the host is first written in memory, and when the memory is full of data, the disk array controller will write a large number of data existing in the memory to the hard disk. This memory "Write-Back" mode replaces host write commands with write memory, which significantly reduces hard disk latency and provides a better write policy than "Write-Through" mode most of the time.

This is the end of the content of "what's the difference between Write-through and Write-back". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report