Varnish Cache Size – How to Check if It’s Ideal

varnish

I've configured my Varnish cache to use a cache size of 512 MB, using:

varnishd ... -s file,/var/cache/varnish.cache,512M

Questions:

  • How do I monitor if 512 MB is too small, too big or okay?
  • How do I get the current usage size of the cache?
  • How do I see how often objects are removed from the cache due to the cache being full?

Best Answer

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.

Related Topic