Cache size

Michael Fischer michael at
Tue Mar 16 17:50:58 CET 2010

Unless you're using Varnish to implement your own edge-caching
service, I am not sure you're going to see significant improvement in
overall image-fetch latency.  As has been discussed in many threads in
the past, Apache and other general-purpose webservers can serve
responses for static resource requests as fast as Varnish can.

If there is truly a hot set of images, then your image server's kernel
will automatically place the popular images in its buffer cache and
Apache/whatever will serve directly from RAM anyway.

And if the working set is larger than your total image server's RAM,
then adding a Varnish layer will only complicate matters without
significantly boosting performance.  Varnish does not make slow disks

You may well be better off just adding more RAM to your image servers
instead of wasting it on an unnecessary Varnish tier.

And if you're not using a general-purpose webserver on your image
servers, fix that first.  There's no benefit in running
application-specific webservers for the purpose of serving static


On Tue, Mar 16, 2010 at 3:47 AM, Ketil Froyn <ketil at> wrote:
> Hi Martin,
> Thanks! :) My main concern has to do with adding one more level of
> complexity into the service I'm running, as a problem with my Varnish
> configuration could result in downtime of the service.
> What I'm considering is to put Varnish in front of a static webserver
> which has about 500GB of images and preview files, distributed across
> a few hundred thousand files of anything from a couple of Kb to a few
> Mb. It's all pretty static content, but more is added all the time,
> some files are fetched a lot more often than others, and new files
> tend to be fetched a fair bit. Since there's that much data, I'm
> concerned about running into some thrashing issues during traffic
> peaks, for instance.
> Assuming the definition of "working data set" is approximately the
> size of all distinct files loaded in TTL time (eg one hour), plus a
> bit extra per file for headers etc, let's say that the working data
> set size is about 10GB. Would I get away with a varnish server with
> 1GB RAM and 15-20GB allocated disk space, just to have a bit of
> headroom?
> Cheers, Ketil
> On Tue, Mar 16, 2010 at 8:09 AM, Martin Boer <martin.boer at> wrote:
>> Ketil,
>> If the server has enough diskspace it doesn't really matter.
>> I use 15GB as that is the free space of the largest disk partition on my
>> smallish server.
>> I'd suggest you just start using and finetuning varnish. And if you can
>> spare the diskspace,
>> don't be shy about it. Just throw a lot at varnish.
>> You might or might not want to cache everything, might want to cache the
>> same content multiple times for several browsertypes, might want to cache
>> some stuff only for an hour while other stuff for ages and ages.
>> All these things will affect the amount of cache you use.
>> Varnish will increase performance from your current webserver(s), so you've
>> won already. :)
>> Regards,
>> Martin
>> Ketil Froyn wrote:
>>> Hi,
>>> The Varnish FAQ says:
>>> Q: How large a cache do I need?
>>> A: You should have a cache at least the size of your working data set. ...
>>> Is there a good way to determine the size of the working data set, so
>>> that I can be pretty sure I'm allocating the right amount of resources
>>> for this?
>>> Regards, Ketil
>>> _______________________________________________
>>> varnish-misc mailing list
>>> varnish-misc at
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at

More information about the varnish-misc mailing list