# Cache usage



## marvel (Jan 12, 2014)

Hi, I've been wondering about something. I only have 25G allocated yet ZFS already cached 140G on my SSDs in just one night. Is this expected behavior? What happens if it's full, will it auto overwrite stuff or will it start to take system memory? I didn't configure anything as to how much memory L2ARC can use, is there any place to do that? I tried to google on it but no clear answers.

Thanks!


```
capacity     operations    bandwidth
pool          alloc   free   read  write   read  write
------------  -----  -----  -----  -----  -----  -----
zroot         24.9G  1.79T      1    190  13.2K  11.2M
  mirror      24.9G  1.79T      1     77  13.2K  3.64M
    ada2p2        -      -      0     42  7.09K  3.64M
    ada3p2        -      -      0     42  6.63K  3.64M
logs              -      -      -      -      -      -
  mirror      4.55M  31.7G      0    112      0  7.58M
    gpt/log0      -      -      0    112     32  7.58M
    gpt/log1      -      -      0    112     32  7.58M
cache             -      -      -      -      -      -
  gpt/cache0  71.6G   120G      0     13      3  1.60M
  gpt/cache1  71.7G   120G      0     13      3  1.60M
------------  -----  -----  -----  -----  -----  -----
```


----------



## kpa (Jan 12, 2014)

It will drop the cached data that has not been used for some time and use the freed space for new cached data. I'm guessing some kind of least recently used algorithm is used.


----------



## marvel (Jan 12, 2014)

kpa said:
			
		

> It will drop the cached data that has not been used for some time and use the freed space for new cached data. I'm guessing some kind of least recently used algorithm is used.



Ok so I don't run into the chance that it will eat away all my memory and then the server crashes or something like that


----------



## trh411 (Jan 12, 2014)

marvel said:
			
		

> I didn't configure anything as to how much *memory* L2ARC can use, is there any place to do that?


Be careful with your terminology.

ARC is the primary zfs cache and uses system memory. The currently configured allocations for ARC can be viewed by issuing `sysctl vfs.zfs.arc_max` and `sysctl vfs.zfs.arc_min` commands.

L2ARC is secondary cache and is SSD based. L2ARC will use up to 100% of the space available on the defined cache device(s). L2ARC does not use system memory, even if it fills up its own SSD devices.

You might find the following to be of interest:
https://pthree.org/2012/12/07/zfs-administration-part-iv-the-adjustable-replacement-cache/


----------

