Varnish's cache hit rate is a percentage of hits among requests that went through vcl_lookup, not all requests.<br><br> - Stig<div><br><div class="gmail_quote">On Wed, Nov 2, 2011 at 10:53 AM, Connor Walls <span dir="ltr"><<a href="mailto:connor.walls@skillpages.com">connor.walls@skillpages.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div lang="EN-IE" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I had a question about the numbers generated in varnishstat. Looking at the current hitrate average for one of our boxes is giving an average of 0.4833 for the last 1000 requests, and the hitrate is in and around this number on all of our varnish boxes. We are also recording the output of varnishlog to a file, including a “X-Cache” header, as per this article: <a href="https://www.varnish-cache.org/trac/wiki/VCLExampleHitMissHeader" target="_blank">https://www.varnish-cache.org/trac/wiki/VCLExampleHitMissHeader</a>. Now, what I’m curious about is whenever I look at the responses that have been logged, <5% of them are being served from the cache, which is at odds with the 48% that varnishstat is reporting. Is the hitrate average only taking into account pages that are passed, and not pages that are fetched? Why is there such a discrepancy between the two values?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Here’s a sample output from varnishstat, if it helps explain things better.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas">4+18:04:37 domU-12-31-39-10-74-A8<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas">Hitrate ratio: 10 100 1000<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas">Hitrate avg: 0.3646 0.4249 0.4833<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 1528600 3.96 3.72 Client connections accepted<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 10346326 23.77 25.19 Client requests received<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 5244804 0.99 12.77 Cache hits<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 9509 0.00 0.02 Cache hits for pass<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 147772 0.00 0.36 Cache misses<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 22490 0.00 0.05 Backend conn. success<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 4731723 21.79 11.52 Backend conn. reuses<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 12459 0.00 0.03 Backend conn. was closed<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 4744236 19.81 11.55 Backend conn. recycles<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 9505 0.00 0.02 Fetch head<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 4727908 20.80 11.51 Fetch with Length<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 1751 0.00 0.00 Fetch chunked<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 422 . . N struct sess_mem<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 96 . . N struct sess<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 4104 . . N struct object<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 4148 . . N struct objectcore<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 4115 . . N struct objecthead<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 48 . . N struct vbe_conn<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 53 . . N worker threads<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 7788 0.00 0.02 N worker threads created<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 0 0.00 0.00 N queued work requests<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 32999 0.00 0.08 N overflowed work requests<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 1 . . N backends<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 136098 . . N expired objects<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 397731 . . N LRU moved objects<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 8861590 17.82 21.58 Objects sent with write<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 1528600 3.96 3.72 Total Sessions<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 10346326 23.77 25.19 Total Requests<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 4600511 20.80 11.20 Total pass<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 4744331 20.80 11.55 Total fetch<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> <a href="tel:5613543692" value="+15613543692" target="_blank">5613543692</a> 14549.86 13669.00 Total header bytes<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 50230527274 64650.96 122311.52 Total body bytes<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 398864 1.98 0.97 Session Closed<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 1 0.00 0.00 Session Pipeline<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 9989106 21.79 24.32 Session Linger<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 4717398 17.82 11.49 Session herd<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 731094771 2065.68 1780.22 SHM records<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 29558086 95.06 71.97 SHM writes<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 14131 0.00 0.03 SHM MTX contention<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 353 0.00 0.00 SHM cycles through buffer<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 3518804 16.83 8.57 SMA allocator requests<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 8184 . . SMA outstanding allocations<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 46354320 . . SMA outstanding bytes<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 12051521527 . . SMA bytes allocated<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 12005167207 . . SMA bytes free<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 357190 1.98 0.87 SMS allocator requests<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 0 . . SMS outstanding allocations<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 0 . . SMS outstanding bytes<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 135529138 . . SMS bytes allocated<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 135529138 . . SMS bytes freed<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 4744578 20.80 11.55 Backend requests made<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 1 0.00 0.00 N vcl total<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 1 0.00 0.00 N vcl available<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 240460 . . N total active purges<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 353239 1.98 0.86 N new purges added<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 112779 0.99 0.27 N old purges deleted<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-size:10.0pt;font-family:Consolas"> 510753 0.99 1.24 N objects tested<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 32284561 412.94 78.61 N regexps tested against<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:Consolas"> 155686 0.99 0.38 N duplicate purges removed<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thanks for any help,<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;color:#1F497D">Connor Walls</span><span style="font-size:10.0pt;color:#1F497D"> </span><u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div><br>_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>
Stig Bakken<br>CTO, Zedge.net - free your phone!<br>
</div>