Solaris: How to limit ZFS ARC cache maximum size

Written by - 0 comments

Published on February 28th 2014 - Listed in Solaris Unix ZFS

One of the reasons why ZFS is a fast file system is the use of a file system caching called ARC (Adaptive Replacement Cache), which runs in memory. 

The current size of ARC can be seen with the following command:

kstat -p zfs:0:arcstats:size
zfs:0:arcstats:size     12310432872

At the time of this output, ARC was using 11.4GB.

Although ARC should be intelligent enough to not occupy RAM which is needed by zones or applications, I have seen cases where ARC uses 50% of the total available memory and the other 50% were fully occupied by zones and applications, causing applications (like MySQL) to swap. That's a performance nightmare.

But there's a way to limit the ARC size by setting the value of zfs_arc_max. At the end of /etc/system I added the following lines:

* Limit ZFS Arc
set zfs:zfs_arc_max = 21474836480

This means that I have set a maximum limit for the zfs arc to 20GB (21474836480 Bytes).

After a reboot (and RAM-Upgrade at the same time), the memory graph clearly shows that the ARC size (represented by CACHES in the graph) has hit 20GB, but never went above it:

ZFS Arc Cache Memory Graph

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.