### **R**edundant **A**rray of **I**ndependent **D**isks
...
...
@@ -75,10 +72,23 @@ It's important to know that a RAID0 and RAID1 requires at least two disks, and a
## Cache in ZFS
### Read caching:
ARC (**A**daptive **R**placement **C**ache)
ARC (**A**daptive **R**placement **C**ache) - Simple RAM cache, hot data blocks are stored in memory for faster acces, ZFS tries to fill all RAM disponible at max, if max level is achieved, oldest blocks gets flushed from memory and needs to be taken in the disk if a read operation requires then again.
L2ARC (**L**evel **2****ARC**) - Adds SSDs in cache flow so oldest data removed from RAM gets on a device faster than hard drives.
### Write caching:
By default, ZFS stores all write requests in RAM as Transaction Groups (**TXGs**) and foward them to the disk in a setted time interval (5 seconds as default). This benefits performance as all disk writes are somewhat organized and is easier to disks to process them. In a power failure event, this system also avoid data inconsistency as no parcial writes will be executed, instead, all data in TXG will be flushed as it is stored in a volatile data device.
The two types of writes in ZFS are:
#### Asynchronous:
Simple RAM cache, hot data blocks are stored in memory for faster acces, ZFS tries to fill all RAM disponible at max, if max level is achieved, oldest blocks gets flushed from memory and needs to be taken in the disk if a read operation requires then again.
- Data immediately cached in RAM and seen as completed by client, then written to disk;
- If a power failure occurs, all data in TXGs is lost, so it's very fast but no so consistent.
L2ARC (**L**evel **2****ARC**)
#### Synchronous:
Adds SSDs in cache flow so oldest data removed from RAM gets on a device faster than hard drives.
- Data still goes to RAM first, but client just see acknowledge if data has been written to persistent storage media. It's slower on client side.
- There is a part o ZFS pool called ZFS Intent Log (**ZIL**), this blocks stores all write transactions initiations and receive the acknowledge of completion to forward to the client. This way, if a write fails, there is a persistent memory block logging that some data was not written and prevents data loss
- ZIL is reliable if implemented in a faster memory device, as an SSD, usually on a separate device.