Mailing List Archive

Understanding cache utilisation
Hello,

For at least one site that I am using Varnish Cache for, the allocated
cache size is fully utilised and objects are now being nuked/evicted
from the cache. Before I blindly supply more resources to provide a
larger cache, I'd like to understand if the cache space is being used
optimally.

For example, of the objects that are expiring naturally, were they
ever used to serve a cache hit? If not, it was probably wasteful to
store them in the cache in the first place.

Of the objects that are being nuked/evicted, were they close to their
natural expiration time anyway? Were they ever used to serve a cache
hit?

Of the objects that have been nuked, are they requested shortly after,
suggesting it may have been worth having a larger cache in order to
retain them a bit longer?

I did not see an easy way to answer these questions with the standard
Varnish toolset - am I missing something?

I looked through the code paths in Varnish 5.1 responsible for
expiration and nuking and it seems the object hit count and ttl is
available in that context - would it be worth writing a patch to log
these fields to the VSL?

How do others ensure their allocated cache size is well utilised
before growing the cache?

Regards,

Jason
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Understanding cache utilisation [ In reply to ]
> Of the objects that are being nuked/evicted, were they close to their
> natural expiration time anyway? Were they ever used to serve a cache
> hit?
>
> Of the objects that have been nuked, are they requested shortly after,
> suggesting it may have been worth having a larger cache in order to
> retain them a bit longer?
>
> I did not see an easy way to answer these questions with the standard
> Varnish toolset - am I missing something?

I think you are correct. The grace period could also be responsible for
keeping expired objects around and making them good candidates for
LRU eviction.

> I looked through the code paths in Varnish 5.1 responsible for
> expiration and nuking and it seems the object hit count and ttl is
> available in that context - would it be worth writing a patch to log
> these fields to the VSL?

You could add a `t=%f` to the `ExpKill LRU` log records, and introduce
something like a `h=%d` for hits and add it to the LRU and EXP_*
variants of the ExpKill record.

See `man vsl` for Expkill. I'm not sure such a patch would be
accepted as we usually are cautious with the VSL throughput but at
least I would gladly review it (merging's not my call in this area).

Dridi
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Understanding cache utilisation [ In reply to ]
Hello Jason,

Just an idea, before patching: log obj.hits and obj.age to get an idea of
what you are delivering.

--
Guillaume Quintard

On Nov 7, 2017 07:23, "Jason Stangroome" <jason@codeassassin.com> wrote:

> Hello,
>
> For at least one site that I am using Varnish Cache for, the allocated
> cache size is fully utilised and objects are now being nuked/evicted
> from the cache. Before I blindly supply more resources to provide a
> larger cache, I'd like to understand if the cache space is being used
> optimally.
>
> For example, of the objects that are expiring naturally, were they
> ever used to serve a cache hit? If not, it was probably wasteful to
> store them in the cache in the first place.
>
> Of the objects that are being nuked/evicted, were they close to their
> natural expiration time anyway? Were they ever used to serve a cache
> hit?
>
> Of the objects that have been nuked, are they requested shortly after,
> suggesting it may have been worth having a larger cache in order to
> retain them a bit longer?
>
> I did not see an easy way to answer these questions with the standard
> Varnish toolset - am I missing something?
>
> I looked through the code paths in Varnish 5.1 responsible for
> expiration and nuking and it seems the object hit count and ttl is
> available in that context - would it be worth writing a patch to log
> these fields to the VSL?
>
> How do others ensure their allocated cache size is well utilised
> before growing the cache?
>
> Regards,
>
> Jason
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: Understanding cache utilisation [ In reply to ]
On Tue, Nov 7, 2017 at 8:09 AM, Guillaume Quintard
<guillaume@varnish-software.com> wrote:
> Hello Jason,
>
> Just an idea, before patching: log obj.hits and obj.age to get an idea of
> what you are delivering.

Indeed, if you keep track of the relevant bits (like varnishncsa only keeps
track of what's needed by its format) you could cheaply (for a given amount
of "cheap") correlate this with LRU evictions.

I'm in the general opinion of making the logs useful, that's why I submitted
a change in 5.2 to get at least the VXID on Hit* records, not just the fact
that we hit something.

Dridi
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc