Controlling memory usage

Dag-Erling Smørgrav des at
Mon Jul 17 21:34:49 CEST 2006

Anders Berg <andersb at> writes:
> The reason Anders N. asks about this is how Squid works today. The
> squid.conf file leaves you with a option to specify how much RAM you
> wanna use for Squid.

I've worked with Squid quite a lot myself, and IIRC it normally uses
about four times as much as you specify in the config file...

>                      The problem is that Squid (probably because of
> old design) does not really "follow" that option. If you set 256 MB
> RAM, you can still end up using 500 MB RAM, and if you set option
> close to max memory you will for certain overflow your physical RAM
> and start swapping/die. Your answer was detailed Poul-Henning, but
> what will prevent this from happpening in Varnish? Lets say you have
> 2 applications running on a Varnish box, and both use the memory
> model Varnish uses, what will happen in the long run with a lot of
> traffic? Will they both adjust themselvs to match pysical RAM, how
> would they "compete" for RAM etc? It's possible you have already
> answered that below, but how do we "limit" RAM usage?

We don't.  The kernel takes care of it.  If memory is scarce, the
kernel will allocate less memory to the buffer cache and Varnish
performance will decrease.

(assuming you use file storage, not malloc storage)

As for heap usage, which the kernel has less control over, it is
mostly a function of the number of objects in the cache; we can take
care of that by setting an upper limit on the number of cached
objects, or even on the amount of heap used to track objects.

Dag-Erling Smørgrav
Senior Software Developer
Linpro AS -

More information about the varnish-dev mailing list