Programster's Blog

Tutorials focusing on Linux, programming, and open-source

ZFS - Add L2ARC Device

ZFS

The Level 2 Adjustable Replacement Cache (L2ARC) is where cached content is put onto when it "falls off" the primary ARC (in RAM). This is because it hasn't been accessed frequently enough compared to other content which is being put into the primary cache (the ARC). If you think of the adding a device for the intent log as all about improving write speed (in synchronous workloads), you can think of adding an L2ARC device as all about improving read speeds.

Add RAM First - The L2ARC Isn't "Free"

Maintaining a L2ARC actually requires overhead in the primary ARC, so it could actually decrease performance in low-memory servers. In those scenarios, it would likely be better to just have more space in memory for the primary ARC, and not have the L2ARC. This is probably why some people may recommend only adding an L2ARC on servers that already have 64GB of RAM. The larger the L2ARC is, the more memory it will require to maintain. This post on reddit has a scenario where a 400GB L2ARC would require 6.37GB of RAM to maintain. If your server only has 8GB of RAM, this would be a dumb thing to do as the primary ARC would suffer.

Steps

sudo zpool add [pool name] cache [disk identifier]

For example:

sudo zpool add zpool1 cache \
/dev/disk/by-id/ata-Samsung_SSD_850_EVO_500GB_S3R3NF0J848724N-part2

Removing the L2ARC

If you change your mind and want to remove the L2ARC, just tell ZFS that you want to remove the device.

sudo zpool remove [pool name] [device name]

References

Last updated: 6th July 2019
First published: 16th August 2018