Hi Kristian,<div>Thanks for the explanation. However, I'm still struggling with how to make sense of the first part of my post. Specifically, how do I know how much of my cache has been used and how severely under allocated is it? If there is some memory free, why is n_lru_nuked increasing at a rate of ~50/s?</div>
<div><br></div><div>I have another varnish box with 24GB of RAM and a 20GB cache file with the following stats:</div><div><div>varnishstat -1 -f n_lru_nuked,sm_bfree,sm_balloc</div><div>n_lru_nuked          11350022          .   N LRU nuked objects</div>
<div>sm_balloc          4124241920          .   bytes allocated</div><div>sm_bfree          17350594560          .   bytes free</div></div><div><br></div><div>According to the calculation above then the used memory would be negative. Am I misunderstanding something?</div>
<div><br></div><div>Thanks,</div><div>Damon</div><div><br><div class="gmail_quote">On Thu, Sep 8, 2011 at 12:40 AM, Kristian Lyngstol <span dir="ltr"><<a href="mailto:kristian@varnish-software.com">kristian@varnish-software.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Wed, Sep 07, 2011 at 11:46:34AM -0700, Damon Snyder wrote:<br>
> According to the docs, the key statistic to look at is n_lru_nuked. This<br>
> value is constantly increasing. Every time you run 'varnishstat -1 -f<br>
> n_lru_nuked' the value changes. However, the value of sm_bfree seems to<br>
> always show some space available:<br>
><br>
> varnishstat -1 -f n_lru_nuked,sm_bfree,sm_balloc<br>
> n_lru_nuked         135193763          .   N LRU nuked objects<br>
> sm_balloc          5468946432          .   bytes allocated<br>
> sm_bfree           <a href="tel:2047246336" value="+12047246336">2047246336</a>          .   bytes free<br>
<br>
</div>sm_bfree is a counter of how much memory has been freed, not how much is<br>
available. Every time an object is removed, expired, etc, this will<br>
increase, and it is never reduced. _balloc is the counter part of that,<br>
and is increased every time something is allocated, and never reduced.<br>
>From these numbers you can calculate how much memory is currently used:<br>
<br>
 5468946432 - <a href="tel:2047246336" value="+12047246336">2047246336</a> = 3421700096 (a little over 3GB)<br>
<br>
However, you don't have to actually do that yourself, as _nbytes is<br>
doing exactly that.<br>
<br>
An important detail is that the size specified in the -s arguments is<br>
/not/ the total memory footprint varnish will have. It is only the total<br>
cache size for actual data, not counting overhead. For Varnish 2.1, we<br>
know that there's an additional overhead of slightly over 1kB for each<br>
object stored, assuming 64-bit systems (your millage may vary, but this<br>
gives you an idea).<br>
<br>
On top of that is a bit of data for things like threads and sessions,<br>
but I rarely take that into consideration myself as it will be a<br>
practically constant size measured in MB. Assuming the memory-footprint<br>
for each thread is 10kB (it's unlikely that it's that large, specially<br>
considering copy-on-write and whatnot), 1000 threads will give a<br>
constant overhead of 10MB, so not something to consider.<br>
<br>
However, 10 million objects will give 10GB of overhead, so that should<br>
be accounted for when you decide how much memory the cache will use with<br>
-s. Examples I've run with is -s malloc,24GB and -s malloc,28GB on two<br>
different sites, both running on a 32GB-system but with different<br>
average object-size.<br>
<br>
Hopefully this helps you figure out what's going on.<br>
<font color="#888888"><br>
- Kristian<br>
<br>
</font></blockquote></div><br></div>