How to check if chosen Varnish cache size is ideal?
Solution 1:
I found the solution:
You can monitor how much of the maximum cache size (512 MB in this case) that Varnish has allocated by running varnishstat
. Then look for the output lines "bytes allocated" and "bytes free".
The following relation holds:
Command line configuration of max size = [bytes allocated] + [bytes free]
Depending on the size of "bytes free" you can fine-tune your cache size to find a proper level.
Solution 2:
Watch the n_lru_nuked
counter. Each time it increases, Varnish throws something out of the cache because it is running low on storage.
Ideally, you wouldn't want the LRU counter to increase at all since kicking stuff out of cache usually means it must be re-fetched, but if your tail is long, LRU cannot be avoided.