Memory usage

Darryl Dixon - Winterhouse Consulting darryl.dixon at
Wed Jan 27 04:34:01 CET 2010

Hi Martin,

> I'm running Varnish on a box with 4GB RAM. There are hundreds of thousands
> of objects being served, and I'm certain that they don't all fit in that
> relatively meager amount of RAM. I understand that Varnish's model
> dictates
> that the kernel will be trusted to use virtual memory as necessary if the
> cached objects don't fit in RAM. I have a few questions about this:
> 1. How can you tell whether your Varnish objects fit in RAM?

In short, `top` - the VIRT column tells you total virtual process size,
the RES column then tells you which portion of that is currently resident
in physical memory

> 2. If I have objects residing in virtual memory, to what extent will my
> performance be adversely affected? If I want my site to be fast, do I
> basically need to go out and buy as much RAM as it will take so that
> virtual memory isn't needed?

Pretty much.

> 3. I noticed tonight that my machine was using a few hundred megs of swap
> space, which I've never seen happen before. Varnish is the only non-system
> service running on this box. My understanding was that Varnish would get
> only as much RAM as was available and then send the overflow into the
> file-backed virtual memory. If that's the case, though, then why is swap
> space being used? Is this just a side effect of how the kernel allocates
> memory, or is something else going on here?

Two things;
1) The varnish process itself requires memory (eg, to hold the ban list
etc), which is not part of the file-backed object cache.
2) Even if the above usage were minimal, it is still entirely possibly
that your VMM (the OS) has decided that the memory being used to cache
objects is more important that some other system processes that have now
been shunted out to swap. Once again, `top` VIRT versus RES will give you
a good clue

Darryl Dixon
Winterhouse Consulting Ltd

More information about the varnish-misc mailing list