Varnish TTL

Mattias Geniar mattias at nucleus.be
Fri Aug 19 09:05:45 CEST 2016


> Then I assumed after the TTL of 2 hrs , the memory to come down. But still after many hours still the memory is holding up at 80%

That's not how Varnish handles memory. For instance, grace mode can be enabled which allows objects to live on beyond their TTL.

At the same time - if I recall correctly - Varnish won't actively remove objects from cache when the TTL has expired. It will however use that space in memory for new objects to store, evicting the expired objects at that time.

So in short: if you tell Varnish to use 1GB of cache (malloc), it will use 1GB of cache. It won't fall back to 15MB just because all objects are expired.

> after TTL do Varnish releases the consumed memory. Correct me if I'm wrong. Or do we need to explicitly purge it??

See above. This also applies to banning: a "ban" in Varnish will mark an object (or set of objects) for deletion from the cache, but it won't actively delete them.
As soon as a new request is made for that object, Varnish will check the ban list and *then* remove the object.

The rationale is that it's more efficient this way instead of wasting CPU cycles removing/purging content that wouldn't benefit the application.

Mattias 




More information about the varnish-misc mailing list