[patch] [experimental] release unneeded graced objects

Nils Goroll slink at schokola.de
Thu Nov 4 20:27:07 CET 2010


Hi,

I've written a patch for something which has annoyed me for long:

It's nice to have a really long grace period, such that even when all backend
servers go down, Varnish can keep most of a website up.

But setting a (really) long grace period (to catch most of the long tail) will
mean that expiry by TTL (object time_when = ttl + grace, actually) will
effectively be disabled and objects will get nuked by LRU only (mostly).
varnishstat figures for such a configuration might look like this:

     3451931          .            .   N expired objects
   239097244          .            .   N LRU nuked objects
  1059383291          .            .   N LRU moved objects


Even more importantly, the cache will contain many copies of each object, so it
will become unnecessarily huge (at least until the backend refresh
implementation is done, which we're working on). I am not using -spersistent so
I can't tell from own experience, but with persistent storage, using a long
grace time will probably be unfeasible.

The attached patch basically shuffles some of phk's code around in cache_hash.c
(I guess I might have written half a dozen lines myself :) ) to collect unneeded
graced objects while looking for a graced object. All graced objects older than
the youngest (which also match the other criteria (think Vary)) will get released.

This should dramatically reduce the effective cache size on systems with long
grace, bring up the expired / nuked ratio, and speed up cache lookup, because
the object list hanging off head object head should shrink significantly.

The additional code will only kick in when a graced object needs to be looked
up, so it should not lower efficiency for the standard case. But still it think
a better place for this might be somewhen after inserting an object into the cache.

The patch passes all tests, but I HAVE NOT TESTED IT IN PRODUCTION. Be warned.
Any feedback from pre-production or production tests is more than welcome.

Thanks, Nils
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: varnish.release_unneeded_objects_in_grace.patch
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20101104/df7f2bf1/attachment-0003.ksh>


More information about the varnish-dev mailing list