diff --git a/ZFS-RAIDs.md b/ZFS-RAIDs.md index e092e52b75e3c676e24e8787ffd65f6929ce3312..973b065fab97c7e43ce818ebcd093757b9021734 100644 --- a/ZFS-RAIDs.md +++ b/ZFS-RAIDs.md @@ -3,9 +3,6 @@ - [x] ZFS description and capabilities - [x] RAID implementations in ZFS - [x] Cache systems in ZFS -___ - -- [ ] ZFS for DB or lvm+ext4 # RAIDs ### **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. + diff --git a/imgs/zil-writes.png b/imgs/zil-writes.png new file mode 100644 index 0000000000000000000000000000000000000000..120ed14cb76b4b54618487ef0efa9d6e10b1b7a0 Binary files /dev/null and b/imgs/zil-writes.png differ