Varnish, long lived cache and purge on change

Karl Pietri karl at slideshare.com
Wed Aug 19 01:06:03 CEST 2009


Hello everyone,    Recently we decided that our primary page that everyone
views doesn't really change all that often.  In fact it changes very rarely
except for the stats counters (views, downloads, etc).  So we decided that
we wanted to store everything in varnish for a super long time (and tell the
client its not cacheable or cacheable for a very short amount of time),
flush the page from varnish when it truly changes and have a very fast ajax
call to update the stats.  This worked great for about 2 days.   Then we ran
out of ram and varnish started causing a ton of swap activity and it
increased the response times of everything on the site to unusable.

After poking about i seem to have found the culprit.  When you use url.purge
it seems to keep a record of that and check every object as it is fetched to
see if it was purged or not.  To test this i set a script to purge a lot of
stuff and got the same problem to happen.


from varnishstat -1

 n_purge                236369          .   N total active purges
n_purge_add            236388         2.31 N new purges added
n_purge_retire             19         0.00 N old purges deleted
n_purge_obj_test      1651452        16.12 N objects tested
n_purge_re_test    5052057513     49316.27 N regexps tested against
n_purge_dups                0         0.00 N duplicate purges removed

each uptick is when i add 100k new purge records.  you can see what will
happen soon.

http://wrenchies.net/~karl/Automator/ScreenShots/20090818160328.png

We really want to take advantage of this style of essentially having static
html served by varnish and flush it out when it changes.

Does any one have advice on how to do this?

Originally we had implemented this using the vlc to set the ttl to 0 but
with all the combinations of accept-encoding that are possible we were
getting many things not being purged from the cache.

Another thought would be to refetch the page on change instead of purging it
but that has the same problem with accept-encoding.

after 36 hours between the 2 machines we have collected 1.3M objects in the
cache and have not even come close to running out of space.  We would
actually like to increase our ttl for the cached objects even longer.

I hope someone can help me out here.

-Karl Pietri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.linpro.no/pipermail/varnish-misc/attachments/20090818/42d984b8/attachment.htm 


More information about the varnish-misc mailing list