Controlling memory usage

Dag-Erling Smørgrav des at linpro.no
Mon Jul 17 14:01:31 CEST 2006


Anders Nordby <anders at fupp.net> writes:
> Will Varnish dynamically use RAM optimally given how much you have
> available?

Yes and no.  With the file-based storage backend, Varnish stores
documents in a single file which it mmaps, and malloc() is used only
for housekeeping structures.  Memory efficiency in this scenario is
really up to the kernel, specifically the buffer cache.

You can see from the screenshots from day 2 of the live test (online
at <URL:http://www.des.no/varnish/day2/>) that Varnish uses 400 MB RAM
with ~23,000 objects cached.  This later grew to ~45,000 objects, but
I don't have memory usage numbers for that part of the test (I killed
top at some point to look at some other numbers and didn't restart
it).  You can however look at the systat numbers from the last
screenshot:

  293100 wire
  214924 act
 3075272 inact
  201504 cache
  219632 buf

Since the machine isn't swapping, "act" is more or less the sum of the
stacks and heaps of all running processes, including Varnish, while
"cache" and "buf" give an estimate of how much memory is used to cache
disk pages, including Varnish's storage file.  The most impressive
number is "inact", which says that almost three quarters of the
server's 4 GB of memory are completely unused.

Next time, I'll try to remember to take snapshots of Varnish's
/proc/$$/map to get a precise breakdown.

DES
-- 
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no



More information about the varnish-dev mailing list