SV: Question on varnishstat output in 4.1

Christian Gerdes christian.gerdes at
Mon Feb 22 18:07:17 CET 2016

I'm running a fresh install of Varnish 4.1 on RedHat EL6 (installed from varnish repo).

I need some clarification on the varnishstat output. After running for 1000 seconds, with 1 sec update interval, the ncurses stats for hitratio say about 0,63, 0.55 and 0.61, for avg(n) for 10, 100 and 1000 respectivly. However, when I manually calculate the cache hit ratio, I get a lot higher values, and I can not understand how these avg(n) hitratio metrics are calculated.

For example, in the same screenshot with all values, MAIN.cache_hit is 303.5 per second, and MAIN.cache_miss is only 4.4 (for 1000). Thats a hit ratio of 98,6% something in percent when compared to MAIN.client_req wich for 1000 is 307.92 per second.
I have configured grace, with quite a high grace time compared to TTL, so I figured the hitratio is calculated based on client requests and actual backend requests, since a graced response can be considered a cache hit but would trigger a backend request, but that is a lot higher as well. MAIN.backend_req was for 1000 at 46.56 per second. Compared to client_req thats a hit ratio of 84.9%.

So please explain how the numbers for Avg(n) are calculated. I could not find any counters that could arrive at a low hitrate as 61% nor any explaination anywhere in the documentation or online (except that 1.0 means 100% hitratio and it can't get better than that but you can have backend requests anyway because pass in recv does not count as a cache miss) and that was for Varnish 2.x in Kristian Lyngstols blog.

By the way, the avg(n) stats are not explained or mentioned at all in varnish-counters man7 page nor in the varnishstat man pages. Maybe they should ;)


More information about the varnish-misc mailing list