In Varnish stats, what does “Backend conn. reuses” and “recycles” mean

varnish

I have varnish installed and I think it's working properly (not sure if it matters but I am using iptables reroute method to route ports incoming:80 > varnish:8080 > apache:80

Anyway, In varnishstat I see a pretty high Hitrate average (60-80%) which I am working on but I am unclear at what all of the stats presented by varnishstat

Specifically the following Backend stats:

380         0.00         0.26 Backend conn. success
10122      15.00         6.85 Backend conn. reuses
267         0.00         0.18 Backend conn. was closed
10391      15.00         7.04 Backend conn. recycles

I've read a blog post called "Varnishstat for dummies" which outlines a lot of details of varnishstat (I recommend it for beginners) but it does not go over these Backend stats.

Feel free to explain here or link to a resource I've missed 🙂

thanks!

Best Answer

The first number ("Backend connections initiated") is the total number of (TCP socket) connections that has been opened from Varnish to the backend. This number is a counter.

"Backend connections recycled" is increased whenever we have a keep-alive connection that is put back into the pool of connections. It has not yet been used, but it might be, unless the backend closes it.

"Backend connections reused" is increased whenever we actually reuse a connection from the pool of backend connections.

Last, "Backend connections unused", are the number of available connections at any given time. This number is an absolute number, and will increase and decrease during operation.

Source : https://www.varnish-cache.org/trac/wiki/StatsExplained