<div class="gmail_quote">On Tue, Jan 26, 2010 at 7:23 PM, Martin Goldman <span dir="ltr"><<a href="mailto:me@mgoldman.com">me@mgoldman.com</a>></span> wrote:</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote">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:<br>


<br>1. How can you tell whether your Varnish objects fit in RAM?<br></div></blockquote><div><br></div><div>You can't guarantee that they will unless you set your cache size at or below the amount of RAM you have installed.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">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?<br>
</div></blockquote><div><br></div><div>Technically, it's "go out and buy as much RAM as it will take to avoid being swamped by paging".  But yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote">

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?</div>
</blockquote><div><br></div><div>Is your backing store file-based, or malloc-based?  If the latter, that would explain the swap space being consumed.  Or, as Darryl said, the housekeeping overhead of a VERY large file-backed cache could make the Varnish process very large.</div>
<div><br></div><div>--Michael</div></div>