Varnish Cache built-in tools

When I start to use Varnish for my server, it is hard to start a new vcl. Most of vcl copy on internet make my Varnish failed to start.

Later I know there is a tool to test the VCL file. Make sure it is legal, or validated.

varnishd -C -f /path/to/mysetup.vcl

If something wrong, it will show the error. Point out the place of error.

[root@vps varnish]# varnishd -C -f ./test.vcl
Message from VCC-compiler:
Expected an action, 'if', '{' or '}'
(input Line 18 Pos 9)
ban("req.url ~ ^" + req.url + "$ && req.http.host == " + req.http.host);
--------###---------------------------------------------------------------------
Running VCC-compiler failed, exit 1[root@vps varnish]#

So I can modify it and try it again, until it is pass the validation.

 

There are also some tools to help me understand the current situation of Varnish Cache Server.

Varnishstat

varnishstat can be used in two modes, equally useful. If run with only “varnishstat” you will get a continously updated list of the counters that fit on your screen. If you want all the values for indepth analysis you can however use “varnishstat -1” for the current counter values.

varnishstat

Varnishhist

The pipes (|) are requests served from the cache whereas the hash-signs (#) are requests to the backend.

varnishhist

 

Varnishtop

Varnishtop is a very handy tool to get filtered information about your traffic. Especially since alot of high-traffic varnish sites do not have access_logs on their backend servers – this can be of great use.

varnishtop

See what requests are most common to the backend servers.
varnishtop -i txurl

See what useragents are the most common from the clients
varnishtop -i RxHeader -C -I ^User-Agent

See what user agents are commonly accessing the backend servers, compare to the previous one to find clients that are commonly causing misses.
varnishtop -i TxHeader -C -I ^User-Agent

See what cookies values are the most commonly sent to varnish.
varnishtop -i RxHeader -I Cookie

See what hosts are being accessed through varnish. Will of course only give you useful information if there are several hosts behind your varnish instance.
varnishtop -i RxHeader -I '^Host:'

See what accept-charsets are used by clients
varnishtop -i RxHeader -I '^Accept-Charset'