ZFS cache and log
There are two kinds of cache, read cache and write cache.
Read cache
Called ARC and L2ARC.
ARC (Adaptive Replacement Cache)
In memory, caching the information that would require in the near future, while discarding the ones that will be needed furthest ahead in time.
This can be set using kernel/module parameter, such as zfs_arc_max
.
L2ARC (Level 2 ARC)
In cache device, extension of ARC. Can be created using following command
zpool add tank cache ada3
Note: tank
is the pool name, ada3
is the block device used for caching
Write cache
Called ZIL (ZFS Intent Log).
Asynchronous
By default, ZFS will cache write data in memory before write to disk, this is called asynchronous mode.
Synchronous
Synchronous will make sure data written to disk before continue, this can be set using following command
zfs set sync=always mypool/dataset1
ZFS Intent Log (ZIL)
This is the temporary space to store data before write into main disks, this can be used to speed up write operation. The write operation is considered as completed once data written into ZIL device, which is called SLOG (Separate Intent Log) devices, can be defined as follow
zpool add tank log ada3
Note: tank
is the pool name, ada3
is the block device used for slog
If worrying SLOG device faulty, it can be mirrored too.
zpool add tank log mirror ada3 ada4
References
Configuring ZFS Cache for High Speed IO
ZFS Performance with Databases (Cached)