Warming up Varnish Cache with varnishreplay

Varnish Cache 2.0 included a feature that hasn't really been used much but might be a very useful tool should you ever need it. It can be used to replay traffic from the log onto another.

Here I'll try to replay the traffic from www.varnish-cache.org onto a Varnish instance installed on my local machine.

$ ssh www.varnish-cache.org varnishlog -w - | varnishreplay -a localhost:6081 -r -

Let's go through what is does. The first part logs into the server and grabs the raw varnishlog and pipes it to standard output. Then we pipe than into a varnishlog instance that attaches to my local Varnish running on localhost, port 6081.

Now I can see actual traffic from varnish-cache.org being replayed on my local setup. I've made varnish-cache.org a backend to my Varnish and I can play around with the VCL and parameters to see how it affects hit rate and such.

It could also be used to keep a standby cache warm by transmitting some of the traffic to the spare datacenter. Or you could record some of the traffic you have during normal traffic to play back whenever you restart a cache before letting it enter the cluster.

Finally, a word of warning. varnishreplay is not the most mature tool in our toolbox. It hasn't seen that much use over the years. I think there are some limitations on how accurately it replays traffic. Bug reports are very welcome should you find any.

Keen to learn more about Varnish Cache? Take a look at our on-demand webinar.

Download the webinar

Image (c) 2008 Anne Helmond. Used under CC BY 2.0.

All things Varnish related

The Varnish blog is where the our team writes about all things related to Varnish Cache and Varnish Software...or simply vents.