ZFS is local storage; we mean storage within a single host by default when we talk about it. It has a wide range of applications:
- ZFS is suitable for home use, where not the most expensive equipment and not the fastest disks, you can use the processor for additional calculations (because it is usually idle). The advantage of ZFS is that it is a convenient constructor. It is unnecessary to use separate SSDs; you can even create a pool directly on the file, convenient for tests.
- Another classic option is NFS storage; there are more disks, we start thinking about synchronous recording and cache, and here you can substitute additional blocks in the form of SSDs.
- ZFS can also be used as large storage when more than a hundred disks are in one pool; all this should work and be restored if the disks crash, which is a problem for any large storage.
Blocks like ARC, ZIL, and so on are not disks that we can use; these are virtual concepts, and they are always in ZFS. We can move them to faster independent media.
ZIL can be placed on the so-called Slog, which does not need to be large since synchronous recording usually comes in a small block and is quickly dumped to the main storage. It is important to write a specific data block as quickly as possible, report to the client about a successful writer, and not write as much data as possible (hello, DBMS!). Slog needs to be read-only on power failure.
ARC can be augmented with one or more SSDs and offload certain data, such as cache only metadata or data sequentially or randomly read from main storage.
There are many variations on how to set up ZFS. It is possible to optimize any load profile, starting from the block size that we operate with. For example, when we want to optimize copy-on-write, we can write in a larger block than in classical file systems, ZFS defaults to 128 KB per block.
Pros And Cons Of ZFS Versus Hardware Solutions
The hardware solution has advantages: we transfer a specific computing load to its processor, hoping that it will cope. You can also use a hardware RAID controller with non-volatile memory or cache and shift the responsibility for the problem with synchronous writing to it.
The disadvantages of a hardware solution are that you need to look for a complete analog in the event of a failure. Hardware RAID knows nothing about data, only about blocks. Therefore, it cannot somehow be optimized for a specific situation.
And there is another point that is rarely mentioned: in the case of hardware and other software solutions, we configure them once; that is, we have common settings: one block size, such and such stripes, and so on. After setting up, a volume can be effectively worked with only with the specified settings. Hence, another plus of ZFS is the ability to configure one pool for different loads by creating separate datasets with different settings.
Dataset is a separate file system in ZFS terminology with its settings. For example, for a DBMS, you can create a separate space for the primary data with a block size of 8 KB and a separate dataset optimized for WAL-log with a block size of 16 KB. In this case, everything will work efficiently. I want to compress some data – great, zfs set compression=on. Other data is read infrequently and may needlessly flush out ARC – no problem, zfs set primarycache=metadata.
Having one pool, you can configure at least each dataset for a specific operation. We adapt to applications as much as possible. That is, ZFS is a very flexible software solution.
In the case of ZFS, all metadata about the file system is written conditionally in the disk header. If the server is broken, you can pull out the disks and transfer them to another server. If there is a compatible version of ZFS, the system will scan them and collect the same pool again.
Any software solution allows you to do this; information about the structure of this array is stored next to the data. But ZFS stores this information on each disk – you don’t even need to specify the order, indicate that there is a pool somewhere, you need to import it. The system will either collect it or show what went wrong. Also, the pool’s state can be rolled back several transactions back if there was an error in them.